How to apply the outlines defined by superpixels to a hyperspectral image to calculate the mean spectrum of each superpixel?

3 次查看(过去 30 天)
I have applied the function superpixels to extract the outlines of several pixels wich have similar colour within an RGB image. Now I want to apply these outlines to the original hypercube to obtain the mean spectrum for each of these superpixels. Can you help me?

采纳的回答

Parth Parikh
Parth Parikh 2023-3-21
Hi Laura,
Here is the code you can try:
Suppose you have number of labels (N) and label matrix (L) from superpixels function.
[rows, cols, channels] = size(hypercube);
hypercube = reshape(hypercube, [rows*cols channels]);
idx = label2idx(L);
outputImg = zeros(rows*cols, channels);
for labelVal = 1:N
idxs = idx{labelVal};
outputImg(idxs, :) = repmat(mean(hypercube(idxs,:)), length(idxs),1);
end
outputImg = reshape(outputImg, [rows, cols, channels]);
I am assuming instead of taking mean in spatial dimension, you would like to take a mean of spectral dimension.
If you would like to explore more about the hyperspectral domain, kindly go through this:

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Hyperspectral Image Processing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by