Dear All,
I have a question about whether I can perform image standardization in ImageJ. I have a series of digital photographs (of an insect), and want to score some morphological traits. As a first step, I want to use the graycard I have included in each photo to standardize all images, relative to a single 'reference' image (i.e. just one of the photos, the choice of which one is to be used as the reference is arbitrary, because I am only interested in relative measures of phenotypic variation, not absolute values). The spirit of what I want to do is something like this: (1) select the graycard in the reference image, then select the graycard in the target image; (2) use ImageJ to calculate what adjustments need to be made to make the ROI in the target image match the ROI in the reference image; (3) apply the calculated adjustment to the entire target image; (4) repeat the procedure for all remaining target images I hope to end up with all of the images having been standardized, so that measurements of phenotypic characters that make us of setting thresholds to objectively delineate edges are not impacted by slight differences in illumination of the original digital photographs. Is this possible with ImageJ, and if not, can you direct me towards software that will perform this sort of task? Thanks for your help. cheers, Ryan email: [hidden email] |
Certainly it's possible. Since you only have a few images, doing it
by hand won't be that onerous. I assume your card's histogram is just going to be scaled and offset, not distorted. If it is, then you have to do something more sophisticated (search on 'histogram equalization'...it's not hard, it's just not as simple). First, open all your images. In each image, draw an ROI on each reference card, and take the histogram of it (Analyze->Histogram). Find the upper and lower limits (or any two distinctive features) of the histogram for each image and note them down (note that the interface tells you exactly where your mouse is, so just point to the ends). Then choose the reference, and figure out what offset and scaling factor you need to apply to make the lower and upper ends of the histogram line up. Then go through and scale the image (Process->Maths->Multiply) and add the offset (Process->Maths->Add). The images will all be standardized. I would use the narrowest histogram as the reference image. When you expand the greyscale range, you end up with gaps in the histogram which can be a pain if you're trying to compare greyscales ("these two are in bins separated by one, but the neighboring bins are both zero...is it an artifact?"). You lose precision by contracting, but it doesn't put in holes and makes interpretation very simple. Though if your measurements are entirely insensitive to having holes in the histogram, then this obviously doesn't apply. Hope this helps. On 4/23/07, Ryan Garrick <[hidden email]> wrote: > Dear All, > > I have a question about whether I can perform image standardization in > ImageJ. I have a series of digital photographs (of an insect), and want to > score some morphological traits. As a first step, I want to use the > graycard I have included in each photo to standardize all images, relative > to a single 'reference' image (i.e. just one of the photos, the choice of > which one is to be used as the reference is arbitrary, because I am only > interested in relative measures of phenotypic variation, not absolute > values). > > The spirit of what I want to do is something like this: > (1) select the graycard in the reference image, then select the graycard > in the target image; > (2) use ImageJ to calculate what adjustments need to be made to make the > ROI in the target image match the ROI in the reference image; > (3) apply the calculated adjustment to the entire target image; > (4) repeat the procedure for all remaining target images > > I hope to end up with all of the images having been standardized, so that > measurements of phenotypic characters that make us of setting thresholds > to objectively delineate edges are not impacted by slight differences in > illumination of the original digital photographs. > > Is this possible with ImageJ, and if not, can you direct me towards > software that will perform this sort of task? > > Thanks for your help. > > cheers, > Ryan > > email: [hidden email] > -- Frederick Ross Graduate Fellow, (|Siggia> + |McKinney>)/sqrt(2) Lab The Rockefeller University Je ne suis pas Fred Cross! |
Hi Frederick,
This explanation has been very helpful; I do the same when standardising grey levels in backscattered electron micrographs. A macro to do it goes like this: macro "Convert Kontron IMG File [b]" { Dialog.create("Enter Values"); Dialog.addNumber("Br-PMMA", br); Dialog.addNumber("I-PMMA", io); Dialog.addNumber("Width", width); Dialog.addNumber("Height", height); Dialog.show(); br = Dialog.getNumber(); io = Dialog.getNumber(); width = Dialog.getNumber(); height = Dialog.getNumber(); setBatchMode(true); run("Raw...", "image=8-bit width="+width+" height="+height+" offset=128 number=1 gap=0"); name = getTitle(); name = split(name, "."); rename(name[0]+".tif"); run("Subtract...", "value="+br); run("Multiply...", "value="+255/(io-br)); path = ""+getDirectory("image")+getTitle+""; saveAs("Tiff", path); close(); } Mike Frederick Ross wrote: > Certainly it's possible. Since you only have a few images, doing it > by hand won't be that onerous. I assume your card's histogram is just > going to be scaled and offset, not distorted. If it is, then you have > to do something more sophisticated (search on 'histogram > equalization'...it's not hard, it's just not as simple). > > First, open all your images. In each image, draw an ROI on each > reference card, and take the histogram of it (Analyze->Histogram). > Find the upper and lower limits (or any two distinctive features) of > the histogram for each image and note them down (note that the > interface tells you exactly where your mouse is, so just point to the > ends). > > Then choose the reference, and figure out what offset and scaling > factor you need to apply to make the lower and upper ends of the > histogram line up. Then go through and scale the image > (Process->Maths->Multiply) and add the offset (Process->Maths->Add). > The images will all be standardized. > > I would use the narrowest histogram as the reference image. When you > expand the greyscale range, you end up with gaps in the histogram > which can be a pain if you're trying to compare greyscales ("these two > are in bins separated by one, but the neighboring bins are both > zero...is it an artifact?"). You lose precision by contracting, but > it doesn't put in holes and makes interpretation very simple. Though > if your measurements are entirely insensitive to having holes in the > histogram, then this obviously doesn't apply. > > Hope this helps. > > On 4/23/07, Ryan Garrick <[hidden email]> wrote: >> Dear All, >> >> I have a question about whether I can perform image standardization in >> ImageJ. I have a series of digital photographs (of an insect), and >> want to >> score some morphological traits. As a first step, I want to use the >> graycard I have included in each photo to standardize all images, >> relative >> to a single 'reference' image (i.e. just one of the photos, the >> choice of >> which one is to be used as the reference is arbitrary, because I am only >> interested in relative measures of phenotypic variation, not absolute >> values). >> >> The spirit of what I want to do is something like this: >> (1) select the graycard in the reference image, then select the graycard >> in the target image; >> (2) use ImageJ to calculate what adjustments need to be made to make the >> ROI in the target image match the ROI in the reference image; >> (3) apply the calculated adjustment to the entire target image; >> (4) repeat the procedure for all remaining target images >> >> I hope to end up with all of the images having been standardized, so >> that >> measurements of phenotypic characters that make us of setting thresholds >> to objectively delineate edges are not impacted by slight differences in >> illumination of the original digital photographs. >> >> Is this possible with ImageJ, and if not, can you direct me towards >> software that will perform this sort of task? >> >> Thanks for your help. >> >> cheers, >> Ryan >> >> email: [hidden email] >> > > -- Michael Doube BPhil BVSc MRCVS PhD Student Dental Institute Queen Mary, University of London New Rd London E1 1BB United Kingdom Phone +44 (0)20 7377 7000 ext 2681 |
Frederick Ross wrote:
> by hand won't be that onerous. I assume your card's histogram is just > going to be scaled and offset, not distorted. If it is, then you have > to do something more sophisticated (search on 'histogram > equalization'...it's not hard, it's just not as simple). I think that you are describing more histogram stretching rather than equalisation. Shouldn't one sample all the greys in between too and then fit a function that is applied to the image? Assuming that the sensor is linear may not be a very valid assumption. Cheers. G. |
In reply to this post by Ryan Garrick
Thanks for your help with this everyone.
Frederick, it looks like the procedure you suggested has worked quite well. I haven't yet played around with equalization (or stretching, as mentioned by Gabriel) that much, but might need to because although the graycard in my reference image has a histogram of gray values with an approx. normal distribution, the graycards in some of target images give a histogram with a slightly longer upper tail (c.f. a normal distribution). If I use the min. and max. gray values alone to determine scaling and offset, this tail is likely to have some impact on standardization. Perhaps it would be reasonable to use the min. and modal gray value of the histograms, the rationale being that it is more important end up with comparable frequency distributions of gray values rather than matching range limits? cheers, Ryan |
On Wednesday 25 April 2007 02:59:09 Ryan Garrick wrote:
> I haven't yet played around with equalization (or stretching, as > mentioned by Gabriel) that much, but might need to because although the > graycard in my reference image has a histogram of gray values with an > approx. normal distribution, the graycards in some of target images give > a histogram with a slightly longer upper tail (c.f. a normal > distribution). Is your test card made of a number of squares? If so, then wouldn't you expect to get a histogram with equally high (but narrow) peaks for the greyscale values of each tablet samples? Can you post an image of your imaged test card? Cheers, G. |
In reply to this post by Ryan Garrick
As Gabriel said, please post a picture of your card.
On 4/24/07, Ryan Garrick <[hidden email]> wrote: > Frederick, it looks like the procedure you suggested has worked quite > well. I haven't yet played around with equalization (or stretching, as > mentioned by Gabriel) that much, but might need to because although the > graycard in my reference image has a histogram of gray values with an > approx. normal distribution, the graycards in some of target images give > a histogram with a slightly longer upper tail (c.f. a normal > distribution). If I use the min. and max. gray values alone to determine > scaling and offset, this tail is likely to have some impact on > standardization. Perhaps it would be reasonable to use the min. and modal > gray value of the histograms, the rationale being that it is more > important end up with comparable frequency distributions of gray values > rather than matching range limits? If you get distortions of the original Gaussian, you need to NOT use the procedure I recommended, as it will introduce systematic errors into your numbers. It means that your sensor is not linear (as Gabriel had mentioned before). The best thing is to keep your sensor in a range where it's linear, but I realize that's not always possible. This being so, life is rather harder. Essentially, you've got to fit a function to the histogram for each of two images, then make the coordinate transformation that takes one to another. For this reason you'll want fairly manageable functions. You might try G(x^\alpha) where G is the Gaussian, and alpha is some power close to 1 (so you're fitting three parameters: the mean, standard deviation, and alpha). If your sensor isn't too far from linear, you may be able to get satisfactory fits this way, and the transformation is fairly straightforwards. I personally think the easiest way is to call Octave from a plugin (JAPOS at http://jopas.sourceforge.net/ lets you do this reasonably well), and then run some curve fitting algorithm someone's already written there. Otherwise, normally for a Gaussian you are better off measuring the mean and standard deviation. These will be more robust than min and max. -- Frederick Ross Graduate Fellow, (|Siggia> + |McKinney>)/sqrt(2) Lab The Rockefeller University Je ne suis pas Fred Cross! |
Free forum by Nabble | Edit this page |