How to create an average spectrum from several points in hyperspectral image

9 views (last 30 days)
I am doing analysis of hyperspectral images, and I want to make a plot of an average spectrum from my image. I have data from several points (ideally I want 20 points), and want to calculate the average spectrum. I use impoint and getPosition to store coordinates, like this:
s1 = impoint;
s1_pos = floor(getPosition(s1));
s2 = impoint;
s2_pos = floor(getPosition(s2));
s3 = impoint;
s3_pos = floor(getPosition(s3));
and then I get the spectrums from each point like this:
d1 = squeeze(img(:,s1_pos(1),s1_pos(2)));
d2 = squeeze(img(:,s2_pos(1),s2_pos(2)));
d3 = squeeze(img(:,s3_pos(1),s3_pos(2)));
This is all reflectance data and I want to plot it against wavelength.

Answers (1)

Image Analyst
Image Analyst on 9 Jun 2014
So what's the problem? Just sum up, divide by 3 and call plot().
meanSpectrum = (d1+d2+d3)/3;
plot(meanSpectrum);

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!