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

Home » Public Forums » archive » Re: something (wrong?) with CONGRID?
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
Re: something (wrong?) with CONGRID? [message #75804] Sun, 01 May 2011 21:36
JP is currently offline  JP
Messages: 55
Registered: April 2008
Member
thanks David...
I may try to find a different way to create my c array in the example above.

JP
Re: something (wrong?) with CONGRID? [message #75805 is a reply to message #75804] Sun, 01 May 2011 21:13 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
JP writes:

> I think I came across a bug with CONGRID, but I'll be happy to be shown wrong.
>
> in the following example all goes as expected:
>
> a = lindgen(95, 74)
> b = congrid(a, 95*10, 74*10)
> Histo_b = Histogram(b, BINSIZE=1)
> help, b
> minmax, Histo_b
>
> I get:
> B LONG = Array[950, 740]
> 100 100
>
> so far, so good, b is an array 10 times larger and wider than a and all the elements of a are repeated 100 times in b.
>
> now I change the size of the array a:
>
> a = lindgen(958, 745)
> b = congrid(a, 958*10, 745*10)
> Histo_b = Histogram(b, BINSIZE=1)
> help, b
> minmax, Histo_b
>
> This time I get:
> B LONG = Array[9580, 7450]
> 90 120
>
> the size of b is OK, but there are some elements repeated 90 times and some others repeated 120 times!!?? I was expecting again 100 and 100.
>
> If I go a bit further and do:
> Histo_b = REFORM(histo_b, 958, 745)
> cgIMAGE, histo_b, SCALE=1
>
> I can see that the values of a repeated 90 times (instead as 100 as expected) are in two columns to the right and the values repeated 120 times are in the last column to the right...
>
>
> Is there anything wrong with CONGRID or I am missing something there?

I don't know exactly why this is happening. But I have
seen enough of this kind of thing over the years to feel
confident that it is yet another (although interesting)
variation of the "sky is falling" phenomenon.

http://www.idlcoyote.com/math_tips/sky_is_falling.html

In other words, when the replication isn't exact, interpolation
has to play a role and computers just cannot represent every
number exactly. Some numbers must fall on the "razor's edge"
and this fact results in some slight imbalancing of the number
of repeats.

http://www.idlcoyote.com/math_tips/razoredge.html

I don't think there is anything particularly alarming about
this. It is really no different then learning that even
mathematical theories cannot be complete. It just means
that whatever we do, there is mystery in the world. I happen
to think that is *exactly* the way it should be. :-)

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: something (wrong?) with CONGRID? [message #75806 is a reply to message #75805] Sun, 01 May 2011 20:35 Go to previous message
JP is currently offline  JP
Messages: 55
Registered: April 2008
Member
By the way, what I am trying to do is to create an array that groups pixels of my original array ARRAY of dims ns, nl in areas of size x, x.

For example, my array is of size (ns, nl) and x=10 I do:


x= 10
a = lindgen(ns/x, nl/x) ; makes array of dims / x
b = congrid(a, (ns/x)*x, (nl/x)*x) ; resizes a to original size
c = lonarr(ns, nl) ; new array the size I want
c[0:(ns/x)*x-1, 0:(nl/x)*x-1] = b ; fills the array I want with b (leaves 0 in the bottom and right borders which don't add to 10 pixels
undefine, a, b ; gets rid of a and b

histo_c = Histogram(c, BINSIZE=1, REVERSE_INDICES=ri)

then I use the array c (via reverse_indices) to do my processing of ARRAY in areas of 10x10 (in the example above).

If there is a simpler, better way to do that I'll be happy to know.

JP
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: something (wrong?) with CONGRID?
Next Topic: Re: Book Tour Report

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

Current Time: Wed Oct 08 11:41:03 PDT 2025

Total time taken to generate the page: 0.00621 seconds