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

Home » Public Forums » archive » Re: subset an image by coordinates
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: subset an image by coordinates [message #68044] Tue, 22 September 2009 08:40
Alvaro Paredes L. is currently offline  Alvaro Paredes L.
Messages: 5
Registered: September 2009
Junior Member
On 21 sep, 17:58, pp <pp.pente...@gmail.com> wrote:
> On Sep 20, 2:00 pm, "Alvaro Paredes L." <alvaropared...@gmail.com>
> wrote:
>
>> ; define theimageto be opened
>> img_file='F:\IMAGE\NDVI-HDF\try\NDVI_2008_03_02.img'
> ...
>> image=img_file[XF,YF]
>
> Are you trying to subscript the file name? Trying to have a
> conversation with an address (http://groups.google.com/group/
> comp.lang.idl-pvwave/msg/b0859e67a0ff6d51)?

Well, thank you very much... I finally found my mother and talked to
her :-)
As I say before, sometimes it's hard to understand how a program
works, specially if you aren't a progammer (this was a nooby
mistake...). There is only one problem with the output coordinates
data (0.0 on the subset, has the same coordinates that 0.0 in the
original image), but i hope i can fix it soon. Anyway, any help is
welcome.

The finally routine is this:

forward_function ENVI_CONVERT_FILE_COORDINATES
pro SUBSET
envi, /restore_base_save_files
envi_batch_init,log_file='batch.txt'

; define the image to be opened
img_file='F:\IMAGE\NDVI-HDF\try\NDVI_2008_03_02.img'
envi_open_file,img_file,r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif

XMap=[-71.0580916, -70.5006694]
YMap=[-32.6030694, -32.9797194]

ENVI_CONVERT_FILE_COORDINATES, FID, XF, YF, XMap, YMap

XF=ROUND(XF)
YF=ROUND(YF)

envi_file_query, fid, DIMS=DIMS, NB=NB, NL=NL, NS=NS
pos = lindgen(nb)

image=fltarr(NS, NL, NB)
FOR i=0, NB-1 DO BEGIN
image[*,*,i]= envi_get_data(fid=fid, dims=dims, pos=pos[i])
endfor

imagen= image[XF[0]:XF[1],YF[0]:YF[1]]

nl2=YF[1]-YF[0]
ns2=XF[1]-XF[0]

map_info=envi_get_map_info(fid=fid)

envi_write_envi_file, imagen, data_type=4, $
descrip = 'testing', $
map_info = map_info, $
nl=nl2, ns=ns2, nb=nb, r_fid=r_fid, $
OUT_NAME = 'F:\IMAGE\NDVI-HDF\try\trying.hdf'

; Exit Envi
envi_batch_exit
end


