Discussion:
ImageJ for ecology - vegetation cover
Shane Litherland
2011-09-21 00:11:30 UTC
Permalink
Hi all,

I am fairly new to ImageJ, but have had little trouble learning it
on-the-fly for my purposes. Works fairly well for me, on Ubuntu 10.04
64-bit desktop.

I am working on a process to measure 'Foliage Projective Cover' in
vegetation surveys. For those not familiar with FPC, it is basically a
point-intercept presence/absence method, conventionally done with the
aid of some basic mirror/pinhole apparatus that allows a user (without
craning one's neck) to look skywards over a transect line etc and note
if one can see sky or leaf through the pinhole.

Tally up the yes/no, and get a percentage of how much foliage is in a
canopy. Another way to visualise it; imagine the sun at full noon in
summer, so it is shining straight down, and noting how much of the
ground is shaded.

Where ImageJ comes in, is that I want to analyse a digital image
captured by pointing a camera skywards and taking a photo. Leaving
technicality/limitations aside at moment, it has the potential to
provide much greater detail in a short timeframe than the traditional
method. It just requires some validation that the process is an accurate
alternative to the traditional method. This is what I am working on at
the moment using ImageJ to analyse the pics. If this whole process is
successful, it may warrant publication somewhere.

I've put the camera through its paces, on a test plot, to assess effects
of various camera settings and lighting conditions. I've used ImageJ to
help assess these by using an 8-bit image, applying the threshold tool
to convert image to B&W, then using 'plot profile' to give a figure I
can convert to percentage FPC. Fairly straight forward.

The potential for error largely emerges at the point of applying a
threshold. Various camera settings and types of foliage produce an image
where changes of threshold values cause considerable variation in FPC.
For example, if an image is mostly of large, thick leaves, it has a
histogram skewed greatly towards black and the FPC value is fairly
similar across a range of thresholds through the mid-white range of
scale. If an image is a mix of some big leaves and a scattering of fine
leaves, the histogram will be bimodal, with peaks very close to black
and white and so thresholds through mid-ranges give similar values, but
change considerably as threshold approaches white.

In practical terms, this is a concern because if a particular photo
shows a foliage pattern that results in the leaves being shown as quite
pale/white (e.g. very fine leaves with glare around them and light
shining through them), small changes in threshold towards the white end
may be needed to correctly identify such leaves as 'black' and those
small changes can give FPC values that differ substantially.

The threshold function will, I believe, do the job. It comes down to
determining where to set the value. I could manually inspect each image
and using the 'red' setting in threshold tool, I can easily adjust
threshold until I am satisfied it is capturing enough of the leaves to
give a valid result, and continue with the analysis of the B&W output.
This however, would be time consuming, possibly negating the benefits of
using the technology to do the task.

I have looked at the various threshold settings, and so far, there were
two that matched the images quite well - for images with a histogram
skewed to black, the 'minimum' setting is probably suitable; for images
with a bimodal histogram, the 'Shanbhag' setting seems better.

Which brings me to the point of having to figure out how these settings
calculate their threshold values, and whether I could work on them to
make something to suit me, or whether I could design a macro that, when
batch-processing the images, could apply one or the other depending on
histogram characteristics.

I will have to tackle macros eventually no matter what my approach, to
deal with the volume of images in an effective manner. I've been looking
into the online documentation etc to come up to speed with that, but
having example macros handy for anything that relates to the threshold
tool and plot profile function would speed my learning too.

If anyone has read this far, probably means you're interested, so do get
in touch with ideas/tips/etc. Even collaboration on documenting this
whole process?

Regards,
Shane.
Shane Litherland
2011-09-21 11:20:48 UTC
Permalink
Hi Audrey,

Thanks for replying :-)

I have read more on the stereology options (a site
http://www.stereology.info/ was linked from one of the ImageJ info
pages), and briefly tried out the grid plugin. So far my understanding
is that I would have to manually count what was at each gridpoint or
counting frame, is that correct? Also the stereology tools seem quite
detailed and possibly more geared at 3-dimensional analysis?

