How to apply the outlines defined by superpixels to a hyperspectral image to calculate the mean spectrum of each superpixel?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Laura
am 19 Mär. 2023
Kommentiert: Laura
am 21 Mär. 2023
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?
0 Kommentare
Akzeptierte Antwort
Parth Parikh
am 21 Mär. 2023
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:
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Hyperspectral Image Processing finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!