comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Resample (neighborhood averaging) a 3D array with missing data
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Resample (neighborhood averaging) a 3D array with missing data [message #86762] Sun, 01 December 2013 17:51 Go to next message
zhangj.sdu is currently offline  zhangj.sdu
Messages: 6
Registered: December 2013
Junior Member
Hello, everyone:

I want to resample a 128x20000x32 (sample,line, band) image with missing data into a 32x5000x32 image, using neighborhood averaging over 4x4 pixels.
The REBIN function cannot help, since it has no NaN keyword like MEAN; The "Average Arrays with Missing Data" tip in the "Examples To Illuminate the IDL Way" is for two arrays (http://www.idlcoyote.com/idl_way/smallexamples.html).

The total amount of images is hundreds of gigabytes. Is there any fast solution to this?

Thanks.
Clark
Re: Resample (neighborhood averaging) a 3D array with missing data [message #86764 is a reply to message #86762] Sun, 01 December 2013 20:55 Go to previous messageGo to next message
Matthew Argall is currently offline  Matthew Argall
Messages: 286
Registered: October 2011
Senior Member
You could try using SMOOTH(array, WIDTH=4, /NAN), then replace NANs in the original array by the result of the smooth. Then use REBIN.
Re: Resample (neighborhood averaging) a 3D array with missing data [message #86765 is a reply to message #86764] Mon, 02 December 2013 02:35 Go to previous messageGo to next message
zhangj.sdu is currently offline  zhangj.sdu
Messages: 6
Registered: December 2013
Junior Member
On Monday, December 2, 2013 12:55:09 PM UTC+8, Matthew Argall wrote:
> You could try using SMOOTH(array, WIDTH=4, /NAN), then replace NANs in the original array by the result of the smooth. Then use REBIN.

Thanks, Matthew. It doesn't work when the NaNs are on the edge of 4x4 pixels.

When averaging over each 4x4 pixels sub-image, the NaNs within them should be ignored, like MEAN(sub-image, /NaN)

Clark
Re: Resample (neighborhood averaging) a 3D array with missing data [message #86766 is a reply to message #86762] Mon, 02 December 2013 02:35 Go to previous messageGo to next message
lecacheux.alain is currently offline  lecacheux.alain
Messages: 325
Registered: January 2008
Senior Member
Le lundi 2 décembre 2013 02:51:50 UTC+1, zhang...@gmail.com a écrit :
> Hello, everyone:
>
>
>
> I want to resample a 128x20000x32 (sample,line, band) image with missing data into a 32x5000x32 image, using neighborhood averaging over 4x4 pixels.
>
> The REBIN function cannot help, since it has no NaN keyword like MEAN; The "Average Arrays with Missing Data" tip in the "Examples To Illuminate the IDL Way" is for two arrays (http://www.idlcoyote.com/idl_way/smallexamples.html).
>
>
>
> The total amount of images is hundreds of gigabytes. Is there any fast solution to this?
>
>
>
> Thanks.
>
> Clark


resampled_array = mean(mean(reform(array,4,32,4,5000,32,/OVER),DIM=1,/NAN),DIM =2,/NAN)

alx.
Re: Resample (neighborhood averaging) a 3D array with missing data [message #86767 is a reply to message #86766] Mon, 02 December 2013 02:39 Go to previous messageGo to next message
lecacheux.alain is currently offline  lecacheux.alain
Messages: 325
Registered: January 2008
Senior Member
Le lundi 2 décembre 2013 11:35:47 UTC+1, alx a écrit :
> Le lundi 2 décembre 2013 02:51:50 UTC+1, zhang...@gmail.com a écrit :
>
>> Hello, everyone:
>
>>
>
>>
>
>>
>
>> I want to resample a 128x20000x32 (sample,line, band) image with missing data into a 32x5000x32 image, using neighborhood averaging over 4x4 pixels.
>
>>
>
>> The REBIN function cannot help, since it has no NaN keyword like MEAN; The "Average Arrays with Missing Data" tip in the "Examples To Illuminate the IDL Way" is for two arrays (http://www.idlcoyote.com/idl_way/smallexamples.html).
>
>>
>
>>
>
>>
>
>> The total amount of images is hundreds of gigabytes. Is there any fast solution to this?
>
>>
>
>>
>
>>
>
>> Thanks.
>
>>
>
>> Clark
>
>
>
>
>
> resampled_array = mean(mean(reform(array,4,32,4,5000,32,/OVER),DIM=1,/NAN),DIM =2,/NAN)
>
>
>
> alx.

Maybe faster would be:
resampled_array=mean(transpose(reform(array,4,32,4,5000,32,/ OVER),[0,2,1,3]), DIM=1,/NAN)

alx.
Re: Resample (neighborhood averaging) a 3D array with missing data [message #86768 is a reply to message #86767] Mon, 02 December 2013 02:44 Go to previous messageGo to next message
lecacheux.alain is currently offline  lecacheux.alain
Messages: 325
Registered: January 2008
Senior Member
Le lundi 2 décembre 2013 11:39:19 UTC+1, alx a écrit :
> Le lundi 2 décembre 2013 11:35:47 UTC+1, alx a écrit :
>
>> Le lundi 2 décembre 2013 02:51:50 UTC+1, zhang...@gmail.com a écrit :
>
>>
>
>>> Hello, everyone:
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>> I want to resample a 128x20000x32 (sample,line, band) image with missing data into a 32x5000x32 image, using neighborhood averaging over 4x4 pixels.
>
>>
>
>>>
>
>>
>
>>> The REBIN function cannot help, since it has no NaN keyword like MEAN; The "Average Arrays with Missing Data" tip in the "Examples To Illuminate the IDL Way" is for two arrays (http://www.idlcoyote.com/idl_way/smallexamples.html).
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>> The total amount of images is hundreds of gigabytes. Is there any fast solution to this?
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>> Thanks.
>
>>
>
>>>
>
>>
>
>>> Clark
>
>>
>
>>
>
>>
>
>>
>
>>
>
>> resampled_array = mean(mean(reform(array,4,32,4,5000,32,/OVER),DIM=1,/NAN),DIM =2,/NAN)
>
>>
>
>>
>
>>
>
>> alx.
>
>
>
> Maybe faster would be:
>
> resampled_array=mean(transpose(reform(array,4,32,4,5000,32,/ OVER),[0,2,1,3]), DIM=1,/NAN)
>
>
>
> alx.

Sorry, I forgot a more REFORM !

resampled_array=mean(reform(transpose(reform(array,4,32,4,50 00,32,/OVER),[0,2,1,3]),8,32,5000,32,/OVER),DIM=1,/NAN)
Re: Resample (neighborhood averaging) a 3D array with missing data [message #86769 is a reply to message #86768] Mon, 02 December 2013 02:47 Go to previous messageGo to next message
Moritz Fischer is currently offline  Moritz Fischer
Messages: 32
Registered: June 2013
Member
>>
>>
>> alx.
>
> Sorry, I forgot a more REFORM !
>
> resampled_array=mean(reform(transpose(reform(array,4,32,4,50 00,32,/OVER),[0,2,1,3]),8,32,5000,32,/OVER),DIM=1,/NAN)
>


... and I think the "8" should be a "16" ( = 4 x 4 ). But you made your
point ;-)
Re: Resample (neighborhood averaging) a 3D array with missing data [message #86779 is a reply to message #86769] Mon, 02 December 2013 16:28 Go to previous message
zhangj.sdu is currently offline  zhangj.sdu
Messages: 6
Registered: December 2013
Junior Member
On Monday, December 2, 2013 6:47:58 PM UTC+8, Moritz Fischer wrote:
>>>
>
>>>
>
>>> alx.
>
>>
>
>> Sorry, I forgot a more REFORM !
>
>>
>
>> resampled_array=mean(reform(transpose(reform(array,4,32,4,50 00,32,/OVER),[0,2,1,3]),8,32,5000,32,/OVER),DIM=1,/NAN)
>
>>
>
>
>
>
>
> ... and I think the "8" should be a "16" ( = 4 x 4 ). But you made your
>
> point ;-)

This is exactly what I need. Thanks, ALX, Moritz.
Clark
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: IDL 8.3???
Next Topic: Color Data with Colorbar OOB Colors

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 11:31:49 PDT 2025

Total time taken to generate the page: 0.00519 seconds