Re: rebin but ignore zero [message #62660] |
Sun, 28 September 2008 14:30 |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
David Klassen writes:
> Interesting---so I have to do the opposite of the help. :)
My all-time favorite book is Desert Notes/River Notes
by Barry Lopez. And my favorite story in that book, which
I was just thinking about again today, as a matter of fact,
is Directions.
Here he is giving "directions" to the reader:
"There is, I should warn you, doubt too about the
directions I will give you here, but they are the very
best that can be had. They will not be easy to follow.
Where it says left you must go right sometimes. Read
south for north sometimes. It depends a little on where
you are coming from, but not entirely."
I love that story. And I miss telling it for my IDL programming
courses. It forms the underlying theme of my IDL books. Worth
reading for any IDL programmer, I should think. :-)
http://www.librarything.com/work/2496108/details/28551525
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.")
|
|
|
Re: rebin but ignore zero [message #62661 is a reply to message #62660] |
Sun, 28 September 2008 14:13  |
David Klassen
Messages: 27 Registered: December 2004
|
Junior Member |
|
|
On Sep 26, 4:15 pm, David Fanning <n...@dfanning.com> wrote:
> David Klassen writes:
>
>> 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.
Interesting---so I have to do the opposite of the help. :)
OK, that does it for the most part. I guess the array is just too
sparse
because it is still zeroing out some points, but at least the values
seem
to be OK. Thanks!
|
|
|
Re: rebin but ignore zero [message #62675 is a reply to message #62661] |
Fri, 26 September 2008 13:15  |
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.")
|
|
|