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

Home » Public Forums » archive » Re: how to read/display an image like it's done in ENVI?
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: how to read/display an image like it's done in ENVI? [message #69222] Tue, 29 December 2009 07:44
Hassan is currently offline  Hassan
Messages: 48
Registered: October 2009
Member
On Dec 29, 2:40 pm, David Fanning <n...@dfanning.com> wrote:
> Hassan writes:
>> yeah the code is fine. I did a silly mistake, I read the the data in
>> the wrong band I should've read [299,159,0] but I read [299,159,1]
>> instead.
>
> Yes, if I could predict stocks as well as I can predict
> IDL outcomes I would be a rich man, indeed! ;-)
>
> 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.")

yes indeed David :D, thanks for the help.
Re: how to read/display an image like it's done in ENVI? [message #69225 is a reply to message #69222] Tue, 29 December 2009 06:40 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Hassan writes:

> yeah the code is fine. I did a silly mistake, I read the the data in
> the wrong band I should've read [299,159,0] but I read [299,159,1]
> instead.

Yes, if I could predict stocks as well as I can predict
IDL outcomes I would be a rich man, indeed! ;-)

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: how to read/display an image like it's done in ENVI? [message #69226 is a reply to message #69225] Tue, 29 December 2009 06:25 Go to previous message
Hassan is currently offline  Hassan
Messages: 48
Registered: October 2009
Member
On Dec 29, 2:06 pm, David Fanning <n...@dfanning.com> wrote:
> Hassan writes:
>> do you think has something unusual happened?
>
> I don't know. The code you sent doesn't work. Could
> that be the problem?
>
> Once I got the code to work, the ENVI value at [1,1]
> corresponded exactly to the image value at [0,0].
>
> Here is the code I used.
>
> filename = 'bhdemsub.img'
> ENVI_OPEN_FILE, filename, /NO_REALIZE , R_FID=FID
> envi_file_query, fid, ns=dimX, nl=dimY, nb=nbBands,$
>     DATA_TYPE=dataType, OFFSET = HeaderOffSet, $
>     LOOKUP= lookup, class_names =classNames, $
>     num_classes = numClasses
> map_Info = ENVI_GET_MAP_INFO(FID=FID)
> image = read_binary(filename,data_Start = HeaderOffSet,$
>         data_Type=dataType, data_Dims=[dimX,dimY,nbBANDS],$
>         ENDIAN= "native")
>
> 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.")

yeah the code is fine. I did a silly mistake, I read the the data in
the wrong band I should've read [299,159,0] but I read [299,159,1]
instead.
Re: how to read/display an image like it's done in ENVI? [message #69227 is a reply to message #69226] Tue, 29 December 2009 06:06 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Hassan writes:

> do you think has something unusual happened?

I don't know. The code you sent doesn't work. Could
that be the problem?

Once I got the code to work, the ENVI value at [1,1]
corresponded exactly to the image value at [0,0].

Here is the code I used.

filename = 'bhdemsub.img'
ENVI_OPEN_FILE, filename, /NO_REALIZE , R_FID=FID
envi_file_query, fid, ns=dimX, nl=dimY, nb=nbBands,$
DATA_TYPE=dataType, OFFSET = HeaderOffSet, $
LOOKUP= lookup, class_names =classNames, $
num_classes = numClasses
map_Info = ENVI_GET_MAP_INFO(FID=FID)
image = read_binary(filename,data_Start = HeaderOffSet,$
data_Type=dataType, data_Dims=[dimX,dimY,nbBANDS],$
ENDIAN= "native")

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: how to read/display an image like it's done in ENVI? [message #69228 is a reply to message #69227] Tue, 29 December 2009 06:00 Go to previous message
Hassan is currently offline  Hassan
Messages: 48
Registered: October 2009
Member
On Dec 29, 1:46 pm, Chris Jengo <cje...@gmail.com> wrote:
> Is there a specific reason why you need to do this in IDL rather than
> just using the ENVI functions ENVI_GET_DATA or ENVI_GET_SLICE?

using envi_get_data I just can import two dimensional image at a time
and I think I need a loop for importing three dimensional data.
envi_get_slice is just for extracting specific line of the data in
specific band/s while I'm importing the whole data.
Re: how to read/display an image like it's done in ENVI? [message #69229 is a reply to message #69228] Tue, 29 December 2009 05:46 Go to previous message
Chris Jengo is currently offline  Chris Jengo
Messages: 13
Registered: July 1999
Junior Member
Is there a specific reason why you need to do this in IDL rather than
just using the ENVI functions ENVI_GET_DATA or ENVI_GET_SLICE?
Re: how to read/display an image like it's done in ENVI? [message #69230 is a reply to message #69229] Tue, 29 December 2009 05:26 Go to previous message
Hassan is currently offline  Hassan
Messages: 48
Registered: October 2009
Member
On Dec 29, 1:15 pm, Hassan <hkhav...@gmail.com> wrote:
> On Dec 29, 12:31 pm, David Fanning <n...@dfanning.com> wrote:
>
>
>
>> Hassan writes:
>>> No, I took that into account as well for example if the pixel value of
>>> the position [300,160,0]/[column,row,band] the equivalent pixel in the
>>> flipped image in IDL should be [299,160,0] but the pixel value doesn't
>>> match.
>
>> Shouldn't that be [299, 159, 0]?
>
>> 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.")
>
> yeah, It is [299,159,0] but the problem still exists. I used the
> following commands to import the data from ENVI:
> ENVI> ENVI_OPEN_FILE, image, /NO_REALIZE , R_FID=FID
> ENVI> ;If it is a valid file, read the header
> ENVI> ;if (fid[0] eq -1) then return, -1
> ENVI> envi_file_query, fid, ns=dimX, nl=dimY, nb=nbBands,
> DATA_TYPE=dataType,$
> ENVI>     OFFSET = HeaderOffSet, LOOKUP= lookup, class_names =
> classNames,$
> ENVI>     num_classes = numClasses
> ENVI> map_Info = ENVI_GET_MAP_INFO(FID=FID)
> ENVI> ;Pack the header info in a structure (optional)
> ENVI> headerInfo = {ns:dimX, nl:dimY, lookup:lookup,
> map_info:map_Info}
> ENVI> data = read_binary(ref2,data_Start = HeaderOffSet,$
> ENVI>         data_Type=dataType, data_Dims=[dimX,dimY,nbBANDS],ENDIAN
> = "native")
> ENVI>         image=data
>
> do you think has something unusual happened?

