Envi band math help! [message #35728] |
Fri, 11 July 2003 03:09  |
gauravjn123
Messages: 7 Registered: July 2003
|
Junior Member |
|
|
Hi!
I have this strange problem...i have written one band math function
to print the band value at the location 30,30 but it doesnt work. And
the same function if written for location 4,4 ...works fine! Here are
the functions:
1.function example,b1
help,b1
print,b1(30,30)
end
2.function example,b1
help,b1
print,b1(4,4)
end
And strangely enuf...in the second example, the value b1(4,4)
is printed 4 times & the value printed final time is the right
value. The help command outputs that the array is of size[5,5] in the
initial 3 times. Only after that in the final turn does it output the
right dimesnions that is 608*673
Could anyone please enlighten me....it has been bugging me for many
days!
Thnx in advance
Gaurav
|
|
|
Re: Envi band math help! [message #35809 is a reply to message #35728] |
Mon, 14 July 2003 21:29  |
tianyf_cn
Messages: 19 Registered: November 2002
|
Junior Member |
|
|
Hi,
Do you want to get the spectral values of a specified points?
If your image is not too larege, you can read the image into memory
and then get the values. If you want values of only one point, it
seems not a very good choice. The procedure may be like those:
;
;Example:
; x=getpoint('c:\test.raw',10,35)
; print,x
;
;pro getpoint, fname, x, y
function getpoint, fname, x, y
;
;Check file name
if n_elements(fname) eq 0 then begin
envi_select,fid=fid,dims=dims,pos=pos
if fid eq -1 then return,-1
endif
;
;Check x,y values
if n_elements(x) eq 0 then x=0 ;IDL array start from 0, NOT 1.
if n_elements(y) eq 0 then y=0
;
;Query the data type for definition of array holding the data.
envi_file_query,fid,data_type=dt
;
data=make_array(dims(2)+1,dims(4)+1,n_elements(pos),type=dt)
;
;Read the data one band each time
;ENVI_GET_BAND can read only one band data.
; If you want use IDL functions, the readu can be a good choice.
; But additional information shoud be need.
;
for bi=0,n_elements(pos)-1 do begin
data(*,*,bi)=envi_get_data(fid=fid,pos=pos(bi),dims=dims)
;If you want to get values of one point, you can set dims to
; dims=[-1,x,x,y,y]
;This is useful when your images is too large to read into memory.
endfor
;
help,data
;
;print,data(x,y,*)
return,reform(data(x,y,*))
;
end
Is this what you want?
Tian.
gauravjn123@yahoo.co.in (Gaurav) wrote in message news:<d193b5fb.0307141212.942053d@posting.google.com>...
> Hi!
> Well even i had felt the same...And therefore i also tried to use a
> procedure to output those pixel values...but unfortunately i was not
> able to use the envi widgets to input the five bands in an image...so
> i reverted back to band math functions for it.
> If it is not possible to output a single pixel value using
> functions, could you please tell me how to input the band values using
> a procedure (Could you please give me a sample procedure to input 5
> bands in an image)
> Thanking you in advance.
>
> Gaurav Jain
> ENST-Bretagne
>
|
|
|