Correlation between bands using IDL [message #72056] |
Tue, 03 August 2010 02:30  |
Lavanya
Messages: 7 Registered: August 2010
|
Junior Member |
|
|
Hi,
I am pretty much new in using IDL. I have been trying to read
multiband image data using envi_select and envi_file_query, where i
get the information about the data im using.
Now how could i find the correlation between any two bands (here the
number of bands i have is 242)
Finally i need to generate a output correlation matrix of 242 * 242.
Please help me how can i go about.
Thanks
|
|
|
Re: Correlation between bands using IDL [message #72139 is a reply to message #72056] |
Thu, 05 August 2010 23:05   |
Lavanya
Messages: 7 Registered: August 2010
|
Junior Member |
|
|
On Aug 5, 12:25 pm, chris <rog...@googlemail.com> wrote:
> On 5 Aug., 07:10, Lavanya <lavany...@gmail.com> wrote:
>
>
>
>> On Aug 4, 11:49 am, chris <rog...@googlemail.com> wrote:
>
>>> On 3 Aug., 11:30, Lavanya <lavany...@gmail.com> wrote:
>
>>>> Hi,
>
>>>> I am pretty much new in using IDL. I have been trying to read
>>>> multiband image data using envi_select and envi_file_query, where i
>>>> get the information about the data im using.
>>>> Now how could i find the correlation between any two bands (here the
>>>> number of bands i have is 242)
>>>> Finally i need to generate a output correlation matrix of 242 * 242.
>>>> Please help me how can i go about.
>
>>>> Thanks
>
>>> Hi,
>>> i don't understand what you want to do. Do you want to correlate
>>> pixel1 band1 with pixel2 band2, pixel1 band1 with pixel2 band3 and so
>>> on for all pixel and bands?
>
>>> Regards Chris
>
>> I wanted to find the correlation between
>> band1 band2, band1 band 3, band 1 band 4
>> band 2 band 1, band 2 band 3, band 2 band 4 and so on. Final result
>> should be of the matrix form n * n where n will be the number of bands
>> of the same image. Here i am using only one image which has 'n' bands
>
>> Please help
>
>> -Lavanya
>
> Ok, as far as I understand you want to compute the Band-To-Band
> correlations. You could do this (not vectorized) in this way:
>
> IDL> n=242l
> IDL> image_size_x=10
> IDL> image_size_y=10
> IDL> image=randomn(seed,image_size_x,image_size_y,n)
> IDL> l=lindgen(n,n) mod n
> IDL> xind=l[*]
> IDL> yind=(temporary(transpose(l)))[*]
> IDL> corr=fltarr(n,n)
> IDL> for i=0l,(n*n)-1l do corr[i] = correlate((image[*,*,xind[i]])[*],
> (image[*,*,yind[i]])[*])
> IDL> corr=reform(corr,n,n,/over)
> IDL> tvscl, corr
>
> Hope it helps
>
> CR
Thank you so much for the reply. Again im facing an error while i was
trying to execute with two bands of size 4980*4200 pixels and getting
a correlation matrix of 2*2.
Here the code below. Please help
image1 = READ_TIFF('\Program Files\ITT\IDL70\examples\data
\image_band1.tif')
image2 = READ_TIFF('\Program Files\ITT\IDL70\examples\data
\image_band2.tif')
n=2
l=lindgen(n,n) mod n
xind=l[*]
yind=(temporary(transpose(l)))[*]
corr=fltarr(n,n)
for i=0l,(n*n)-1l do corr[i] = correlate((image1[*,*,xind[i]])[*], $
(image2[*,*,yind[i]])[*])
corr=reform(corr,n,n,/over)
help, corr
print, corr
END
|
|
|
Re: Correlation between bands using IDL [message #72287 is a reply to message #72139] |
Thu, 26 August 2010 01:04  |
rogass
Messages: 200 Registered: April 2008
|
Senior Member |
|
|
On 6 Aug., 08:05, Lavanya <lavany...@gmail.com> wrote:
> On Aug 5, 12:25 pm, chris <rog...@googlemail.com> wrote:
>
>
>
>
>
>> On 5 Aug., 07:10, Lavanya <lavany...@gmail.com> wrote:
>
>>> On Aug 4, 11:49 am, chris <rog...@googlemail.com> wrote:
>
>>>> On 3 Aug., 11:30, Lavanya <lavany...@gmail.com> wrote:
>
>>>> > Hi,
>
>>>> > I am pretty much new in using IDL. I have been trying to read
>>>> > multiband image data using envi_select and envi_file_query, where i
>>>> > get the information about the data im using.
>>>> > Now how could i find thecorrelationbetween any two bands (here the
>>>> > number of bands i have is 242)
>>>> > Finally i need to generate a outputcorrelationmatrixof 242 * 242.
>>>> > Please help me how can i go about.
>
>>>> > Thanks
>
>>>> Hi,
>>>> i don't understand what you want to do. Do you want to correlate
>>>> pixel1 band1 with pixel2 band2, pixel1 band1 with pixel2 band3 and so
>>>> on for all pixel and bands?
>
>>>> Regards Chris
>
>>> I wanted to find thecorrelationbetween
>>> band1 band2, band1 band 3, band 1 band 4
>>> band 2 band 1, band 2 band 3, band 2 band 4 and so on. Final result
>>> should be of thematrixform n * n where n will be the number of bands
>>> of the same image. Here i am using only one image which has 'n' bands
>
>>> Please help
>
>>> -Lavanya
>
>> Ok, as far as I understand you want to compute the Band-To-Band
>> correlations. You could do this (not vectorized) in this way:
>
>> IDL> n=242l
>> IDL> image_size_x=10
>> IDL> image_size_y=10
>> IDL> image=randomn(seed,image_size_x,image_size_y,n)
>> IDL> l=lindgen(n,n) mod n
>> IDL> xind=l[*]
>> IDL> yind=(temporary(transpose(l)))[*]
>> IDL> corr=fltarr(n,n)
>> IDL> for i=0l,(n*n)-1l do corr[i] = correlate((image[*,*,xind[i]])[*],
>> (image[*,*,yind[i]])[*])
>> IDL> corr=reform(corr,n,n,/over)
>> IDL> tvscl, corr
>
>> Hope it helps
>
>> CR
>
> Thank you so much for the reply. Again im facing an error while i was
> trying to execute with two bands of size 4980*4200 pixels and getting
> acorrelationmatrixof 2*2.
> Here the code below. Please help
>
> image1 = READ_TIFF('\Program Files\ITT\IDL70\examples\data
> \image_band1.tif')
> image2 = READ_TIFF('\Program Files\ITT\IDL70\examples\data
> \image_band2.tif')
>
> n=2
> l=lindgen(n,n) mod n
> xind=l[*]
> yind=(temporary(transpose(l)))[*]
> corr=fltarr(n,n)
> for i=0l,(n*n)-1l do corr[i] = correlate((image1[*,*,xind[i]])[*], $
> (image2[*,*,yind[i]])[*])
> corr=reform(corr,n,n,/over)
> help, corr
> print, corr
> END
Ok, sorry for delay - holidays...
Correct me if I'm wrong. As far as I understood you have 2 images
sized x,y,z where z are the bands. Now do you want to get a
correlation matrix (for what)?
Case 1: a correlation between pixel x0,y0,all z from image 1 and pixel
x0,y0,all z from image 2 - store correlation in corr[0,0] and then the
next pixel?
Case 2: a correlation between pixel x0,y0,z0 form image 1 and pixel
x0,y0,z1 form image 2 - store correlation in
corr[0,0,n_correlations[0]] and then for all band combinations and
pixels
Case x:
Pls, describe it in more detail, then i'm able and willing to help.
Regards
CR
|
|
|