Re: Creating a composite image, avoid fill data values [message #65134] |
Fri, 13 February 2009 09:26 |
Spon
Messages: 178 Registered: September 2007
|
Senior Member |
|
|
On Feb 13, 4:30 pm, Matt <mmsmith1...@gmail.com> wrote:
> Hi - I need to create a composite image showing the mean of all images
> while avoiding the fill value of 0. I have 5 images that are 600 by
> 800. In these images there are fill values interspersed among valid
> values (3-255). I'd like to create a new image showing the mean pixel
> values across all images, but I need to ignore pixels with value of 0
> from the calculations. Any suggestions on how to get this done?
> Thanks.
Hi Matt,
here's how I would go about it:
1) Create a stack of the images (e.g. Stack = [ [[img1]],
[[img2]], ...), and set all your zeroes to 1 (with the > operator).
Then multiply up stack contents in 3rd dimension with PRODUCT.
2) Now all you need to know is what denominator to divide each cell by
to get your average, and divide your two arrays to get the average in
each pixel.
GoodInd = Where(Stack GT 1)
Mask = Intarr(Size(Stack,/Dim))
Mask[GoodInd] = 1
Denominator = Total(Mask, 3)
AvImg = StackProduct / Denominator
Good luck!
Chris
|
|
|