フィルターのクリア

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 Center および File ExchangeHyperspectral Image Processing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by