void filterIntensity(ImageProcessor ip) { ColorProcessor cp = (ColorProcessor)ip; int width = cp.getWidth(); int height = cp.getHeight(); int size = width*height; byte[] H = new byte[size]; byte[] S = new byte[size]; byte[] B = new byte[size]; cp.getHSB(H, S, B); ImageProcessor ip2 = new ByteProcessor(width, height, B, null); filter(ip2); cp.setHSB(H, S, (byte[])ip2.getPixels()); }
/** Create or subtract a background, based on the brightness of an RGB image (keeping * the hue of each pixel unchanged) * @param ip The RGB image. On output, it will become the background-subtracted image or * the background (depending on <code>createBackground</code>). * @param radius Radius of the rolling ball creating the background (actually a * paraboloid of rotation with the same curvature) * @param createBackground Whether to create a background, not to subtract it. * @param lightBackground Whether the image has a light background. * @param doPresmooth Whether the image should be smoothened (3x3 mean) before creating * the background. With smoothing, the background will not necessarily * be below the image data. * @param correctCorners Whether the algorithm should try to detect corner particles to avoid * subtracting them as a background. */ public void rollingBallBrightnessBackground(ColorProcessor ip, double radius, boolean createBackground, boolean lightBackground, boolean useParaboloid, boolean doPresmooth, boolean correctCorners) { int width = ip.getWidth(); int height = ip.getHeight(); byte[] H = new byte[width*height]; byte[] S = new byte[width*height]; byte[] B = new byte[width*height]; ip.getHSB(H, S, B); ByteProcessor bp = new ByteProcessor(width, height, B, null); rollingBallBackground(bp, radius, createBackground, lightBackground, useParaboloid, doPresmooth, correctCorners); ip.setHSB(H, S, (byte[])bp.getPixels()); }
/** Create or subtract a background, based on the brightness of an RGB image (keeping * the hue of each pixel unchanged) * @param ip The RGB image. On output, it will become the background-subtracted image or * the background (depending on <code>createBackground</code>). * @param radius Radius of the rolling ball creating the background (actually a * paraboloid of rotation with the same curvature) * @param createBackground Whether to create a background, not to subtract it. * @param lightBackground Whether the image has a light background. * @param doPresmooth Whether the image should be smoothened (3x3 mean) before creating * the background. With smoothing, the background will not necessarily * be below the image data. * @param correctCorners Whether the algorithm should try to detect corner particles to avoid * subtracting them as a background. */ public void rollingBallBrightnessBackground(ColorProcessor ip, double radius, boolean createBackground, boolean lightBackground, boolean useParaboloid, boolean doPresmooth, boolean correctCorners) { int width = ip.getWidth(); int height = ip.getHeight(); byte[] H = new byte[width*height]; byte[] S = new byte[width*height]; byte[] B = new byte[width*height]; ip.getHSB(H, S, B); ByteProcessor bp = new ByteProcessor(width, height, B, null); rollingBallBackground(bp, radius, createBackground, lightBackground, useParaboloid, doPresmooth, correctCorners); ip.setHSB(H, S, (byte[])bp.getPixels()); }
/** Converts a 3-slice (hue, saturation, brightness) 8-bit stack to RGB. */ public void convertHSBToRGB() { if (imp.getStackSize()!=3) throw new IllegalArgumentException("3-slice 8-bit stack required"); ImageStack stack = imp.getStack(); byte[] H = (byte[])stack.getPixels(1); byte[] S = (byte[])stack.getPixels(2); byte[] B = (byte[])stack.getPixels(3); int width = imp.getWidth(); int height = imp.getHeight(); imp.trimProcessor(); ColorProcessor cp = new ColorProcessor(width, height); cp.setHSB(H, S, B); imp.setImage(cp.createImage()); imp.killStack(); if (IJ.isLinux()) imp.setTitle(imp.getTitle()); }
/** Converts a 3-slice (hue, saturation, brightness) 8-bit stack to RGB. */ public void convertHSBToRGB() { if (imp.getStackSize()!=3) throw new IllegalArgumentException("3-slice 8-bit stack required"); ImageStack stack = imp.getStack(); byte[] H = (byte[])stack.getPixels(1); byte[] S = (byte[])stack.getPixels(2); byte[] B = (byte[])stack.getPixels(3); int width = imp.getWidth(); int height = imp.getHeight(); imp.trimProcessor(); ColorProcessor cp = new ColorProcessor(width, height); cp.setHSB(H, S, B); imp.setImage(cp.createImage()); imp.killStack(); if (IJ.isLinux()) imp.setTitle(imp.getTitle()); }