Help in measuring area with the 'wand'

measure
imagej
segmentation

#1

plot6_spcm2_En%20es1.tif
I have attempted to use the wand to measure area with varied results and unknown units. I have followed the instructions and measured the same object several times and receive different, sometimes extremely, numerical results every time. The resulting measurements have an E-4 or E-5 at the end. The problem is that the software does not visually outline the object and so I don’t know exactly what is being measured and I don’t know what units of measure are used. Am I doing something wrong? Is there a better method of measuring area? Thanks


#2

Good day,

please post a typical image in TIF- or PNG-format that you use and tell us exactly where you click (coordinates) with the Wand-tool and what settings of the Wand-tool you use.

Without this exact information we are unable to help.

Regards

Herbie


#3

plot6_spcm2_En%20es1.tif


#4

You didn’t answer my questions:

tell us exactly where you click (coordinates) with the Wand-tool and what settings of the Wand-tool you use.

Generally, I don’t think you will get good results with the Wand-tool without pre-processing the images.*

Regards

Herbie


* After experimenting a bit, I wasn’t able to extract the animal from the background. The grid-structure is much too disturbing. It will be rather difficult to measure the animal size, no matter what approach is followed. In any case, the Wand-tool is unsuited.


#5

Herbie
I intended to answer your questions but wanted to make sure the photo uploaded successfully. When I attempted to use the wand to calculate area I used it in several locations with the assumption that the location should not matter as long as the cursor was to the left of the object, but received different resulting calculations every time. The only wand tool setting that I could find was a selection for area. I have read your other comments on extracting the salamander from the grid background and that was a consideration that I wondered about. This is my first effort in using imageJ so I am learning as I explore the software.
Do you have any suggestions on other methods to calculate area of these samples? Thanks for your help.


#6

Presently, the only way I see to extract the animal from the background in such images is very costly and I’m not willing to write code that performs what I think is necessary.

I tried to suppress the grid-lines by orientation filtering, but their high contrast and their width doesn’t allow for satisfying results.

If you have colour images and if the animal colour is sufficiently different from the (dark gray / black) colour of the grid-lines, then there may be a simpler solution. The Wand-tool is definitely unsuited for this purpose and you should understand why this is so.

Best would be to take the photographs again and have the animals on unstructured ground.

Regards

Herbie


#7

Here is the best outline of the animal from your sample image that I could obtain:

Of course the segmentation is due to the filtering of the grid-lines. The total area, i.e. the sum of the 12 segment areas, is about 6.9 cm^2 according to the scale-setting.

Caveats:
If the grid-lines aren’t horizontal/vertical, the approach becomes quite involved.
Due to the segmentation, i.e. to the width of the grid-lines, and to thresholding effects, the area measurements aren’t perfectly accurate.

Regards

Herbie


#8

Hello David -

I have a half-baked idea for you, see below:

First, as Herbie suggested, the simplest thing to do (if you can)
would be to re-take the photographs on a plain, light background.
Then (assuming that the salamander picture you posted is
typical of those you will be working with) you could threshold the
image, and let Fiji / ImageJ tell you the area of the thresholded
object.

But, if you’re stuck with the grid lines, you might be able to locate
the grid lines and color them white. (I am not aware of any
ImageJ tools that would do this for you.)

I see that the grid lines are not exactly horizontal and vetical,
nor are they exactly straight. (But they are pretty close.) You
might be able to fit a set of slightly warped grid lines to your
image, and then set those pixels to white. You could then
threshold the image, and measure the area of the thresholded
object (e.g., count the pixels darker than the threshold).

This would slightly underestimate the area because you would
have drawn white grid lines through the salamander.

A refinement could be to “fill” the image after setting the grid
lines to white and thresholding it, that is, fill back in the white
cuts through the salamander, and then measure the area of
the thresholded object.

