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.
|