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

Home » Public Forums » archive » Re: rebin but ignore zero
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: rebin but ignore zero [message #62675 is a reply to message #62661] Fri, 26 September 2008 13:15 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Klassen writes:

> I have a very sparse array (image) and I want to resize it---shrink
> it by a factor of 2 in each direction. If I do a rebin, every pixel
> is
> replaced by its nearest neighbor average, but many of those
> neighbors are zeroes---not real zeroes, but zero because there
> is no data there. This means, the resulting rebin-ed image has
> values that are smaller than they "should" be.
>
> Is there a way to do a rebin that can ignore these "blank" pixels?

In contrast to what the documentation says, REBIN insists on doing
bilinear sampling when minifying a dimension. You can overcome
this by setting the SAMPLE keyword. Then nearest-neighbor sampling
will be enforced, and your data values won't change.

IDL> a=fltarr(10,10)
IDL> a[2,2] =1
IDL> a[8,8] = 1
IDL> print, rebin(a, 5, 5)
0.000000 0.000000 0.000000 0.000000 0.000000
0.000000 0.250000 0.000000 0.000000 0.000000
0.000000 0.000000 0.000000 0.000000 0.000000
0.000000 0.000000 0.000000 0.000000 0.000000
0.000000 0.000000 0.000000 0.000000 0.250000
IDL> print, rebin(a, 5, 5, /SAMPLE)
0.000000 0.000000 0.000000 0.000000 0.000000
0.000000 1.00000 0.000000 0.000000 0.000000
0.000000 0.000000 0.000000 0.000000 0.000000
0.000000 0.000000 0.000000 0.000000 0.000000
0.000000 0.000000 0.000000 0.000000 1.00000

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: Image file creation file size too large
Next Topic: DUNK DUNK man DUNK women DUNK High man DUNK High women

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

Current Time: Tue Dec 02 22:45:56 PST 2025

Total time taken to generate the page: 1.68077 seconds