Re: Locate pixels that fall within other pixel-geo search [message #72456 is a reply to message #72451] |
Thu, 09 September 2010 13:41  |
rogass
Messages: 200 Registered: April 2008
|
Senior Member |
|
|
On 9 Sep., 22:07, Snow53 <jennifer_wa...@hotmail.com> wrote:
> Hi,
>
> I have two images with slightly different dimensions, but the same
> projection. Image 1 has coarse resolution. Image 2 has fine
> resolution.
>
> For each coarse pixel in Image 1, I need to find all fine resolution
> pixels that fall within that pixel (based on the condition that they
> fall within the same geographic extent of that coarse pixel).
>
> I'm reading in the file with envi_open_file, so the files should have
> all the geographic info needed.
>
> Has anyone done something similar? Could anyone suggest a good way to
> do this selection?
>
> Thanks!
Maybe you can use this routine or some ideas frome it:
function cr_get_tiles,im, wx,wy
s = size(im,/dimensions)
;l = make_array(s,/index,/ulong)
run1 = 0l
run2 = 0l
tilex = round((s[0] - (s[0] mod wx))/wx)
tilexpart = round(float(s[0] mod wx)/wx)
tilex += tilexpart
tiley = round((s[1] - (s[1] mod wy))/wy)
tileypart = round(float(s[1] mod wy)/wy)
tiley += tileypart
; tiley = round((s[1] - (s[1] mod wy))/wy + float(s[1]
mod wy)/wy)
newim = make_array([wx,wy,s[2],tilex*tiley],type=size(im,/
type))
for i=0l, tilex-1l do begin
for j=0l, tiley-1l do begin
if i eq (tilex-1l) && tilexpart gt 0 then $
newim[0: s[0]-i*wx-1l ,*,*,run1] = im[i*wx:*,j*wy:((j
+1l)*wy)-1l,*] else $
if j eq (tiley-1l) && tileypart gt 0 then $
newim[*,0:s[1]-j*wy-1l,*,run1] = im[i*wx:((i
+1l)*wx)-1l,j*wy:*,*] else $
newim[*,*,*,run1] = im[i*wx:((i+1l)*wx)-1l,j*wy:((j+1l)*wy)-1l,*]
run1++
endfor
endfor
undefine, im
return, newim
end
wx and wy is the ratio between coarse and fine image.
Hope it helps
CR
|
|
|