The hard part of this scheme would be fitting the grid lines.
I think that this would be “straighforward,” but would represent
a relatively significant analysis / programming task. But if the
grid lines are relatively similar from image to image (nearly
the same number, approximately the same distance apart),
I think it should be doable (not that I know how to do it …).

Thanks, mm


#9

But, if you’re stuck with the grid lines, you might be able to locate
the grid lines and color them white. (I am not aware of any
ImageJ tools that would do this for you.)

I had this in mind when I wrote:

[…] the only way I see to extract the animal from the background in such images is very costly

!

This would slightly underestimate the area because you would
have drawn white grid lines through the salamander.

Did you have a look at the result I’ve posted above?

However, my result was obtained by using a rather short ImageJ-macro …

Regards

Herbie


#10

Hello Herbie -

Indeed. Doable, in my estimation, but costly would be a good
term for it.

Yes, I saw your result, including the “ghost” lines going through
the outline. I speculated in my own mind that you might have
filtered out the lines in Fourier space, but I don’t really know
how to do something like that in practice. Quite nice, in fact.

Thanks, mm


#11

Thanks for your reply!

I speculated in my own mind that you might have
filtered out the lines in Fourier space, but I don’t really know
how to do something like that in practice.

Indeed!
The ImageJ built-in method
____“Process >> FFT >> Bandpass Filter… (with option stripes suppression)”
does not lead to convincing results.

In practice, as you write, one has to construct a good filter and this is again costly but its application is cheap.

Best

Herbie


#12

The grid lines are not necessary, simply there as a visual size reference, so I can photograph on a white background. On a white background could I use the wand for accurate results for calculating area or would I need to use another method? Thanks for all of your effort on this.


#13

David, please try to understand how the Wand-tool works!

Study the ImageJ User Guide and especially Section 19.7.

You should then understand why your original try did not work!

If you get images without the grid, things should work, but please do you and perhaps us a favour by understanding the principal limits of this method.

Regards

Herbie


#14

why are you so in love with the wand tool?:wink:


#15

As a beginning user that was the first tool that, based on the simple instructions, would quickly measure area. Do you know of an alternative method?


#16

Here is a macro that selects your salamander pretty well:

#@ int gridThickness
setBatchMode(true);
setAutoThreshold("Default");
run("Create Mask");
setOption("BlackBackground", false);
for (t=0; t<gridThickness; t++) { run("Erode"); }
for (t=0; t<gridThickness; t++) { run("Dilate"); }
run("Create Selection");
close();
resetThreshold();
run("Restore Selection");

And the result with a grid thickness of 3:

It works by creating a mask of the auto-thresholded area, then eroding the mask X times to destroy the grid, then dilating it back to where it was (approximately). It’s not perfect, but it’s reasonably close.

For an explanation of how I built up this macro, see:


#17

Wow! nice job. That is exactly what I was looking for. I will look into duplicating this on my own but since I am new to this software I’m sure I will have questions. Thank you very much.


#18

Curtis,

this is an interesting alternative!

For the task in question one needs to think about the uncertainty of the final area measurement. I’ve estimated it being about ±10% mainly according to the fact that a 3D-structure is imaged, i.e. projected onto the camera sensor.

With grid-removal the area is slightly under-estimated, with grid-erosion it is slightly over-estimated. This is especially apparent at the legs of the animal.

My estimation of the projected animal area is 7.3±0.4cm^2.
With your grid-erosion and “Intermodes”-threshold I get 7.6cm^2.
With grid-removal, “Default”-threshold and “Exclude Holes” I get 7.0cm^2.

I think the OP has to deal with principal (3D > 2D) and method-dependent deviations from the true area.

Best

Herbie


#19

David,

please have a look at my above considerations.

Regards

Herbie


#20

Herbie,
How did you determine that either method was an over or under estimation of the area and not closer to the actual area? Did you use yet another method to calculate the area or simply calculate a mean of the two resulting areas of the two methods?
I will consider both methods and try to evaluate the best for my needs and ease of use. Thanks for all of your thoughts on this.

David