Login  Register

Re: Macro for automatically detecting/setting a scale

Posted by Brandon Hurr on Sep 27, 2018; 11:47pm
URL: http://imagej.273.s1.nabble.com/Macro-for-automatically-detecting-setting-a-scale-tp5021253p5021254.html

David,

Absolutely you can do this. I do this all the time, but I use a color chart
as a size reference. In the past we've used an oblong reference that was
blue so we could pick it out from the white, black, and gray backgrounds we
were using at the time.
What you do is you measure your scale. Say it is 3.14 centimeters long and
1 cm wide.
You then paint it a color that separates it from your background and your
objects of interest (leaves).
Then you run color segmentation to find your object and measure it in terms
of pixels in the image.  I think I use feret's distance to get the longest
dimension of the scale. Then you can use that to compute your scaling
factor.

Rather than set the pixel scale for each image in ImageJ, I typically apply
this transformation to the data that is output, but I know others prefer
the other way. I do this because you have to make sure you reset the scale
after every loop and it's easy to do the transformation on each object (I
typically do this in R across many variables, but ImageJ can do this
quickly enough too).

Are you starting from nothing?
What do your images look like?

B





On Thu, Sep 27, 2018 at 4:22 PM DavidG <[hidden email]> wrote:

> Hi,
>
> I'm just getting started using ImageJ for some leaf area analysis and have
> a
> question about automatically setting the scale for multiple images.  I
> couldn't find another thread about this specific issue, but I apologize if
> it has been addressed previously.
>
> I need to analyze the areas of leaves in a large batch of images.  The
> images will be taken against a uniform background containing an object of
> known size for scale.  My dilemma comes from the fact that it will not be
> possible for all of the images to be taken from a uniform distance, causing
> the scale to differ slightly from image to image.
>
> Is it possible to create a macro that can detect an object of known size
> within each image and then set the scale accordingly?  Ideally, I would
> like
> to be able to process many images in series. Any help or suggestions are
> appreciated!
>
> I've been really impressed looking through the ImageJ community's posts the
> past few days and I'm excited at all of the possible functions!
>
> Thanks,
> David
>
>
>
>
>
> --
> Sent from: http://imagej.1557.x6.nabble.com/
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html