Re: Simple question, [message #28853] |
Mon, 14 January 2002 05:06 |
Martin Downing
Messages: 136 Registered: September 1998
|
Senior Member |
|
|
>
> I have an array (251,251,16). I would like to average value of pixel
> where there is mask value of 255 by befor anf after values.
>
> ====This code works===
>
> for k=1, 10 do begin
> temp1(*,*,k)=((temp(*,*,k-1)+temp(*,*,k+1))/2) * (temp(*,*,k) eq
> 255) + (temp(*,*,k) * (temp(*,*,k) ne 255))
>
> end
>
> ====
>
> ====But this code doesn�t work====
..........
"Then don't do it!" Tommy Cooper
Sorry but I couldn't resist
Martin
|
|
|
Re: Simple question, [message #28863 is a reply to message #28853] |
Sat, 12 January 2002 15:32  |
gogosgogos
Messages: 15 Registered: July 2001
|
Junior Member |
|
|
use the > and < operators
they will truncate the other values to 255
result = array > 255
result = array < 255
if you mean averaging a subarray, try something like:
masked = array * (array GE 255)
array_mean = mean(masked)
hope this helps, not sure what you are up to
cheers!
dinhnq@yahoo.com (Dinh Huong) wrote in message news:<b5f3d715.0201120753.d515dc8@posting.google.com>...
> Dear lists,
>
> I have an array (251,251,16). I would like to average value of pixel
> where there is mask value of 255 by befor anf after values.
>
> ====This code works===
>
> for k=1, 10 do begin
> temp1(*,*,k)=((temp(*,*,k-1)+temp(*,*,k+1))/2) * (temp(*,*,k) eq
> 255) + (temp(*,*,k) * (temp(*,*,k) ne 255))
>
> end
>
> ====
>
> ====But this code doesn�t work====
>
> i=indgen(251)
> j=indgen(251)
> k=indgen(16)
>
> for k = 2,13 do begin
>
> temp1(*,*,k)=(temp(*,*,k) * (temp(*,*,k) ne 255) + $
> ((temp(*,*,k-2)*(temp(*,*,k-1) eq 255) + (temp(*,*,k-1)*(temp(*,*,k-1)
> ne 255) + $
> temp(*,*,k+1)*(temp(*,*,k+1) ne 255) + temp(*,*,k+2)*(temp(*,*,k+1) eq
> 255))/2 * (temp(*,*,k) eq 255)
>
> endfor
>
> Thank you for your helps,
>
> Huong Dinh
|
|
|