I used the Export to IDL function in ENVI and it works fine so there
should be something wrong in the way I imported the data.
Re: how to read/display an image like it's done in ENVI? [message #69231 is a reply to message #69230] Tue, 29 December 2009 05:15 Go to previous message
Hassan is currently offline  Hassan
Messages: 48
Registered: October 2009
Member
On Dec 29, 12:31 pm, David Fanning <n...@dfanning.com> wrote:
> Hassan writes:
>> No, I took that into account as well for example if the pixel value of
>> the position [300,160,0]/[column,row,band] the equivalent pixel in the
>> flipped image in IDL should be [299,160,0] but the pixel value doesn't
>> match.
>
> Shouldn't that be [299, 159, 0]?
>
> 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.")

yeah, It is [299,159,0] but the problem still exists. I used the
following commands to import the data from ENVI:
ENVI> ENVI_OPEN_FILE, image, /NO_REALIZE , R_FID=FID
ENVI> ;If it is a valid file, read the header
ENVI> ;if (fid[0] eq -1) then return, -1
ENVI> envi_file_query, fid, ns=dimX, nl=dimY, nb=nbBands,
DATA_TYPE=dataType,$
ENVI> OFFSET = HeaderOffSet, LOOKUP= lookup, class_names =
classNames,$
ENVI> num_classes = numClasses
ENVI> map_Info = ENVI_GET_MAP_INFO(FID=FID)
ENVI> ;Pack the header info in a structure (optional)
ENVI> headerInfo = {ns:dimX, nl:dimY, lookup:lookup,
map_info:map_Info}
ENVI> data = read_binary(ref2,data_Start = HeaderOffSet,$
ENVI> data_Type=dataType, data_Dims=[dimX,dimY,nbBANDS],ENDIAN
= "native")
ENVI> image=data

do you think has something unusual happened?
Re: how to read/display an image like it's done in ENVI? [message #69232 is a reply to message #69231] Tue, 29 December 2009 04:31 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Hassan writes:

> No, I took that into account as well for example if the pixel value of
> the position [300,160,0]/[column,row,band] the equivalent pixel in the
> flipped image in IDL should be [299,160,0] but the pixel value doesn't
> match.

Shouldn't that be [299, 159, 0]?

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: how to read/display an image like it's done in ENVI? [message #69233 is a reply to message #69232] Tue, 29 December 2009 03:05 Go to previous message
Hassan is currently offline  Hassan
Messages: 48
Registered: October 2009
Member
On Dec 29, 1:10 am, David Fanning <n...@dfanning.com> wrote:
> Hassan writes:
>> I have an multi-band image [488,290,62] and opened it in ENVI. I need
>> to work with a particular pixel for example pixel with column 300 and
>> row 160 in band 1. after importing the image in IDL, i couldnt find
>> the pixel.
>> print, image[300,160,0] >>> it shows me a pixel value that is
>> different with the one is shown in ENVI
>> I flipped the image (using reverse function) and consider it starts
>> with column=0 and row=0 in IDL but still couldnt find the pixel.
>> image=reverse[image,2]
>> print, image[299,159]
>
>> I'm not sure if I describe the problem clearly so please let me know
>> if you need more explanation.
>
> ENVI uses an indexing system that starts at [1,1],
> rather than the [0,0] of IDL. Could that be the
> problem?
>
> 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.")

Hi David,

No, I took that into account as well for example if the pixel value of
the position [300,160,0]/[column,row,band] the equivalent pixel in the
flipped image in IDL should be [299,160,0] but the pixel value doesn't
match.

Thanks
Hasan
Re: how to read/display an image like it's done in ENVI? [message #69234 is a reply to message #69233] Mon, 28 December 2009 17:10 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Hassan writes:

> I have an multi-band image [488,290,62] and opened it in ENVI. I need
> to work with a particular pixel for example pixel with column 300 and
> row 160 in band 1. after importing the image in IDL, i couldnt find
> the pixel.
> print, image[300,160,0] >>> it shows me a pixel value that is
> different with the one is shown in ENVI
> I flipped the image (using reverse function) and consider it starts
> with column=0 and row=0 in IDL but still couldnt find the pixel.
> image=reverse[image,2]
> print, image[299,159]
>
> I'm not sure if I describe the problem clearly so please let me know
> if you need more explanation.

ENVI uses an indexing system that starts at [1,1],
rather than the [0,0] of IDL. Could that be the
problem?

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.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: IDL 8.0 compile_opt changes
Next Topic: Convolve a spectrum (from MODTRAN) with a spectral response function

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

Current Time: Wed Oct 08 09:13:03 PDT 2025

Total time taken to generate the page: 0.00668 seconds