Re: Find bounding box coordinates for "target" in binary mask image

Posted by Jonathan Jackson-2 on
URL: http://imagej.273.s1.nabble.com/Find-bounding-box-coordinates-for-target-in-binary-mask-image-tp3703318p3703319.html

Josh,

If your image is not a binary mask already, use something like:

setThreshold(140, 255);
run("Threshold", "thresholded remaining black");

to convert to a mask.
then the ConvertMaskToCompositeROI macro can create a single ROI outlining
all the (BLACK) particles and add it to the ROI manager. Analyze->Measure is
able to calculate a bounding box on the composite ROI

If this isn't what you wanted, there's also the MaskToSelectionMacros
http://rsb.info.nih.gov/ij/macros/MaskToSelectionMacros.txt

Jon


On Thu, 23 Mar 2006 13:31:22 -0500, Josh Doe <[hidden email]> wrote:

>Thanks Wayne, that works perfectly. I'm greedy though, and want to
>extrapolate this to batch process a couple hundred images. I've thought of a
>few ways to do this:
>
>1) Is there any sort of a "select by color" tool? If so, I could simply
>select any white portions, and then Analyze->Measure. In this case, is there
>some way to pull off the values using a macro or something, so that I can
>batch this?
>
>2) I found that "Analyze Particles" takes care of the first part of the
>problem from (1). I'd still need some way to pull off the measured values.
>Since I have some non-contiguous regions, I get multiple "particles". I
>could just then do some math to find the min and max dimensions from all
>measured particles, to come up with one bounding box that encloses all of them.
>
>3) Write a program. I did a quick m-file for Matlab that does the job, but
>takes a VERY long time, even for just one image. Besides, I don't like to
>rely on non-free software. :)
>
>Thanks for any suggestions.
>
>-jmd
>
>On Thu, 23 Mar 2006 09:44:07 -0500, Wayne Rasband <[hidden email]> wrote:
>
>>> Hi, I have some binary mask images, and I need to get the
>>> coordinates and size of a box surrounding the part of
>>> interest. Basically the images are all black, except for a
>>> clump of white pixels somewhere in the image, which I call
>>> the "target".
>>>
>>> So what I could do is open each image in ImageJ, move the
>>> cursor to the left most pixel of the "target", then the
>>> right side, top side, and bottom side, writing down the
>>> pixel location for each of these. Then I can find the center
>>> of the target, and the tolerances for the bounding box, side
>>> to side and top to bottom.
>>>
>>> However, this is very tedious, and I have many such images.
>>> Is there some automated way of getting these coordinates,
>>> either using ImageJ or something else? Thanks for any
>>> suggestions.
>>
>>     1. Check "Bounding Rectangle" in Analyze>Set Measurements
>>     2. Click inside the "target" with the wand tool
>>     3. Press 'm' (Analyze>Measure)
>>
>>-wayne
>========================================================================