the position of the pixel in 3 dimensional array [message #69221] |
Tue, 29 December 2009 10:00  |
Hassan
Messages: 48 Registered: October 2009
|
Member |
|
|
Hi,
I used the folloing command to get a one-dimensional array:
pos_g0=where(image gt 0)
now, I have a pixel that know the value in three positions of
[388,168,13],[388,168,33,[388,168,48]] ([column,row,band]) and want to
work out the location of pixel in the pos_g0 which is in 3 locations.
I used the following commands but the results isn't correct.
;make a vector which keeps the position of the desired pixel in pos_g0
array in 3 locations
pixel_pos=[0,0,0]
for i=0l,n_elements(pos_g0)-1 do begin&
ai=array_indices(ref1,pos_g0[i])&
if (ai[0] eq 388 and ai[1] eq 168 and ai[2] eq 13) then begin &
pixel_pos[0]=i&
endif&
else begin&
if (ai[0] eq 388 and ai[1] eq 168 and ai[2] eq 33) then &
pixel_pos[1]=i&
if (ai[0] eq 388 and ai[1] eq 168 and ai[2] eq 48) then &
pixel_pos[2]=i&
endelse&
endfor
|
|
|
Re: the position of the pixel in 3 dimensional array [message #69355 is a reply to message #69221] |
Sun, 03 January 2010 12:20  |
rogass
Messages: 200 Registered: April 2008
|
Senior Member |
|
|
On 29 Dez. 2009, 19:00, Hassan <hkhav...@gmail.com> wrote:
> Hi,
>
> I used the folloing command to get a one-dimensional array:
> pos_g0=where(image gt 0)
Now you have a index list of all pixels greater than zero.
> now, I have a pixel that know the value in three positions of
> [388,168,13],[388,168,33,[388,168,48]] ([column,row,band]) and want to
> work out the location of pixel in the pos_g0 which is in 3 locations.
I don't understand this part. Do you mean that you want to check
whether the pixels stored in you pos_g0 list match the three points or
what? If this is the case why not:
ra = make_array(size(ref1,/dimensions),/index)
list = [ra[388,168,13],ra[388,168,33],ra[388,168,48]]
pos_g0=where(image gt 0,cnt)
llist =rebin(list,3,cnt)
pixel_pos=[where(pos_g0-llist[0,*] eq 0),where(pos_g0-llist[1,*] eq
0),where(pos_g0-llist[2,*] eq 0)]
Hope it helps somehow, it wa not tested...
Regards
CR
|
|
|