Re: Disector counting frame
Posted by Teresa W on May 20, 2010; 11:01am
URL: http://imagej.273.s1.nabble.com/Disector-counting-frame-tp3688237p3688238.html
I used this approach to produce an unbiased dissector frame, and it may help those searching under this topic. I recorded the process as a macro and ran it automatically once I had determined the sizes of the different squares. It can be run on individual images or on an image stack.
Squares are defined in IJ by (X, Y, width, height), where XY is the right-hand top vertex. A random number generator and a spreadsheet can be used to calculate random XY co-ordinate start points, and so satisfy the requiremnts of an unbiased dissector.
Set on Record Macro to capture procedures.
From your thresholded binary image, first sample a square around 2x the size of the largest particle you want to count. Save as Sample image.
Set the Scale to global. Create and name a square frame image of the same size as the Sample square. Use New image & choose the required pixel size. Draw a slightly smaller square inside and fill it to give a border of black ~ 5-10 pixels. Save this border square as a binary Frame image.
Within the Sample image, draw a Count square to a known size (e.g. 1 mm2), starting from 0, 0 of the Sample image. Run Analyse Particles, Include On edges, Show Masks. Save the Mask as a binary Mask1 image. Save all Mask image as binary images, or later Image Calculator functions may not work.
Return to Sample image and use the Polygon tool to create an L-shaped ROI the inverse of the Count square, which shares 3 common vertices with the Count square on the inside part of the L. Using this L-ROI run Analyse Particles, Include On edges, Show Masks. Save Mask as Mask2 image. Then run Analyse Particles, exclude On Edges, Show Masks. Save Mask as Mask3. Subtract Mask 3 from Mask 2 to get only the particles intersecting the edges of the L-shaped ROI. Save as Mask 2. Add Mask2 to Mask1, Add Frame. Save as Mask2 and run Analyse Particles, exclude On Edges, Show Masks.
This gives you an image or a stack where the top and right-hand particles touching the Count square are excluded, while those jutting out of the bottom and left-hand have been stitched onto edges and are counted. There can be problems if your particles are too large for the Sample square and are truncated when they hit the border resulting from the Frame.
For stacks, I found that large stacks work best where the image stacks are all saved onto the Desktop, the use of Create New Window is used only when necessary, and intermediate image stacks are saved (hence all the Save steps).
Teresa Wegrzyn
Institute of Food, Nutrition and Human Health
Massey University
Palmerston North New Zealand.