How do I compare the intensity vs wavelength( lambda 1,2,3,4,5 upto n ; a total of 97 bands) at a particular pixel between two(or more) hyperspectral images?
You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Show older comments
Using Matlab R2013a ; I am working on hyperspectral images from a Specim camera (600-925nm) ; images are in the .raw format (bil raster) I use the following command to read the file C0.raw
A=multibandread('C0.raw',[1952,2048,97],'uint16',0,'bil','ieee-le',{'Band','Direct',[601,710,800,905]})
just like C0.raw I have ten other images ( C1,C2,C3,C4...)
Id like to know how to compare the spectral response(in terms of intensity) of a pixel say p(970,1051) at the four bands(601,710,800,905nm). Also the same comparison between multiple images at the same pixel. How can this be done? Any ideas?
I use this to visualise the data( and it does so correctly)
Min_val = min(min(min(A)))
Max_val = max(max(max(A)))
imshow(A(:,:,4),[Min_val Max_val])
I try to use plot(A(970,1051,:)) But it doesnt work out.
Accepted Answer
Image Analyst
on 5 Jan 2014
You have to know what element those wavelengths occur at. Maybe it's elements 20, 42, 61, and 81. So then you just extract those:
intensityAt601 = p(970,1051, 20);
intensityAt710 = p(970,1051, 42);
intensityAt800 = p(970,1051, 61);
intensityAt905 = p(970,1051, 81);
Then for the second image, use p2 or whatever you called that image.
10 Comments
Sindhuraj
on 5 Jan 2014
Edited: Image Analyst
on 5 Jan 2014
The nature of my problem,requires me to find out which at which wavelengths the same pixel's intensity differs when comparing multiple images.
Which means, that the elements you talk about (i.e. wavlengths 20,42,61,81) are not my concern at the moment. Main concern is how to plot the comparison of intensity vs wavelenghts(assuming wavelengths to be 601,710,800,905) for the same pixel on different images.
I am unable to figure out exactly what codes/commands/functions to use for the same.
Hang on,what do you mean by elements 20,42,61,81 here? Are they the wavelengths or are they the series of wavelengths (like the numerical order, since there are 97 bands) Thank you in advance
They are your spectral planes. Let's say your image is 1952 rows by 2048 columns by 97 spectral channels. Well, which one of the 97 spectral channels corresponds to wavelength 710? You should know that.
To get all wavelengths, jsut extract all, then plot
spectrum1 = p1(970,1051, :);
spectrum2 = p2(970,1051, :);
plot(spectrum1, 'r-', 'LineWidth', 3);
hold on;
plot(spectrum2, 'b-', 'LineWidth', 3);
grid on;
Cool,thanks,still having trouble implementing the instructions. However,I came across a matlab function called cubeviewer,that does the job of pixel intensity response pretty nicely,for a selected cube.
Well what is your image array called? Why can't you just give : as the third index and get the value of every spectral channel? I don't see why there should be any difficulty.
Ive done that i.e. for say pixel(970,1051) ; array A ; i passed multibandread to store the .raw file into the array A ; for Row,Range [500 600], Column,Range [500 600] the cube gets stored as [101,101,97] where 97=number of bands ;
you suggested storing intensity value of A(970,1051,20) assuming 20=nth band of interest.similarly for n=21.....97.
when i give the plot command,the graph that comes up is blank. I think,I shall have to make a loop for trying all the bands i.e. assuming A(i,j,k) where k=bands from k=1 to 97,plot A(970,1051,k).
Not sure of the exact syntax to make the plotting loop.
No you don't. You don't need a loop. You don't understand that using colon : in place of an index means to take all. Color = "all". So to get all the sprectrum values at row 12 and column 42, you'd do
spectrum = A(12, 42, :); % Extracts 97 values. spectrum is 97 by 1 vector.
First of all,thanks,am new to Matlab,and the silly things can seem difficult at first :) btw,I do know that i,j,k stands for the (row,column,band)
okay,extracted the values for all the bands at A(12,42) successfully. when I plot(spectrum), matlab returns " Error using plot Data may not have more than 2 dimensions " Obviously,because spectrum(1x1x97) So I pass X=squeeze(spectrum) and then plot(X). It shows the graph where X axis represents the band and the Y axis represents I assume intensity (because,value on the Y axis range from 20 to 65)I thought the intensity value range from 0 to 1.
When comparing multiple cubes, I assume the commands subplot and hold on are involved?
You use subplot if you want a bunch of plots arrayed in a grid. If you want all the plots on the same plot, don't use subplot and use hold on to plot them all in the same plot.
Works like a charm! Much Thanks!
ALINA
on 25 Jan 2014
hi sindhuraj, can you show the code you have written.Since i am not able to retrive the spectral plot inspite of the code i wrote.Kindly please help.
More Answers (0)
Categories
Find more on Hyperspectral Image Processing in Help Center and File Exchange
Products
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)