Hi All,
I have a two part question for which I have one example plugin. The first question is about image type. In the plugin I create duplicate of a 32-bit image. I subsequently threshold that duplicate and then convert it to a mask which makes it 8-bit. I then select a pixel in the mask that I know has a value of 255 *in the display*. I then programmatically get the value of the pixel a number of ways using ImageProcessor methods and using one ImagePlus method. Here's the output of from running the plugin (pasted in below). Mask is a Gray32? true Mask bit depth = 8 [13, 294]: Orig= 224.0 Mask with ImageProcessor.getPixel() = 1130364928 Mask with ImageProcessor.getPixelValue() = 224.0 Mask with ImageProcessor.getf() = 224.0 Mask with ImagePlus.getPixel() = 255 The first 2 lines of output are confusing because the Mask image processor thinks it is 32-bit even though it also thinks it is 8-bit. The next line shows the pixel coordinates I chose and the original image value. The next 4 lines show the value of the pixel using different methods - only the last gives me what I *think* should be the correct value. Can someone shed light on (a) why the Mask thinks it is both 32-bit and 8-bit and (b) what is the "right" way to retrieve pixel values using ImageProcessor directly? The second question is about FloodFiller. I believe that I can use a seed pixel derived from one image to flood fill a second image. What I can seem to fathom is what is the effect on the second image? Using the Macro.Functions.floodFill(x,y) as an example, I have tried to flood fill the mask (above) with pixels derived for the Edge image. In the plugin some 6700 pixels qualify as seed pixels, but I can't see what effect the filling has on the mask. When I use the macro tool (the bucket icon on the toolbar) it has an obvious effect. How do I manage the FloodFiller so that I can distinguish unqualified and unfilled blobs from the qualified and filled blobs? Thanks! Ben import ij.*; import ij.process.*; import ij.gui.*; import java.awt.*; import ij.plugin.*; public class Test_GetPixel implements PlugIn { ImagePlus origImp, maskImp, edgeImp; ImageProcessor origIp, maskIp, edgeIp; public void run(String arg) { //load the image and make it "just so" IJ.run("Cell Colony (31K)"); IJ.run("Invert"); IJ.run("32-bit"); ImagePlus origImp = IJ.getImage(); ImageProcessor origIp = origImp.getProcessor(); //create a mask of the image as a 0-1 binary float ImagePlus maskImp = new ImagePlus("Mask", origIp.duplicate()); ImageProcessor maskIp = maskImp.getProcessor(); maskIp.resetMinAndMax(); maskIp.setThreshold(72, 5000000, FloatProcessor.RED_LUT); maskImp.show(); IJ.run("Convert to Mask"); maskImp.updateAndDraw(); int i = 13; int j = 294; int w = maskIp.getWidth(); int h = maskIp.getHeight(); IJ.log("Mask is a Gray32? " + (maskImp.GRAY32 == 2)); IJ.log("Mask bit depth = " + maskImp.getBitDepth()); IJ.log("["+i+", "+j+"]: Orig= " + origIp.getPixelValue(i,j)); IJ.log("Mask with ImageProcessor.getPixel() = " + maskIp.getPixel(i,j)); IJ.log("Mask with ImageProcessor.getPixelValue() = " + maskIp.getPixelValue(i,j)); IJ.log("Mask with ImageProcessor.getf() = " + maskIp.getf(i,j)); IJ.log("Mask with ImagePlus.getPixel() = " + (maskImp.getPixel (i,j))[0]); //create an edge image ImagePlus edgeImp = new ImagePlus("Edge", origIp.duplicate()); ImageProcessor edgeIp = edgeImp.getProcessor(); edgeIp.resetMinAndMax(); int[] gauss = {3, 5, 3, 5, 8, 5, 3, 5, 3}; int[] laplace = {0, -1, 0, -1, 4, -1, 0, -1, 0}; edgeIp.convolve3x3(laplace); edgeIp.convolve3x3(gauss); edgeImp.show(); FloodFiller ff = new FloodFiller(maskIp); int c = 0; for ( i = 0; i < w; i++){ for ( j = 0; j < h; j++){ if ( (edgeIp.getPixelValue(i,j) > 18.0) && (maskImp.getPixel (i,j))[0] == 255) { //IJ.log("Fill= " + i + ", " + j); ff.fill(i,j); maskImp.updateAndDraw(); c++; } IJ.showProgress(i, w); } //j loop }//i loop IJ.log(""); IJ.log("Found " + c + " qualifying seed pixels for flood filling"); } //run } |
Free forum by Nabble | Edit this page |