X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 03 Nov 2006 07:35 AM by  anon
Comparing Pixel Values in Images w/IDL
 1 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
03 Nov 2006 07:35 AM
    I'd like to apologize if this is a simple question, but I am new to IDL and haven't had a lot of experience with it yet. I have some GeoTIFF files created in ENVI (georeferenced MODIS imagery that has been exported as GeoTIFF files) that I need to compare with one another to see if there is snow cover in some and not others. The images are georeferenced and have common points, but do not have the same dimensions or same complete coverage areas. So, I think I need to find a way to have IDL read them in and tell me the pixel value at specific lat/long points common in each image so I can see how the albedo is changing (the images are taken over a range of time). Could anyone help me out as to how to go about this? Thank you very much! ~Tanya

    Deleted User



    New Member


    Posts:
    New Member


    --
    03 Nov 2006 07:35 AM
    There are probably many different ways to compare 2 pixel values of 2 different images using their map coordinates. Here is an example using some ENVI programming routines. If you could build a similar code to read your 2 different tiff images thus you would be able to compare the pixel values that correspond to a same map location. ********************************************************************************************************** PRO example ; This example is built using an image of the ENVI distribution, that had been first exported ; to a GEOTIFF image using ENVI: C:\RSI\IDL63\products\envi43\data\bhdemsub.img fname =dialog_pickfile() ; open the TIFF/GEOTIFF file envi_open_data_file, fname, /tif, r_fid=fid if (fid eq -1) then RETURN ; Query and print the dims, ns, nl, and nb ENVI_FILE_QUERY, fid, dims=dims ,ns=ns, nl=nl, nb=nb print, "dimensions = ", ns, nl, nb ; Retrieve the data (values of each pixel) in the array called “data” data = ENVI_GET_DATA(fid=fid, dims=dims, pos=0) ; Retrieve the map information: it returns a structure with all the different map information map_info = envi_get_map_info(fid=fid) print,'map_info structure' help,map_info,/struct ; The size of the pixel (resolution) is saved in the map_info.ps array of the structure X_px_size=map_info.ps[0] Y_px_size= map_info.ps[1] ; The latitude and longitude of the reference point is saved in the map_info.mc array: ; The 2 first components of this array are the pixel locations of the point ; (0,0) in this example ; The 2 other components correspond to the longitude and latitude of this point min_lon=(map_info.mc)[2] max_lat=(map_info.mc)[3] ; using the previous information it is possible to calculate the maximum longitude ; and the minimum latitude max_lon= min_lon + X_px_size*(ns-1) min_lat= max_lat - Y_px_size*(nl-1) ; Now it is possible to retrieve the pixel value of a point identified by its latitude ; and its longitude ; example with the 2 following points lat_list=[4905171.20d,4895481.20d] lon_list=[277408.57d, 287968.57d] ; First it is necessary to calculate the corresponding pixel position X_px_pos= (lon_list-min_lon) / X_px_size Y_px_pos = (max_lat-lat_list) / Y_px_size ; thus it is possible to retrieve the pixel values using the pixel positions value=data[X_px_pos,Y_px_pos ] PRINT,'pixel value = ',value END
    You are not authorized to post a reply.