Java Code Examples for ij.process.ShortProcessor#getWidth()
The following examples show how to use
ij.process.ShortProcessor#getWidth() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ShortRenderer.java From render with GNU General Public License v2.0 | 5 votes |
/** * Converts the processor to a short (16-bit) image. * * @param renderedImageProcessorWithMasks processor to convert. * * @return the converted image. */ public static BufferedImage targetToShortImage(final ImageProcessorWithMasks renderedImageProcessorWithMasks) { // convert to 16-bit gray-scale final ShortProcessor sp = renderedImageProcessorWithMasks.ip.convertToShortProcessor(); final BufferedImage image = new BufferedImage(sp.getWidth(), sp.getHeight(), BufferedImage.TYPE_USHORT_GRAY); final WritableRaster raster = image.getRaster(); raster.setDataElements(0, 0, sp.getWidth(), sp.getHeight(), sp.getPixels()); return image; }
Example 2
Source File: DownsamplerTest.java From TrakEM2 with GNU General Public License v3.0 | 5 votes |
final private static void testShort( ShortProcessor ipShort ) { final double min = ipShort.getMin(); final double max = ipShort.getMax(); while( ipShort.getWidth() > 32 ) { ipShort = Downsampler.downsampleShortProcessor( ipShort ); ipShort.setMinAndMax( min, max ); } }
Example 3
Source File: Utils.java From TrakEM2 with GNU General Public License v3.0 | 5 votes |
/** A method that circumvents the findMinAndMax when creating a float processor from an existing processor. Ignores color calibrations and does no scaling at all. */ static public final FloatProcessor fastConvertToFloat(final ShortProcessor ip) { final short[] pix = (short[])ip.getPixels(); final float[] data = new float[pix.length]; for (int i=0; i<pix.length; i++) data[i] = pix[i]&0xffff; final FloatProcessor fp = new FloatProcessorT2(ip.getWidth(), ip.getHeight(), data, ip.getColorModel(), ip.getMin(), ip.getMax()); return fp; }
Example 4
Source File: ExportBestFlatImage.java From TrakEM2 with GNU General Public License v3.0 | 5 votes |
protected FloatProcessor convertToFloat( final ShortProcessor sp ) { final short[] pixS = (short[]) sp.getPixels(); loader.releaseToFit( pixS.length * 4 ); final float[] pixF = new float[pixS.length]; for ( int i=0; i<pixS.length; ++i) { pixF[i] = pixS[i] & 0xffff; } return new FloatProcessor( sp.getWidth(), sp.getHeight(), pixF ); }
Example 5
Source File: HackLabelEdgesClient.java From render with GNU General Public License v2.0 | 4 votes |
@Override protected ImageProcessor loadImageProcessor(final String url, final int downSampleLevels, final boolean isMask, final boolean convertTo16Bit) throws IllegalArgumentException { final ImageProcessor imageProcessor = super.loadImageProcessor(url, downSampleLevels, isMask, convertTo16Bit); if (! isMask) { final ShortProcessor shortProcessor = (ShortProcessor) imageProcessor; final List<TileEdgeAndColor> tileEdgeAndColorList = urlToEdgeAndColorList.get(url); if (tileEdgeAndColorList != null) { for (final TileEdgeAndColor tileEdgeAndColor : tileEdgeAndColorList) { int minX = 0; int maxX = shortProcessor.getWidth(); int minY = 0; int maxY = shortProcessor.getHeight(); switch (tileEdgeAndColor.tileEdge.position) { case TOP: maxY = minY + edgePixelSize; break; case RIGHT: minX = maxX - edgePixelSize; break; case BOTTOM: minY = maxY - edgePixelSize; break; case LEFT: maxX = minX + edgePixelSize; break; } final short edgeRGB = (short) tileEdgeAndColor.color.getRGB(); for (int y = minY; y < maxY; y++) { for (int x = minX; x < maxX; x++) { shortProcessor.set(x, y, edgeRGB); } } if (LOG.isDebugEnabled()) { LOG.debug("loadImageProcessor: set {} {} pixel edge of tile {} to color {}", tileEdgeAndColor.tileEdge.position, edgePixelSize, tileEdgeAndColor.tileEdge.tileId, shortProcessor.get(minX, minY)); } } } } return imageProcessor; }
Example 6
Source File: ImagePlusMatConverter.java From IJ-OpenCV with GNU General Public License v3.0 | 3 votes |
/** * Duplicates {@link ShortProcessor} to the corresponding OpenCV image of * type {@link Mat}. * * @param sp The {@link ShortProcessor} to be converted * @return The OpenCV image (of type {@link Mat}) */ public static Mat toMat(ShortProcessor sp) { final int w = sp.getWidth(); final int h = sp.getHeight(); final short[] pixels = (short[]) sp.getPixels(); return new Mat(h, w, opencv_core.CV_16UC1, new ShortPointer(pixels)); }