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

Home » Public Forums » archive » Re: reading pixels from images from automated XYpositions
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: reading pixels from images from automated XYpositions [message #38982] Fri, 16 April 2004 04:58
Thomas Nehls is currently offline  Thomas Nehls
Messages: 24
Registered: March 2004
Junior Member
Rick Towler wrote:
> "Thomas Nehls" wrote in message...
>
>
>>> img = READ_TIFF(image, R, G, B , ORIENTATION=1,
>
> SUB_RECT=[pos[1,i]-3,pos[2,i], 7, 7])
>
>>> OPENW,1,'greyscale_data.dat',/APPEND
>>> PRINTF,1, i+1, mean(R), stddev(R), median(R)
>>> CLOSE,1
>>> ENDFOR
>>>
>>> END
>>
>> I thought, this would be a good idea, but unfortunately:
>>
>>> % READ_TIFF: Expression must be named variable in this context:
>>> <INT ( 1)>.
>>
>> what does it mean? which expression?
>
>
> Even if you don't understand the error, check the clues. READ_TIFF is
> complaining about something to do with an integer value "1". Looking at
> your READ_TIFF call I see two places you are trying to pass "1". A check of
> the docs would reveal that ORIENTATION is supposed to be set "to a named
> variable which will contain the orientation value from the TIFF file." So
> READ_TIFF wants to *return* a value via the ORIENTATION keyword but it can't
> because "1" is not a valid variable. Changing "ORIENTATION=1" to
> "ORIENTATION=o" should fix this problem.
>
> -Rick
>
>
Hi,

you are completely right, sorry. some hours before I used the
ORIENTATION keyword in connection with WRITE_TIFF, so my mistake was to
think(to wish) ORIENTATION would have the same function in READ_TIFF.

Is there any possibility to tell IDL that the XY coordinates I used to
define the SUBRECT Portion are coordinates starting from the left hand
top? (Thats what I wanted to tell IDL by using ORIENTATION = 1)

I dont want to recalculate the coordinates...
Thanks
Tom
Re: reading pixels from images from automated XYpositions [message #38992 is a reply to message #38982] Thu, 15 April 2004 09:50 Go to previous message
Rick Towler is currently offline  Rick Towler
Messages: 821
Registered: August 1998
Senior Member
"Thomas Nehls" wrote in message...

>> img = READ_TIFF(image, R, G, B , ORIENTATION=1,
SUB_RECT=[pos[1,i]-3,pos[2,i], 7, 7])
>>
>> OPENW,1,'greyscale_data.dat',/APPEND
>> PRINTF,1, i+1, mean(R), stddev(R), median(R)
>> CLOSE,1
>> ENDFOR
>>
>> END
>
> I thought, this would be a good idea, but unfortunately:
>> % READ_TIFF: Expression must be named variable in this context:
>> <INT ( 1)>.
>
> what does it mean? which expression?

Even if you don't understand the error, check the clues. READ_TIFF is
complaining about something to do with an integer value "1". Looking at
your READ_TIFF call I see two places you are trying to pass "1". A check of
the docs would reveal that ORIENTATION is supposed to be set "to a named
variable which will contain the orientation value from the TIFF file." So
READ_TIFF wants to *return* a value via the ORIENTATION keyword but it can't
because "1" is not a valid variable. Changing "ORIENTATION=1" to
"ORIENTATION=o" should fix this problem.

-Rick
Re: reading pixels from images from automated XYpositions [message #38994 is a reply to message #38992] Thu, 15 April 2004 09:23 Go to previous message
Thomas Nehls is currently offline  Thomas Nehls
Messages: 24
Registered: March 2004
Junior Member
Hi Yunxiang,
thank you for showing me where my problem was! now I got a new one ;-)

I have an 3 x 6 array.
I looked through the IDL-help and then I found all the keywords for the
read_tiff function and now I think that is one key to our problem:
what do you think about that:

> PRO gs
>
> image = DIALOG_PICKFILE(,/read) ;gets the image filename
> position = DIALOG_PICKFILE(,/read) ;gets the according position filename
>
> pos = READ_SYLK(position, /ARRAY, /COLMAJOR, NROWS=n)
>
> output = DIALOG_PICKFILE(,/WRITE)
> OPENW,1,output,/APPEND
> PRINTF,1,image
> CLOSE,1
>
> FOR i=0,n-1 DO BEGIN
>
> img = READ_TIFF(image, R, G, B , ORIENTATION=1, SUB_RECT=[pos[1,i]-3,pos[2,i], 7, 7])
>
> OPENW,1,'greyscale_data.dat',/APPEND
> PRINTF,1, i+1, mean(R), stddev(R), median(R)
> CLOSE,1
> ENDFOR
>
> END

I thought, this would be a good idea, but unfortunately:
> % READ_TIFF: Expression must be named variable in this context:
> <INT ( 1)>.

what does it mean? which expression?

Can anybody help us/me?
Thanks in advance
Tom
Re: reading pixels from images from automated XYpositions [message #39007 is a reply to message #38994] Wed, 14 April 2004 16:02 Go to previous message
Yunxiang Zhang is currently offline  Yunxiang Zhang
Messages: 19
Registered: October 2003
Junior Member
I think you'd better explain in detail the definition of your pos. I can't
understand it from your code. But I think I may have a similiar question
of how to extract features from an image.

For example, let's define a 7X7 pixels area a molecule. And I have all N
molecules' positions stored in a 2XN array pos. Thus, molecule No. i will
be,

Image[pos[0,i]-3:pos[0,i]+3,pos[1,i]-3:pos[1,i]+3]

which is a 7X7 data. But if if I want to extract all the molecules at the
same time without using a loop. Then I got,

molecules=Image[pos[0,*]-3:pos[0,*]+3,pos[1,*]-3:pos[1,*]+3]

% Expression must be a scalar or 1 element array in this context: <INT
Array[1, N]>.

Can anybody show me how to do this properly?


Thanks!
Yunxiang


On Wed, 14 Apr 2004, Thomas Nehls wrote:

> Hi folks,
>
> I want to get information(mean, stddev, median) about the values of
> certain pixels(7x7 pixels areas) from an image.
> The according XY positions should be read from a file, where a list of
> positions is given.
>
> This is, what I thought could work:
>
>> PRO input,x
>>
>> FOR n=0,x-1 do grey_scale_value,n
>> END
>>
>> PRO grey_scale_value, n,x
>> file = DIALOG_PICKFILE(/READ)
>> img = READ_TIFF(file)
>> positions = DIALOG_PICKFILE(/READ)
>> pos =bytarr(3,6)
>> pos = READ_SYLK(positions,/ARRAY)
>> pixels1 = img[0,23:26,35:38]
>> pixels2 = img[0,(pos[1]-3 where pos[0]=n):(pos[1]+3 where pos[0]=n),(pos[2]-3 where pos[0]=n):(pos[2]+3 where pos[0]=n)]
>>
>> OPENW,1,'greyscale_data.dat',/APPEND
>> PRINTF,1, (n+1),mean(pixels2),stddev(pixels2),median(pixels2)
>> CLOSE,1
>> END
>
> first I tried pixels1, the scheme works, but I think I used the 'where'
> command in the wrong way...
> Do you have a hint for me?
> Thanks
> Tom
>
>
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Yes, probably, you're right
Next Topic: Re: set default set of sub-bands in envi_select

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

Current Time: Wed Oct 08 15:48:08 PDT 2025

Total time taken to generate the page: 0.00553 seconds