Creating a composite image, avoid fill data values [message #65136] |
Fri, 13 February 2009 08:30  |
Matt[1]
Messages: 23 Registered: December 2006
|
Junior Member |
|
|
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.
|
|
|
Re: Creating a composite image, avoid fill data values [message #65180 is a reply to message #65136] |
Mon, 16 February 2009 16:08  |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
On Feb 13, 11:30 am, 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.
The stacking method is OK, but in this case a loop with five
iterations will not hurt. Assuming your image is stored in the array
IMAGE(600,800,5),
TOT = fltarr(600,800) ;; Cumulative total image
NSAMP = TOT ;; Number of valid samples per pixel
for i = 0, 4 do begin
nsamp = nsamp + (IMAGE NE 0) ;; Accumulate number of valid pixels
tot = tot + IMAGE ;; Accumulate total
end
mean = (TOT/NSAMP)
Of course you will want to check NSAMP to avoid dividing by zero.
|
|
|