Orange has a hyperspectral dataset called "liver cirrhosis" and you can visualize the hyperspectral image using the hyperspectral image widget. However, I would like to perform various clustering methods e.g. k-means on the spectra at each pixel and then display those clusters on the hyperspectral image widget like in this photo enter image description here

does anyone know how to do this kind of analysis?


1 Answer 1


As a first step, You can take the table of measurements as-is, run k-means on all the columns representing intensities.

In the image, I see pixels in 5 colors (red, orange, green, azure, magenta), so the author of the top image has decided to run k-means with k=5 clusters. (k in in k-means is often chosen to be an odd number)

To get a clearer signal, people often run preprocessing steps such as Principal Components analysis (PCA) on their datasets before running k-means, and then choose the first, say, 10 components (should be larger than 5). Then people run k-means on those 10 columns.

Choosing the number of components to calculate k from, and then choosing a value for k, is basically guesswork, at least initially.

It is also guesswork to assign colors to cluster numbers found by the k-means algorithm. So you probably have to set a lookup table manually, in another preprocessing step, such as { 1 => "red". 2 => "azure", 3 => "limegreen" 4 => "yellow", 5 => "orange" }. And then make an x-y plot coloring the pixels accordingly. The sequence is arbitrary.

Sorry, I don't know how to do this in Orange.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.