Thanks again to everyone who helped me! :)
Re: subset an image by coordinates [message #68051 is a reply to message #68044] Mon, 21 September 2009 14:58 Go to previous message
penteado is currently offline  penteado
Messages: 866
Registered: February 2018
Senior Member
Administrator
On Sep 20, 2:00 pm, "Alvaro Paredes L." <alvaropared...@gmail.com>
wrote:
> ; define the image to be opened
> img_file='F:\IMAGE\NDVI-HDF\try\NDVI_2008_03_02.img'
...
> image=img_file[XF,YF]

Are you trying to subscript the file name? Trying to have a
conversation with an address (http://groups.google.com/group/
comp.lang.idl-pvwave/msg/b0859e67a0ff6d51)?
Re: subset an image by coordinates [message #68052 is a reply to message #68051] Mon, 21 September 2009 14:26 Go to previous message
Alvaro Paredes L. is currently offline  Alvaro Paredes L.
Messages: 5
Registered: September 2009
Junior Member
On 21 sep, 15:25, Robert <robert.m...@gmail.com> wrote:
> On Sep 21, 10:51 am, "Alvaro Paredes L." <alvaropared...@gmail.com>
> wrote:
>
>
>
>
>
>> On 20 sep, 22:27, Jeremy Bailin <astroco...@gmail.com> wrote:
>
>>> On Sep 20, 1:00 pm, "Alvaro Paredes L." <alvaropared...@gmail.com>
>>> wrote:
>
>>>> On 20 sep, 10:24, Robert <robert.m...@gmail.com> wrote:
>
>>>> > On Sep 20, 8:12 am, Jeremy Bailin <astroco...@gmail.com> wrote:
>
>>>> > > On Sep 19, 11:14 pm, "Alvaro Paredes L." <alvaropared...@gmail.com>
>>>> > > wrote:
>
>>>> > > > Hi all
>
>>>> > > > I was searching on the web, but i didn't find an answer to my problem.
>>>> > > > I need to make asubseton animageusing
>
>>>> > > > coordinates, but i can't find a way to do it. I see this method
>
>>>> > > > http://groups.google.es/group/comp.lang.idl-pvwave/browse_fr m/thread/...
>>>> > > > and this other (very
>
>>>> > > > similar) http://www.mombu.com/programming/idl/t-subset-an-image-by-ro i-in-idl-...,
>>>> > > > but don't use
>
>>>> > > > coordinates, use an evf file.
>
>>>> > > > IDL/ENVI has a widget that use only two coordinates to cut (upper-left
>>>> > > > and lower-right coordinate), but it isn't
>
>>>> > > > fully automatically.
>
>>>> > > > Is there any function to cut theimagewith set coordinates and save
>>>> > > > it in a new file?
>
>>>> > > > I really hope you can help me... I'm not a programmer and this
>>>> > > > sometimes it's very hard
>
>>>> > > > Thanks!
>
>>>> > > > Alvaro
>
>>>> > > Do you mean like:
>
>>>> > > newimage = oldimage[x0:x1,y0:y1]
>
>>>> > > ?
>
>>>> > > -Jeremy.
>
>>>> > If the original author is looking tosubsetby map coordinates, he
>>>> > needs to use the procedure
>
>>>> > ENVI_CONVERT_FILE_COORDINATES, FID, XF, YF, XMap, YMap
>
>>>> > to convert the corners of hisimagein map coordinates to file
>>>> > coordinates. Once he has the proper file coordinates, he cansubset
>>>> > theimage. If you give us a little more specifics of what you are
>>>> > trying to do, we can probably provide more information.
>
>>>> > r
>
>>>> Thanks for the quickly help. I have animagewith degrees coordinates
>>>> and with the function that Robert suggested
>>>> (ENVI_CONVERT_FILE_COORDINATES) i can transform coord to pixel value
>>>> without problems (as the script i show below). But i try to do that
>>>> Jeremy suggest, but i don't know if is it properly working
>>>> (image=img_file[XF,YF]??)
>
>>>> forward_function ENVI_CONVERT_FILE_COORDINATES
>>>> proSUBSET
>>>> envi, /restore_base_save_files
>>>> envi_batch_init,log_file='batch.txt'
>
>>>> ; define theimageto be opened
>>>> img_file='F:\IMAGE\NDVI-HDF\try\NDVI_2008_03_02.img'
>>>> envi_open_file,img_file,r_fid=fid
>>>> print, 'fid=',fid
>
>>>> ; define coordinates to make thesubset
>>>> YMap=[-32.6030694, -32.9797194]
>>>> XMap=[-71.0580916, -70.5006694]
>
>>>> ENVI_CONVERT_FILE_COORDINATES, FID, XF, YF, XMap, YMap
>
>>>> ;rounds the pixel value to its closest integer.
>>>> XF=ROUND(XF)
>>>> YF=ROUND(YF)
>
>>>> ;verify the conversion
>>>> print, 'X pixel ',XF
>>>> print, 'Y pixel ',YF
>
>>>> ;making thesubset??????
>>>> image=img_file[XF,YF]
>
>>>> ; Exit Envi
>>>> envi_batch_exit
>>>> end
>
>>>> Finally, and maybe this is a basic question, how i save this "subset"
>>>> in a .img file?
>
>>>> Thanks!
>
>>>> Alvaro
>
>>> Note the colons in my example. :-)=  Instead of
>
>>>  image=img_file[XF,YF]
>
>>> you probably want:
>
>>>  image=img_file[XF[0]:XF[1], YF[0]:YF[1]]
>
>>> -Jeremy.
>
>> Well, thanks Jeremy. I tried to do what you say but i obtain this
>> error:
>> "Subscript range values of the form low:high must be >= 0, < size,
>> with low <= high: IMG_FILE."
>
>> I have verified the order min:max in [XF[0]:XF[1], YF[0]:YF[1]], and
>> try with manual input of pixels values, and isn't working... there's
>> something i'm doing bad... :(
>
>> Alvaro.- Hide quoted text -
>
>> - Show quoted text -
>
> Check first to see if your coordinates are sane; i.e. do they actually
> fall within yourimage? Are the file coordinates between zero and the
> maximum number of lines or samples? Are your map coordinates in the
> proper projection?
>
> r

I already check the coordinates. The image that i'm using to test is a
modis autoref with the MCTK toolkit, so there should be no problem
with the coord system. Also, i checked it in google earth. With ENVI,
i made a subset via map coordinates. The samples and lines matched
well with the ones I got on the other procedure (by
ENVI_CONVERT_FILE_COORDINATES). Also, i used the pixel locator (on
ENVI) to find the pixels samples and lines converted, and all are
inside the image (image is 2509 x 1195... my samples and lines are
(867:934),(311:356) respectively).

I think that the problem is specifically with the line image=img_file
[XF[0]:XF[1], YF[0]:YF[1]]... maybe i need to transform the image or
the values. I tried to extract a single values like image=img_file
[x,y] and i get the same error, so i believe the problem is with
img_file that isn't recognized as an array.

Thanks again!

Alvaro.
Re: subset an image by coordinates [message #68053 is a reply to message #68052] Mon, 21 September 2009 12:25 Go to previous message
Robert Moss, PhD is currently offline  Robert Moss, PhD
Messages: 29
Registered: November 2006
Junior Member
On Sep 21, 10:51 am, "Alvaro Paredes L." <alvaropared...@gmail.com>
wrote:
> On 20 sep, 22:27, Jeremy Bailin <astroco...@gmail.com> wrote:
>
>
>
>
>
>> On Sep 20, 1:00 pm, "Alvaro Paredes L." <alvaropared...@gmail.com>
>> wrote:
>
>>> On 20 sep, 10:24, Robert <robert.m...@gmail.com> wrote:
>
>>>> On Sep 20, 8:12 am, Jeremy Bailin <astroco...@gmail.com> wrote:
>
>>>> > On Sep 19, 11:14 pm, "Alvaro Paredes L." <alvaropared...@gmail.com>
>>>> > wrote:
>
>>>> > > Hi all
>
>>>> > > I was searching on the web, but i didn't find an answer to my problem.
>>>> > > I need to make asubseton animageusing
>
>>>> > > coordinates, but i can't find a way to do it. I see this method
>
>>>> > > http://groups.google.es/group/comp.lang.idl-pvwave/browse_fr m/thread/...
>>>> > > and this other (very
>
>>>> > > similar) http://www.mombu.com/programming/idl/t-subset-an-image-by-ro i-in-idl-...,
>>>> > > but don't use
>
>>>> > > coordinates, use an evf file.
>
>>>> > > IDL/ENVI has a widget that use only two coordinates to cut (upper-left
>>>> > > and lower-right coordinate), but it isn't
>
>>>> > > fully automatically.
>
>>>> > > Is there any function to cut theimagewith set coordinates and save
>>>> > > it in a new file?
>
>>>> > > I really hope you can help me... I'm not a programmer and this
>>>> > > sometimes it's very hard
>
>>>> > > Thanks!
>
>>>> > > Alvaro
>
>>>> > Do you mean like:
>
>>>> > newimage = oldimage[x0:x1,y0:y1]
>
>>>> > ?
>
>>>> > -Jeremy.
>
>>>> If the original author is looking tosubsetby map coordinates, he
>>>> needs to use the procedure
>
>>>> ENVI_CONVERT_FILE_COORDINATES, FID, XF, YF, XMap, YMap
>
>>>> to convert the corners of hisimagein map coordinates to file
>>>> coordinates. Once he has the proper file coordinates, he cansubset
>>>> theimage. If you give us a little more specifics of what you are
>>>> trying to do, we can probably provide more information.
>
>>>> r
>
>>> Thanks for the quickly help. I have animagewith degrees coordinates
>>> and with the function that Robert suggested
>>> (ENVI_CONVERT_FILE_COORDINATES) i can transform coord to pixel value
>>> without problems (as the script i show below). But i try to do that
>>> Jeremy suggest, but i don't know if is it properly working
>>> (image=img_file[XF,YF]??)
>
>>> forward_function ENVI_CONVERT_FILE_COORDINATES
>>> proSUBSET
>>> envi, /restore_base_save_files
>>> envi_batch_init,log_file='batch.txt'
>
>>> ; define theimageto be opened
>>> img_file='F:\IMAGE\NDVI-HDF\try\NDVI_2008_03_02.img'
>>> envi_open_file,img_file,r_fid=fid
>>> print, 'fid=',fid
>
>>> ; define coordinates to make thesubset
>>> YMap=[-32.6030694, -32.9797194]
>>> XMap=[-71.0580916, -70.5006694]
>
>>> ENVI_CONVERT_FILE_COORDINATES, FID, XF, YF, XMap, YMap
>
>>> ;rounds the pixel value to its closest integer.
>>> XF=ROUND(XF)
>>> YF=ROUND(YF)
>
>>> ;verify the conversion
>>> print, 'X pixel ',XF
>>> print, 'Y pixel ',YF
>
>>> ;making thesubset??????
>>> image=img_file[XF,YF]
>
>>> ; Exit Envi
>>> envi_batch_exit
>>> end
>
>>> Finally, and maybe this is a basic question, how i save this "subset"
>>> in a .img file?
>
>>> Thanks!
>
>>> Alvaro
>
>> Note the colons in my example. :-)=  Instead of
>
>>  image=img_file[XF,YF]
>
>> you probably want:
>
>>  image=img_file[XF[0]:XF[1], YF[0]:YF[1]]
>
>> -Jeremy.
>
> Well, thanks Jeremy. I tried to do what you say but i obtain this
> error:
> "Subscript range values of the form low:high must be >= 0, < size,
> with low <= high: IMG_FILE."
>
> I have verified the order min:max in [XF[0]:XF[1], YF[0]:YF[1]], and
> try with manual input of pixels values, and isn't working... there's
> something i'm doing bad... :(
>
> Alvaro.- Hide quoted text -
>
> - Show quoted text -

Check first to see if your coordinates are sane; i.e. do they actually
fall within your image? Are the file coordinates between zero and the
maximum number of lines or samples? Are your map coordinates in the
proper projection?

r
Re: subset an image by coordinates [message #68061 is a reply to message #68053] Mon, 21 September 2009 07:51 Go to previous message
Alvaro Paredes L. is currently offline  Alvaro Paredes L.
Messages: 5
Registered: September 2009
Junior Member
On 20 sep, 22:27, Jeremy Bailin <astroco...@gmail.com> wrote:
> On Sep 20, 1:00 pm, "Alvaro Paredes L." <alvaropared...@gmail.com>
> wrote:
>
>
>
>
>
>> On 20 sep, 10:24, Robert <robert.m...@gmail.com> wrote:
>
>>> On Sep 20, 8:12 am, Jeremy Bailin <astroco...@gmail.com> wrote:
>
>>>> On Sep 19, 11:14 pm, "Alvaro Paredes L." <alvaropared...@gmail.com>
>>>> wrote:
>
>>>> > Hi all
>
>>>> > I was searching on the web, but i didn't find an answer to my problem.
>>>> > I need to make asubseton animageusing
>
>>>> > coordinates, but i can't find a way to do it. I see this method
>
>>>> > http://groups.google.es/group/comp.lang.idl-pvwave/browse_fr m/thread/...
>>>> > and this other (very
>
>>>> > similar) http://www.mombu.com/programming/idl/t-subset-an-image-by-ro i-in-idl-...,
>>>> > but don't use
>
>>>> > coordinates, use an evf file.
>
>>>> > IDL/ENVI has a widget that use only two coordinates to cut (upper-left
>>>> > and lower-right coordinate), but it isn't
>
>>>> > fully automatically.
>
>>>> > Is there any function to cut theimagewith set coordinates and save
>>>> > it in a new file?
>
>>>> > I really hope you can help me... I'm not a programmer and this
>>>> > sometimes it's very hard
>
>>>> > Thanks!
>
>>>> > Alvaro
>
>>>> Do you mean like:
>
>>>> newimage = oldimage[x0:x1,y0:y1]
>
>>>> ?
>
>>>> -Jeremy.
>
>>> If the original author is looking tosubsetby map coordinates, he
>>> needs to use the procedure
>
>>> ENVI_CONVERT_FILE_COORDINATES, FID, XF, YF, XMap, YMap
>
>>> to convert the corners of hisimagein map coordinates to file
>>> coordinates. Once he has the proper file coordinates, he cansubset
>>> theimage. If you give us a little more specifics of what you are
>>> trying to do, we can probably provide more information.
>
>>> r
>
>> Thanks for the quickly help. I have animagewith degrees coordinates
>> and with the function that Robert suggested
>> (ENVI_CONVERT_FILE_COORDINATES) i can transform coord to pixel value
>> without problems (as the script i show below). But i try to do that
>> Jeremy suggest, but i don't know if is it properly working
>> (image=img_file[XF,YF]??)
>
>> forward_function ENVI_CONVERT_FILE_COORDINATES
>> proSUBSET
>> envi, /restore_base_save_files
>> envi_batch_init,log_file='batch.txt'
>
>> ; define theimageto be opened
>> img_file='F:\IMAGE\NDVI-HDF\try\NDVI_2008_03_02.img'
>> envi_open_file,img_file,r_fid=fid
>> print, 'fid=',fid
>
>> ; define coordinates to make thesubset
>> YMap=[-32.6030694, -32.9797194]
>> XMap=[-71.0580916, -70.5006694]
>
>> ENVI_CONVERT_FILE_COORDINATES, FID, XF, YF, XMap, YMap
>
>> ;rounds the pixel value to its closest integer.
>> XF=ROUND(XF)
>> YF=ROUND(YF)
>
>> ;verify the conversion
>> print, 'X pixel ',XF
>> print, 'Y pixel ',YF
>
>> ;making thesubset??????
>> image=img_file[XF,YF]
>
>> ; Exit Envi
>> envi_batch_exit
>> end
>
>> Finally, and maybe this is a basic question, how i save this "subset"
>> in a .img file?
>
>> Thanks!
>
>> Alvaro
>
> Note the colons in my example. :-)=  Instead of
>
>  image=img_file[XF,YF]
>
> you probably want:
>
>  image=img_file[XF[0]:XF[1], YF[0]:YF[1]]
>
> -Jeremy.

Well, thanks Jeremy. I tried to do what you say but i obtain this
error:
"Subscript range values of the form low:high must be >= 0, < size,
with low <= high: IMG_FILE."

I have verified the order min:max in [XF[0]:XF[1], YF[0]:YF[1]], and
try with manual input of pixels values, and isn't working... there's
something i'm doing bad... :(

Alvaro.
Re: subset an image by coordinates [message #68077 is a reply to message #68061] Sun, 20 September 2009 19:27 Go to previous message
Jeremy Bailin is currently offline  Jeremy Bailin
Messages: 618
Registered: April 2008
Senior Member
On Sep 20, 1:00 pm, "Alvaro Paredes L." <alvaropared...@gmail.com>
wrote:
> On 20 sep, 10:24, Robert <robert.m...@gmail.com> wrote:
>
>
>
>
>
>> On Sep 20, 8:12 am, Jeremy Bailin <astroco...@gmail.com> wrote:
>
>>> On Sep 19, 11:14 pm, "Alvaro Paredes L." <alvaropared...@gmail.com>
>>> wrote:
>
>>>> Hi all
>
>>>> I was searching on the web, but i didn't find an answer to my problem.
>>>> I need to make asubseton animageusing
>
>>>> coordinates, but i can't find a way to do it. I see this method
>
>>>> http://groups.google.es/group/comp.lang.idl-pvwave/browse_fr m/thread/...
>>>> and this other (very
>
>>>> similar) http://www.mombu.com/programming/idl/t-subset-an-image-by-ro i-in-idl-...,
>>>> but don't use
>
>>>> coordinates, use an evf file.
>
>>>> IDL/ENVI has a widget that use only two coordinates to cut (upper-left
>>>> and lower-right coordinate), but it isn't
>
>>>> fully automatically.
>
>>>> Is there any function to cut theimagewith set coordinates and save
>>>> it in a new file?
>
>>>> I really hope you can help me... I'm not a programmer and this
>>>> sometimes it's very hard
>
>>>> Thanks!
>
>>>> Alvaro
>
>>> Do you mean like:
>
>>> newimage = oldimage[x0:x1,y0:y1]
>
>>> ?
>
>>> -Jeremy.
>
>> If the original author is looking tosubsetby map coordinates, he
>> needs to use the procedure
>
>> ENVI_CONVERT_FILE_COORDINATES, FID, XF, YF, XMap, YMap
>
>> to convert the corners of hisimagein map coordinates to file
>> coordinates. Once he has the proper file coordinates, he cansubset
>> theimage. If you give us a little more specifics of what you are
>> trying to do, we can probably provide more information.
>
>> r
>
> Thanks for the quickly help. I have an image with degrees coordinates
> and with the function that Robert suggested
> (ENVI_CONVERT_FILE_COORDINATES) i can transform coord to pixel value
> without problems (as the script i show below). But i try to do that
> Jeremy suggest, but i don't know if is it properly working
> (image=img_file[XF,YF]??)
>
> forward_function ENVI_CONVERT_FILE_COORDINATES
> pro SUBSET
> envi, /restore_base_save_files
> envi_batch_init,log_file='batch.txt'
>
> ; define the image to be opened
> img_file='F:\IMAGE\NDVI-HDF\try\NDVI_2008_03_02.img'
> envi_open_file,img_file,r_fid=fid
> print, 'fid=',fid
>
> ; define coordinates to make the subset
> YMap=[-32.6030694, -32.9797194]
> XMap=[-71.0580916, -70.5006694]
>
> ENVI_CONVERT_FILE_COORDINATES, FID, XF, YF, XMap, YMap
>
> ;rounds the pixel value to its closest integer.
> XF=ROUND(XF)
> YF=ROUND(YF)
>
> ;verify the conversion
> print, 'X pixel ',XF
> print, 'Y pixel ',YF
>
> ;making the subset??????
> image=img_file[XF,YF]
>
> ; Exit Envi
> envi_batch_exit
> end
>
> Finally, and maybe this is a basic question, how i save this "subset"
> in a .img file?
>
> Thanks!
>
> Alvaro

Note the colons in my example. :-)= Instead of

image=img_file[XF,YF]

you probably want:

image=img_file[XF[0]:XF[1], YF[0]:YF[1]]


-Jeremy.
Re: subset an image by coordinates [message #68082 is a reply to message #68077] Sun, 20 September 2009 10:00 Go to previous message
Alvaro Paredes L. is currently offline  Alvaro Paredes L.
Messages: 5
Registered: September 2009
Junior Member
On 20 sep, 10:24, Robert <robert.m...@gmail.com> wrote:
> On Sep 20, 8:12 am, Jeremy Bailin <astroco...@gmail.com> wrote:
>
>
>
>
>
>> On Sep 19, 11:14 pm, "Alvaro Paredes L." <alvaropared...@gmail.com>
>> wrote:
>
>>> Hi all
>
>>> I was searching on the web, but i didn't find an answer to my problem.
>>> I need to make asubseton animageusing
>
>>> coordinates, but i can't find a way to do it. I see this method
>
>>> http://groups.google.es/group/comp.lang.idl-pvwave/browse_fr m/thread/...
>>> and this other (very
>
>>> similar) http://www.mombu.com/programming/idl/t-subset-an-image-by-ro i-in-idl-...,
>>> but don't use
>
>>> coordinates, use an evf file.
>
>>> IDL/ENVI has a widget that use only two coordinates to cut (upper-left
>>> and lower-right coordinate), but it isn't
>
>>> fully automatically.
>
>>> Is there any function to cut theimagewith set coordinates and save
>>> it in a new file?
>
>>> I really hope you can help me... I'm not a programmer and this
>>> sometimes it's very hard
>
>>> Thanks!
>
>>> Alvaro
>
>> Do you mean like:
>
>> newimage = oldimage[x0:x1,y0:y1]
>
>> ?
>
>> -Jeremy.
>
> If the original author is looking tosubsetby map coordinates, he
> needs to use the procedure
>
> ENVI_CONVERT_FILE_COORDINATES, FID, XF, YF, XMap, YMap
>
> to convert the corners of hisimagein map coordinates to file
> coordinates. Once he has the proper file coordinates, he cansubset
> theimage. If you give us a little more specifics of what you are
> trying to do, we can probably provide more information.
>
> r

Thanks for the quickly help. I have an image with degrees coordinates
and with the function that Robert suggested
(ENVI_CONVERT_FILE_COORDINATES) i can transform coord to pixel value
without problems (as the script i show below). But i try to do that
Jeremy suggest, but i don't know if is it properly working
(image=img_file[XF,YF]??)


forward_function ENVI_CONVERT_FILE_COORDINATES
pro SUBSET
envi, /restore_base_save_files
envi_batch_init,log_file='batch.txt'

; define the image to be opened
img_file='F:\IMAGE\NDVI-HDF\try\NDVI_2008_03_02.img'
envi_open_file,img_file,r_fid=fid
print, 'fid=',fid

; define coordinates to make the subset
YMap=[-32.6030694, -32.9797194]
XMap=[-71.0580916, -70.5006694]

ENVI_CONVERT_FILE_COORDINATES, FID, XF, YF, XMap, YMap

;rounds the pixel value to its closest integer.
XF=ROUND(XF)
YF=ROUND(YF)

;verify the conversion
print, 'X pixel ',XF
print, 'Y pixel ',YF

;making the subset??????
image=img_file[XF,YF]

; Exit Envi
envi_batch_exit
end

Finally, and maybe this is a basic question, how i save this "subset"
in a .img file?

Thanks!

Alvaro
Re: subset an image by coordinates [message #68083 is a reply to message #68082] Sun, 20 September 2009 07:24 Go to previous message
Robert Moss, PhD is currently offline  Robert Moss, PhD
Messages: 29
Registered: November 2006
Junior Member
On Sep 20, 8:12 am, Jeremy Bailin <astroco...@gmail.com> wrote:
> On Sep 19, 11:14 pm, "Alvaro Paredes L." <alvaropared...@gmail.com>
> wrote:
>
>
>
>> Hi all
>
>> I was searching on the web, but i didn't find an answer to my problem.
>> I need to make a subset on an image using
>
>> coordinates, but i can't find a way to do it. I see this method
>
>> http://groups.google.es/group/comp.lang.idl-pvwave/browse_fr m/thread/...
>> and this other (very
>
>> similar) http://www.mombu.com/programming/idl/t-subset-an-image-by-ro i-in-idl-...,
>> but don't use
>
>> coordinates, use an evf file.
>
>> IDL/ENVI has a widget that use only two coordinates to cut (upper-left
>> and lower-right coordinate), but it isn't
>
>> fully automatically.
>
>> Is there any function to cut the image with set coordinates and save
>> it in a new file?
>
>> I really hope you can help me... I'm not a programmer and this
>> sometimes it's very hard
>
>> Thanks!
>
>> Alvaro
>
> Do you mean like:
>
> newimage = oldimage[x0:x1,y0:y1]
>
> ?
>
> -Jeremy.

If the original author is looking to subset by map coordinates, he
needs to use the procedure

ENVI_CONVERT_FILE_COORDINATES, FID, XF, YF, XMap, YMap

to convert the corners of his image in map coordinates to file
coordinates. Once he has the proper file coordinates, he can subset
the image. If you give us a little more specifics of what you are
trying to do, we can probably provide more information.

r
Re: subset an image by coordinates [message #68086 is a reply to message #68083] Sun, 20 September 2009 05:12 Go to previous message
Jeremy Bailin is currently offline  Jeremy Bailin
Messages: 618
Registered: April 2008
Senior Member
On Sep 19, 11:14 pm, "Alvaro Paredes L." <alvaropared...@gmail.com>
wrote:
> Hi all
>
> I was searching on the web, but i didn't find an answer to my problem.
> I need to make a subset on an image using
>
> coordinates, but i can't find a way to do it. I see this method
>
> http://groups.google.es/group/comp.lang.idl-pvwave/browse_fr m/thread/...
> and this other (very
>
> similar) http://www.mombu.com/programming/idl/t-subset-an-image-by-ro i-in-idl-...,
> but don't use
>
> coordinates, use an evf file.
>
> IDL/ENVI has a widget that use only two coordinates to cut (upper-left
> and lower-right coordinate), but it isn't
>
> fully automatically.
>
> Is there any function to cut the image with set coordinates and save
> it in a new file?
>
> I really hope you can help me... I'm not a programmer and this
> sometimes it's very hard
>
> Thanks!
>
> Alvaro

Do you mean like:

newimage = oldimage[x0:x1,y0:y1]

?

-Jeremy.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Structure
Next Topic: structure

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

Current Time: Wed Oct 08 17:36:16 PDT 2025

Total time taken to generate the page: 0.00769 seconds