Congrid scaling issue

Issue #6 resolved
Ben West created an issue

I have a 3x3072x2048 image (the 3 being for RGB color) which I'm attempting to rescale to 3x768x512 using congrid (instead of rebin, which I know is better, because the image in use isn't necessarily always going to be able to be scaled by integer multiples/factors) to display on the screen. I noticed that part of my image wasn't being displayed, so I verified the functionality of the command in IDL. I was entering the command correctly, FL was bugging out somewhere.

For testing, I'm creating a 768x512 window and an array with red, green, and blue lines so that the issue is very visible. The following commands display correctly in IDL and incorrectly in FL.

window,0,xs=768,ys=512
img=bytarr(3,3072,2048)
for i=0,2 do img[i,*,i:*:3]=255
tv,congrid(img,3,768,512),/true

In IDL, in order to display the image as it appears in FL I need to exchange the last command with:

tv,congrid(img,3,768,512*(3./2)),/true

or equivalently:

tv,congrid(img,3,768,768),/true

Also, testing with just running array_equal(img, congrid(img,3, 3072,2048)) returns 0: although no change should exist between the two, they are not equal. IDL returns 1, as they are equal. Rebin works as intended in both IDL and FL.

Another example:

window,0,xs=150,ys=100
img=bytarr(600,400)
img[*,0:*:2]=255
tv,congrid(img,150,100)

The last line must have the last dimension changed to a value of 150 in IDL in order to match FL's display. This shows that the issue exists not only in three dimensions, but two as well.

I did verify that congrid(img,x,y,z) does return an array with the dimensions (x,y,z).

I have not tested other aspect ratios than 3:2, but I suspect that the issue is something with the largest sized dimension being applied as the value for scaling later dimensions, which may then get cropped.

Some support for that idea: if I do tv,congrid(img,150,100000) (in that last example), it displays the exact same thing as tv,congrid(img,150,100) and as tv,congrid(img,150,150).

Comments (5)

  1. Log in to comment