Do I just need to study these options further to learn how to have them
automatically count leaf-or-sky, or is my initial thought correct that
the grid/frame tools simply aid manual counting? If the latter, it won't
address my hurdle but it will provide me with another means to verify my
image capture protocols.

The automatic counting I can already achieve with the 'plot profile'
function, my hurdle is making sure this function has an image that
accurately shows the leaves in the canopy in a way that can be counted
as 'yes/no' - and from my rudimentary understanding of digital images, I
figured that would involve having only two options in the image rather
than greyscale or colours, and that is why I started tinkering with
thresholds. In other words, I don't know any better at the moment!

Will continue my homework, but just thought I'd check about the manual
counting questions above before I delved too much more into the
stereography because it looks like it would take some brain-power :-)

Regards and thanks,
Shane.
PS noted you are involved in aquaculture and fisheries... happened to be
my main interests in my university days! Albeit on the opposite side of
the world to you :-)
The stereology tools, in particular the grid macro and grid plugin will give you an overlay for counting or point estimates on an RGB image - no need for thresholding.
Search for stereology in ImageJ or try
http://rsbweb.nih.gov/ij/plugins/grid.html
Audrey J. Geffen
Professor, Fisheries Ecology and Aquaculture Group
Department of Biology | Institutt for biologi
Universitetet i Bergen | University of Bergen
Mailing Address: Postboks 7803, 5020 Bergen, NORWAY
Street Address: Thormøhlensgt. 53 A/B
Tel: +47 55 58 44 00 Fax: +47 55 58 44 50
http://www.uib.no/personer/Audrey.Geffen
Masters programme in aquaculture biology: http://www.uib.no/studyprogramme/MAMN-HAV
-----Original Message-----
IMAGEJ automatic digest system
Sent: Wednesday, September 21, 2011 6:03 AM
Subject: IMAGEJ Digest - 19 Sep 2011 to 20 Sep 2011 (#2011-257)
There are 9 messages totaling 449 lines in this issue.
1. Stack brightness/contrast
2. FFT filter fails on large image (2)
3. mTrackJ data sets (2)
4. In a PlugInFilter, how do I suspend the current tool? (3)
5. ImageJ for ecology - vegetation cover
----------------------------------------------------------------------
Date: Tue, 20 Sep 2011 09:13:51 +0200
Subject: Stack brightness/contrast
Dear all,
before starting to code I'd like to ask if somebody is aware of a ready-to-use
I have a SIFT-aligned stack of similar technical images.
For reasons beyond my influence brightness and contrast vary between
images and I'd like to adjust them to make the images even more similar (e.g.
in the sense of least squares of pixel value differences).
Does anybody know which button to press?
Thanks in advance.
Thomas
--
NEU: FreePhone - 0ct/min Handyspartarif mit Geld-zurück-Garantie!
Jetzt informieren: http://www.gmx.net/de/go/freephone
------------------------------
Date: Tue, 20 Sep 2011 10:33:09 +0100
Subject: FFT filter fails on large image
Dear all,
I'm trying to run a FFT bandpass filter (0-50 pixels) on a very large image
(22848x14336, 16bit, 625MB), but I get the error reproduced below. The image
is a stitch of several 1344x1024 images. Running the filter for each image
works fine. However, if I scale down by a factor of 0.5 it works... Does
anyone have the same problem? I'm using 64bit ImageJ, version 1.45o with
20480 mb available (20gigs basically). The task manager doesn't seem to show
a bump on memory usage (which is high but not full).
My basic interpretation of the error is that ImageJ or Java seem to have an
arbiratrary limit on array sizes and the FFT algorithm creates arrays based
on the image size... Could that be it? If so, would there be a way to
increase such a limit?
Thanks,
Pedro Almada
java.lang.ArrayIndexOutOfBoundsException: -738153312
at ij.process.ShortBlitter.copyBits(ShortBlitter.java:48)
at ij.process.ShortProcessor.copyBits(ShortProcessor.java:433)
at ij.process.ImageProcessor.insert(ImageProcessor.java:1374)
at ij.plugin.filter.FFTFilter.tileMirror(FFTFilter.java:187)
at ij.plugin.filter.FFTFilter.filter(FFTFilter.java:96)
at ij.plugin.filter.FFTFilter.run(FFTFilter.java:58)
at
ij.plugin.filter.PlugInFilterRunner.processOneImage(PlugInFilterRunner.java:2
56)
at ij.plugin.filter.PlugInFilterRunner.<init>(PlugInFilterRunner.java:105)
at ij.IJ.runPlugIn(IJ.java:158)
at ij.Executer.runCommand(Executer.java:127)
at ij.Executer.run(Executer.java:64)
at java.lang.Thread.run(Thread.java:619)
------------------------------
Date: Tue, 20 Sep 2011 13:40:04 +0200
Subject: Re: FFT filter fails on large image
Hi Pedro,
you can use the FFT implementation of ImgLib
(http://pacific.mpi-cbg.de/wiki/index.php/Imglib) which is included in Fiji.
In combination with the CellContainer it can deal with much larger images on
the cost of slightly slower computation speed.
At the moment, this still requires implementation, but there is a plan to
make some functionality (like FFTs) available as plugins, too. You find an
ImgLib tutorial here
(http://pacific.mpi-cbg.de/wiki/index.php/Into_ImgLib_-
_Generic_Image_Processing_in_Java)
if you want to give it a shot, it includes example files on how to use FFT,
too.
Nice greetings,
Stephan
--------------------------------------------------
Sent: Tuesday, September 20, 2011 11:33 AM
Subject: FFT filter fails on large image
Dear all,
I'm trying to run a FFT bandpass filter (0-50 pixels) on a very large
image
(22848x14336, 16bit, 625MB), but I get the error reproduced below. The
image
is a stitch of several 1344x1024 images. Running the filter for each image
works fine. However, if I scale down by a factor of 0.5 it works... Does
anyone have the same problem? I'm using 64bit ImageJ, version 1.45o with
20480 mb available (20gigs basically). The task manager doesn't seem to
show
a bump on memory usage (which is high but not full).
My basic interpretation of the error is that ImageJ or Java seem to have
an
arbiratrary limit on array sizes and the FFT algorithm creates arrays
based
on the image size... Could that be it? If so, would there be a way to
increase such a limit?
Thanks,
Pedro Almada
java.lang.ArrayIndexOutOfBoundsException: -738153312
at ij.process.ShortBlitter.copyBits(ShortBlitter.java:48)
at ij.process.ShortProcessor.copyBits(ShortProcessor.java:433)
at ij.process.ImageProcessor.insert(ImageProcessor.java:1374)
at ij.plugin.filter.FFTFilter.tileMirror(FFTFilter.java:187)
at ij.plugin.filter.FFTFilter.filter(FFTFilter.java:96)
at ij.plugin.filter.FFTFilter.run(FFTFilter.java:58)
at
ij.plugin.filter.PlugInFilterRunner.processOneImage(PlugInFilterRunner.java:2
56)
at ij.plugin.filter.PlugInFilterRunner.<init>(PlugInFilterRunner.java:105)
at ij.IJ.runPlugIn(IJ.java:158)
at ij.Executer.runCommand(Executer.java:127)
at ij.Executer.run(Executer.java:64)
at java.lang.Thread.run(Thread.java:619)
------------------------------
Date: Mon, 19 Sep 2011 18:01:00 +0100
Subject: mTrackJ data sets
We are generating large data sets from mTrackJ in which large numbers of
cells are being tracked from each image stack. We are trying to get them into
excel or Prism or other software for further analysis. The problem is that the
data is imported as a single column of objects, so if you want to set up a series
of columns with data for each cell in a set of columns, you have to manually
cut and paste each cell's dataset into a new set of columns. Is there a way to
automate this process or a way to import so that the cell/object sets get
sorted in the first place? Thanks- Dave
Dr. David Knecht
Department of Molecular and Cell Biology
Co-head Flow Cytometry and Confocal Microscopy Facility
U-3125
91 N. Eagleville Rd.
University of Connecticut
Storrs, CT 06269
860-486-2200
860-486-4331 (fax)
------------------------------
Date: Tue, 20 Sep 2011 15:29:18 +0200
Subject: Re: mTrackJ data sets
Hi David,
With the ImageJ macro language you can open a text file as a string, break
it into separate arrays (for exemple detecting the beginning of each object
trajectory), and then build a data table with a column for each trajectory.
If you send me an exemple file made by mTrackJ I could give it a shot (not
right now though).
Christophe
We are generating large data sets from mTrackJ in which large numbers of
cells are being tracked from each image stack. We are trying to get them
into excel or Prism or other software for further analysis. The problem is
that the data is imported as a single column of objects, so if you want to
set up a series of columns with data for each cell in a set of columns, you
have to manually cut and paste each cell's dataset into a new set of
columns. Is there a way to automate this process or a way to import so that
the cell/object sets get sorted in the first place? Thanks- Dave
Dr. David Knecht
Department of Molecular and Cell Biology
Co-head Flow Cytometry and Confocal Microscopy Facility
U-3125
91 N. Eagleville Rd.
University of Connecticut
Storrs, CT 06269
860-486-2200
860-486-4331 (fax)
------------------------------
Date: Tue, 20 Sep 2011 16:27:04 +0000
Subject: In a PlugInFilter, how do I suspend the current tool?
I am writing a plugin (in Java) in which I click on places in an image and the
plugin makes changes to the image. It is modeled after the Mouse Listener
programming example on the plugins page.
Unfortunately, when I click on an image, not only does my plugin get invoked,
but whatever tool happens to be selected on the toolbar also reacts. Thus, I
find myself unexpectedly zooming or selecting/deselecting the ROI while
using my plugin. In some cases, the current tool seems to block my mouse
listener. For example, if there is a rectangular selection showing, and any of
the selection tools is set, after I start my plugin, the first mouse click deselects
the ROI but does not get to my plugin. Subsequent mouse clicks also do not
get seen by my plugin. However, if no ROI has been drawn and a selection
tool is set, my plugin works correctly.
So the question is, can my plugin suspend toolbar tools while it is running?
The closest thing I've found is in the Toolbar class. There are getToolID and
setTool functions which would allow me to remember the tool selected when
my plugin starts and restore it when my plugin exits. Perhaps one of the valid
values for setTool would correspond to "None"? If so, it is not listed in the
documentation. There is also a restorePreviousTool, but other than its name,
it is undocumented. It's not clear how or when the previous tool is set.
------------------------------
Date: Wed, 21 Sep 2011 00:04:40 +0200
Subject: Re: In a PlugInFilter, how do I suspend the current tool?
Hi Bob,
my procedure to disable tools conflicting with a MouseListener and/or
if (Toolbar.getToolId() > Toolbar.CROSSHAIR)
IJ.setTool(Toolbar.RECTANGLE); //deselect tools that
would interfere
ic.addMouseListener(this);
ic.addMouseMotionListener(this);
//ic is the ImageCanvas
imp.setRoi((Roi)null); // intercept roi tools
Michael
___________________________________________________________
_____
I am writing a plugin (in Java) in which I click on places in an
image and the plugin makes changes to the image. It is modeled
after the Mouse Listener programming example on the plugins page.
Unfortunately, when I click on an image, not only does my plugin
get invoked, but whatever tool happens to be selected on the
toolbar also reacts. Thus, I find myself unexpectedly zooming or
selecting/deselecting the ROI while using my plugin. In some cases,
the current tool seems to block my mouse listener. For example, if
there is a rectangular selection showing, and any of the selection
tools is set, after I start my plugin, the first mouse click
deselects the ROI but does not get to my plugin. Subsequent mouse
clicks also do not get seen by my plugin. However, if no ROI has
been drawn and a selection tool is set, my plugin works correctly.
So the question is, can my plugin suspend toolbar tools while it is
running?
The closest thing I've found is in the Toolbar class. There are
getToolID and setTool functions which would allow me to remember
the tool selected when my plugin starts and restore it when my
plugin exits. Perhaps one of the valid values for setTool would
correspond to "None"? If so, it is not listed in the documentation.
There is also a restorePreviousTool, but other than its name, it is
undocumented. It's not clear how or when the previous tool is set.
------------------------------
Date: Tue, 20 Sep 2011 18:07:17 -0500
Subject: Re: In a PlugInFilter, how do I suspend the current tool?
Thanks! I'll give that a shot tomorrow. How do I undo it? I know to save
the tool ID it was on and then reset it when my plugin exits. But how do I
undo the setRoi((Roi)null)? At the end of my plugin, I do a
removeMouseListener and removeMouseMotionListener. Is that enough?
Thank you,
Bob
-----Original Message-----
From: Michael Schmid
Sent: Tuesday, September 20, 2011 5:04 PM
Subject: Re: In a PlugInFilter, how do I suspend the current tool?
Hi Bob,
my procedure to disable tools conflicting with a MouseListener and/or
if (Toolbar.getToolId() > Toolbar.CROSSHAIR)
IJ.setTool(Toolbar.RECTANGLE); //deselect tools that
would interfere
ic.addMouseListener(this);
ic.addMouseMotionListener(this);
//ic is the ImageCanvas
imp.setRoi((Roi)null); // intercept roi tools
Michael
___________________________________________________________
_____
I am writing a plugin (in Java) in which I click on places in an image
and the plugin makes changes to the image. It is modeled after the Mouse
Listener programming example on the plugins page.
Unfortunately, when I click on an image, not only does my plugin get
invoked, but whatever tool happens to be selected on the toolbar also
reacts. Thus, I find myself unexpectedly zooming or selecting/deselecting
the ROI while using my plugin. In some cases, the current tool seems to
block my mouse listener. For example, if there is a rectangular selection
showing, and any of the selection tools is set, after I start my plugin,
the first mouse click deselects the ROI but does not get to my plugin.
Subsequent mouse clicks also do not get seen by my plugin. However, if no
ROI has been drawn and a selection tool is set, my plugin works
correctly.
So the question is, can my plugin suspend toolbar tools while it is
running?
The closest thing I've found is in the Toolbar class. There are getToolID
and setTool functions which would allow me to remember the tool selected
when my plugin starts and restore it when my plugin exits. Perhaps one of
the valid values for setTool would correspond to "None"? If so, it is not
listed in the documentation. There is also a restorePreviousTool, but
other than its name, it is undocumented. It's not clear how or when the
previous tool is set.
------------------------------
Date: Wed, 21 Sep 2011 10:11:30 +1000
Subject: ImageJ for ecology - vegetation cover
Hi all,
I am fairly new to ImageJ, but have had little trouble learning it
on-the-fly for my purposes. Works fairly well for me, on Ubuntu 10.04
64-bit desktop.
I am working on a process to measure 'Foliage Projective Cover' in
vegetation surveys. For those not familiar with FPC, it is basically a
point-intercept presence/absence method, conventionally done with the
aid of some basic mirror/pinhole apparatus that allows a user (without
craning one's neck) to look skywards over a transect line etc and note
if one can see sky or leaf through the pinhole.
Tally up the yes/no, and get a percentage of how much foliage is in a
canopy. Another way to visualise it; imagine the sun at full noon in
summer, so it is shining straight down, and noting how much of the
ground is shaded.
Where ImageJ comes in, is that I want to analyse a digital image
captured by pointing a camera skywards and taking a photo. Leaving
technicality/limitations aside at moment, it has the potential to
provide much greater detail in a short timeframe than the traditional
method. It just requires some validation that the process is an accurate
alternative to the traditional method. This is what I am working on at
the moment using ImageJ to analyse the pics. If this whole process is
successful, it may warrant publication somewhere.
I've put the camera through its paces, on a test plot, to assess effects
of various camera settings and lighting conditions. I've used ImageJ to
help assess these by using an 8-bit image, applying the threshold tool
to convert image to B&W, then using 'plot profile' to give a figure I
can convert to percentage FPC. Fairly straight forward.
The potential for error largely emerges at the point of applying a
threshold. Various camera settings and types of foliage produce an image
where changes of threshold values cause considerable variation in FPC.
For example, if an image is mostly of large, thick leaves, it has a
histogram skewed greatly towards black and the FPC value is fairly
similar across a range of thresholds through the mid-white range of
scale. If an image is a mix of some big leaves and a scattering of fine
leaves, the histogram will be bimodal, with peaks very close to black
and white and so thresholds through mid-ranges give similar values, but
change considerably as threshold approaches white.
In practical terms, this is a concern because if a particular photo
shows a foliage pattern that results in the leaves being shown as quite
pale/white (e.g. very fine leaves with glare around them and light
shining through them), small changes in threshold towards the white end
may be needed to correctly identify such leaves as 'black' and those
small changes can give FPC values that differ substantially.
The threshold function will, I believe, do the job. It comes down to
determining where to set the value. I could manually inspect each image
and using the 'red' setting in threshold tool, I can easily adjust
threshold until I am satisfied it is capturing enough of the leaves to
give a valid result, and continue with the analysis of the B&W output.
This however, would be time consuming, possibly negating the benefits of
using the technology to do the task.
I have looked at the various threshold settings, and so far, there were
two that matched the images quite well - for images with a histogram
skewed to black, the 'minimum' setting is probably suitable; for images
with a bimodal histogram, the 'Shanbhag' setting seems better.
Which brings me to the point of having to figure out how these settings
calculate their threshold values, and whether I could work on them to
make something to suit me, or whether I could design a macro that, when
batch-processing the images, could apply one or the other depending on
histogram characteristics.
I will have to tackle macros eventually no matter what my approach, to
deal with the volume of images in an effective manner. I've been looking
into the online documentation etc to come up to speed with that, but
having example macros handy for anything that relates to the threshold
tool and plot profile function would speed my learning too.
If anyone has read this far, probably means you're interested, so do get
in touch with ideas/tips/etc. Even collaboration on documenting this
whole process?
Regards,
Shane.
------------------------------
End of IMAGEJ Digest - 19 Sep 2011 to 20 Sep 2011 (#2011-257)
***********************************************************
**
Shane Litherland
2011-09-23 07:37:12 UTC
Permalink
Hi all,

I have found some primary literature on this topic which really nails
the subject! There have been studies published on algorithms used to
define vegetation from sky (mostly based on analysing the blue component
of RGB images and working on edges); there is even a freely available
program for analysing side-images of pasture based on these algorithms.
Of course, they're in Windows though ;-) yikes.

There are also some MATLAB codes, downloadable, from this site:
http://www.mathworks.com/matlabcentral/fileexchange/24314

I am endeavouring to contact the relevant authors, with a view that I/we
may be able to work with what they already have, and get it into an
open-source/linux version. But that may not even be necessary...
because...

I've also found webpages with info about ImageJ working with/in MATLAB,
and 'open' alternatives to matlab that might still use matlab scripts
and talk well to ImageJ, such as Octave, Scilab, and other
maths/algebraic stuff, all handy in my ubuntu repository :-)

Interesting (learning)times ahead :-)

Looks like most of the hard work has already been done for me though!
...

Anyone interested in seeing the original literature, which I am still
studying up on, try:

Automated Analysis of in Situ Canopy Images for the Estimation of Forest
Canopy Cover
Lauri Korhonen; Jaakko Heikkinen
Forest Science; Aug 2009

Automatic thresholding for hemispherical
canopy-photographs based on edge detection
M. Nobis, U. Hunziker / Agricultural and Forest Meteorology 128 (2005)

and Michael Nobis' Sidelook software:
http://www.appleco.ch/

Loading...