Borrar filtros
Borrar filtros

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

3 visualizaciones (últimos 30 días)
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?

Respuesta aceptada

Parth Parikh
Parth Parikh el 21 de Mzo. de 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:

Más respuestas (0)

Categorías

Más información sobre Hyperspectral Image Processing en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by