On Monday, June 1, 2015 at 9:18:36 PM UTC+2, alx wrote:
> Le lundi 1 juin 2015 17:27:14 UTC+2, Helder a écrit :
>> Hi,
>> maybe I'm missing something very basic...
>> Suppose I make an image with these commands:
>> w = window(dimension=[600,600])
>> i = image(dist(600), margin=0, image_dimensions=[100,100], current=w)
>>
>> The idea is that the image has 600x600 pixels, but the units are 100x100.
>> So each pixel (device units) has a size of 6.
>>
>> If I now change the data:
>> i.setData, dist(300)
>>
>> It turns out that the "image does not change" (in appearance) and not the 300 pixel correspond to 100 units. So that the pixel has a size of 3 units.
>>
>> Can I redefine, after the setData, the image_dimensions?
>>
>> I did notice that the "image_dimensions" keyword is under the "Keywords are applied only during the initial creation of the graphic." part of the help. Just looking for a way around this.
>>
>> Thanks,
>> Helder
>
> Keywords IMAGE_DIMENSIONS and IMAGE_LOCATION are meant for replacing X and Y vectors in case of a regularly sampled image, independently on the number of pixels in the image.
> For example, qiven the array A[300,300],
> i = image(A, IMAGE_DIMENSIONS=[100,150], IMAGE_LOCATION=[20,30])
> means that the X-axis goes from 20 to 120 and Y-axis from 30 to 180.
>
> alx.
Thanks Alx.
Ok, so I think I got this. I need to use:
i.setData, dist(300), xVector, yVector
I tried this and the result puzzled me quite a bit.
Lets start from looking at what I get when I print the image object (in my case i) after creation:
IDL> i = image(dist(600), margin=0, image_dimensions=[100,100], current=w)
IDL> i
SCALE_CENTER = 50.000000 50.000000
XRANGE = 0.00000000 100.00000
YRANGE = 0.00000000 100.00000
I only left the relevant results above.
If I use dist(300) I get exactly the same result.
If I then insert a image using two vectors x and y, here is what I get:
IDL> i.setData, dist(300), cgscalevector(findgen(300),0,100, /double), cgscalevector(findgen(300),0,100, /double)
SCALE_CENTER = 50.167224 50.167224
XRANGE = 0.00000000 100.33445
YRANGE = 0.00000000 100.33445
Why is xrange not ending at 100? I would expect that because
IDL> min(cgscalevector(findgen(300),0,100, /double))
0.00000000000000000
IDL> max(cgscalevector(findgen(300),0,100, /double))
100.00000000000000
In order to get the original result, I need this:
IDL> i.setData, dist(300), cgscalevector(findgen(300),0,99.0+2.0/3d, /double), cgscalevector(findgen(300),0,99.0+2.0/3d, /double)
SCALE_CENTER = 50.000000 50.000000
XRANGE = 0.00000000 100.00000
YRANGE = 0.00000000 100.00000
With:
IDL> min(cgscalevector(findgen(300),0,99.0+2.0/3d, /double))
0.00000000000000000
IDL> max(cgscalevector(findgen(300),0,99.0+2.0/3d, /double))
99.666666666666671
Where is this missing third coming from?
Thanks,
Helder
PS: pardon my being pedantic...
|