@Override public int getWidth () { return source.getWidth(); } }
ForeCounter (ByteProcessor filter, Wrapper<Integer> fore) { this.filter = filter; this.fore = fore; filterWidth = filter.getWidth(); filterHeight = filter.getHeight(); }
/** * Report the RunTable created with the runs retrieved from the provided source. * * @param source the source to read runs from. * @return a populated RunTable */ public RunTable createTable (ByteProcessor source) { // ROI is defined as the whole source final Rectangle roi = new Rectangle(0, 0, source.getWidth(), source.getHeight()); return createTable(source, roi); }
static public final BufferedImage convertToBufferedImage(final ByteProcessor bp) { bp.setMinAndMax(0, 255); // TODO what is this doing here? The ByteProcessor.setMinAndMax is destructive, it expands the pixel values to the desired range. final Image img = bp.createImage(); if (img instanceof BufferedImage) return (BufferedImage)img; //else: final BufferedImage bi = new BufferedImage(bp.getWidth(), bp.getHeight(), BufferedImage.TYPE_BYTE_INDEXED, Loader.GRAY_LUT); bi.createGraphics().drawImage(img, 0, 0, null); return bi; }
/** Constructs a ByteBlitter from a ByteProcessor. */ public ByteBlitter(ByteProcessor ip) { this.ip = ip; width = ip.getWidth(); height = ip.getHeight(); pixels = (byte[])ip.getPixels(); }
public ByteAccessor(ByteProcessor ip) { w = ip.getWidth(); h = ip.getHeight(); pixels = (byte[])ip.getPixels(); }
private void initHistogram(ByteProcessor image) { byte[] pixels=(byte[])image.getPixels(); int w=image.getWidth(),h=image.getHeight(); for(int i=0;i<w*h;i++) { int value=pixels[i]; if(value<0) value+=256; values[value]++; } }
/** Constructs a ByteBlitter from a ByteProcessor. */ public ByteBlitter(ByteProcessor ip) { this.ip = ip; width = ip.getWidth(); height = ip.getHeight(); pixels = (byte[])ip.getPixels(); }
public GenericAccumulator(int x, int y, ByteProcessor mask) { this.x = x; this.y = y; width = mask.getWidth(); height = mask.getHeight(); pixels = (byte[])mask.getPixels(); }
/** Returns the specified plane (1=red, 2=green, 3=blue, 4=alpha) as a ByteProcessor. */ public ByteProcessor getChannel(int channel, ByteProcessor bp) { int size = width*height; if (bp == null || bp.getWidth()!=width || bp.getHeight()!=height) bp = new ByteProcessor(width, height); byte[] bPixels = (byte[])bp.getPixels(); int shift = 16 - 8*(channel-1); if (channel==4) shift=24; for (int i=0; i<size; i++) bPixels[i] = (byte)(pixels[i]>>shift); return bp; }
private void initializeToFore (ByteProcessor input, DistanceTable output) { for (int i = (input.getWidth() * input.getHeight()) - 1; i >= 0; i--) { if (input.get(i) == 0) { output.setValue(i, VALUE_TARGET); // reference pixel -> distance=0 } else { output.setValue(i, VALUE_UNKNOWN); // non-reference pixel -> to be computed } } }
final static protected FloatProcessor scaleByte( final ByteProcessor bp ) { final FloatProcessor fp = new FloatProcessor( bp.getWidth(), bp.getHeight() ); final byte[] bytes = ( byte[] )bp.getPixels(); final float[] floats = ( float[] )fp.getPixels(); for ( int i = 0; i < bytes.length; ++i ) floats[ i ] = ( bytes[ i ] & 0xff ) / 255.0f; return fp; }
@Override public DistanceTable computeToBack (ByteProcessor input) { DistanceTable output = allocateOutput(input.getWidth(), input.getHeight(), normalizer); initializeToBack(input, output); process(output); return output; }
@Override public DistanceTable computeToFore (ByteProcessor input) { DistanceTable output = allocateOutput(input.getWidth(), input.getHeight(), normalizer); initializeToFore(input, output); process(output); return output; }
/** Creates a BinaryProcessor from a ByteProcessor. The ByteProcessor must contain a binary image (pixels values are either 0 or 255). Backgound is assumed to be white. */ public BinaryProcessor(ByteProcessor ip) { super(ip.getWidth(), ip.getHeight(), (byte[])ip.getPixels(), ip.getColorModel()); setRoi(ip.getRoi()); parent = ip; }
private void merge (ByteProcessor img, boolean[][] lines) { for (int y = 0, h = img.getHeight(); y < h; y++) { for (int x = 0, w = img.getWidth(); x < w; x++) { if (lines[x][y]) { img.set(x, y, PixelSource.BACKGROUND); } } } } }
/** Creates a BinaryProcessor from a ByteProcessor. The ByteProcessor must contain a binary image (pixels values are either 0 or 255). Backgound is assumed to be white. */ public BinaryProcessor(ByteProcessor ip) { super(ip.getWidth(), ip.getHeight(), (byte[])ip.getPixels(), ip.getColorModel()); setRoi(ip.getRoi()); parent = ip; }
/** 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 ByteProcessor ip) { final byte[] pix = (byte[])ip.getPixels(); final float[] data = new float[pix.length]; for (int i=0; i<pix.length; i++) data[i] = pix[i]&0xff; final FloatProcessor fp = new FloatProcessorT2(ip.getWidth(), ip.getHeight(), data, ip.getColorModel(), ip.getMin(), ip.getMax()); return fp; } /** A method that circumvents the findMinAndMax when creating a float processor from an existing processor. Ignores color calibrations and does no scaling at all. */
Roi getRoiNonBackground( ByteProcessor bp ) { bp.setThreshold(1,255,ImageProcessor.NO_LUT_UPDATE); // bp.threshold(0); ImageStack tempStack = new ImageStack(bp.getWidth(),bp.getHeight()); tempStack.addSlice(null,bp); ImagePlus imp = new ImagePlus("example stack",tempStack); ThresholdToSelection tts = new ThresholdToSelection(); tts.setup( "", imp ); tts.run(bp); // imp.show(); return imp.getRoi(); }