private static final ImageProcessor createProcessor(final int w, final int h, final int type) { if (type == ImagePlus.COLOR_RGB) return new ColorProcessor(w, h); return new ByteProcessor(w, h); } }
private static final ImageProcessor createProcessor( final int w, final int h, final int type) { if(type == ImagePlus.COLOR_RGB) return new ColorProcessor(w, h); return new ByteProcessor(w, h); } }
public ImageProcessor getMask() { if (cachedMask!=null && cachedMask.getPixels()!=null) return cachedMask; ImageProcessor mask = new ByteProcessor(width, height); for (int i=0; i<nPoints; i++) mask.putPixel((int)Math.round(xpf[i]), (int)Math.round(ypf[i]), 255); cachedMask = mask; return mask; }
public ImageProcessor getMask() { if (cachedMask!=null && cachedMask.getPixels()!=null) return cachedMask; ImageProcessor mask = new ByteProcessor(width, height); for (int i=0; i<nPoints; i++) mask.putPixel((int)Math.round(xpf[i]), (int)Math.round(ypf[i]), 255); cachedMask = mask; return mask; }
/** Returns a byte[3][256] containing the colors of the fire LUT. */ public static final IndexColorModel fireLUT() { final ImagePlus imp = new ImagePlus("fire", new ByteProcessor(1, 1)); IJ.run(imp, "Fire", ""); return (IndexColorModel) imp.getProcessor().getColorModel(); }
private void drawRoundedRect(ImageProcessor ip) { int margin = (int)getStrokeWidth()/2; BufferedImage bi = new BufferedImage(width+margin*2+1, height+margin*2+1, BufferedImage.TYPE_BYTE_GRAY); Graphics2D g = bi.createGraphics(); if (stroke!=null) g.setStroke(stroke); g.drawRoundRect(margin, margin, width, height, cornerDiameter, cornerDiameter); ByteProcessor mask = new ByteProcessor(bi); ip.setRoi(x-margin, y-margin, width+margin*2+1, height+margin*2+1); ip.fill(mask); }
/** Returns a new, blank ByteProcessor with the specified width and height. */ public ImageProcessor createProcessor(int width, int height) { ImageProcessor ip2; ip2 = new ByteProcessor(width, height, new byte[width*height], getColorModel()); if (baseCM!=null) ip2.setMinAndMax(min, max); ip2.setInterpolationMethod(interpolationMethod); return ip2; }
/** 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 ByteProcessor doit(ImageProcessor ip, byte[] mapping) { byte[] pixels=(byte[])ip.getPixels(); int w=ip.getWidth(),h=ip.getHeight(); byte[] result=new byte[w*h]; for(int i=0;i<w*h;i++) { int value=pixels[i]; if(value<0) value+=256; result[i]=mapping[value]; } return new ByteProcessor(w, h, result, null); }
static public final ImageProcessor createProcessor(final int type, final int width, final int height) { switch (type) { case ImagePlus.GRAY8: return new ByteProcessor(width, height); case ImagePlus.GRAY16: return new ShortProcessor(width, height); case ImagePlus.GRAY32: return new FloatProcessor(width, height); case ImagePlus.COLOR_RGB: return new ColorProcessor(width, height); } return null; }
public void makeMask(ImageProcessor ip, Rectangle r) { mask = ip.getMask(); if (mask==null) { mask = new ByteProcessor(r.width, r.height); mask.invert(); } else { // duplicate mask (needed because getMask caches masks) mask = mask.duplicate(); } mask.invert(); }
public void makeMask(ImageProcessor ip, Rectangle r) { mask = ip.getMask(); if (mask==null) { mask = new ByteProcessor(r.width, r.height); mask.invert(); } else { // duplicate mask (needed because getMask caches masks) mask = mask.duplicate(); } mask.invert(); }
ImageProcessor makeMask(ImageProcessor ip, Rectangle r, ImagePlus imp) { ImageProcessor mask = imp.getMask(); if (mask==null) { mask = new ByteProcessor(r.width, r.height); mask.invert(); } else { // duplicate mask (needed because getMask caches masks) mask = mask.duplicate(); } mask.invert(); return mask; }
ImageProcessor reduceColors(ImageProcessor ip) { MedianCut mc = new MedianCut((int[])ip.getPixels(), ip.getWidth(), ip.getHeight()); Image img = mc.convert(256); return(new ByteProcessor(img)); }
private ImagePlus makeTestImage(final String title, final int width, final int height, final int... pixels) { assertEquals( pixels.length, width * height ); final byte[] bytes = new byte[pixels.length]; for (int i = 0; i < bytes.length; i++) bytes[i] = (byte)pixels[i]; final ByteProcessor bp = new ByteProcessor( width, height, bytes, null ); return new ImagePlus( title, bp ); }
private ImageProcessor createImage_Square4x4 () { ImageProcessor image = new ByteProcessor(10, 10); image.setValue(0); image.fill(); for (int y = 3; y < 7; y++) { for (int x = 3; x < 7; x++) { image.set(x, y, 255); } } return image; }
private ImageProcessor createImage_Square4x4 () { ImageProcessor image = new ByteProcessor(10, 10); image.setValue(0); image.fill(); for (int y = 3; y < 7; y++) { for (int x = 3; x < 7; x++) { image.set(x, y, 255); } } return image; }
private ImageProcessor createImage_Square10x10 () { ImageProcessor image = new ByteProcessor(30, 30); image.setValue(0); image.fill(); for (int y = 10; y < 20; y++) { for (int x = 10; x < 20; x++) { image.set(x, y, 255); } } return image; }
private ImageProcessor createImage_Square4x4 () { ImageProcessor image = new ByteProcessor(10, 10); image.setValue(0); image.fill(); for (int y = 3; y < 7; y++) { for (int x = 3; x < 7; x++) { image.set(x, y, 255); } } return image; }
private ImageProcessor createImage_Square10x10 () { ImageProcessor image = new ByteProcessor(30, 30); image.setValue(0); image.fill(); for (int y = 10; y < 20; y++) { for (int x = 10; x < 20; x++) { image.set(x, y, 255); } } return image; }