Merging different color channels

4 vues (au cours des 30 derniers jours)
Mustapha Seidu
Mustapha Seidu le 17 Août 2021
Commenté : Bjorn Gustavsson le 17 Août 2021
Hi, is it possible to merge color channels from different color spaces to sort of form a new 3-dimensional image for the purpose of analysis?
For example, I am trying to extract channels L, G, and V from CIELAB, RGB, and HSV respectively and merge them before proceeding to perform further manipulations to the image. Is that possible? If not, what is the closest I can get to that?

Réponses (1)

Bjorn Gustavsson
Bjorn Gustavsson le 17 Août 2021
Sure, they are after all nothing but 2-D arrays representing different aspects of an image. Just combine them any which way you see fit. Make sure that you have the different channels in compatible types such that you don't lose precision (convert to double etc).
  2 commentaires
Mustapha Seidu
Mustapha Seidu le 17 Août 2021
Thank you very much @Bjorn Gustavsson.
I tried using cat(3,channel1,channel2,channe3) but it seems to be inacccurately merged since Value(V) from HSV ranges from 0 to 1 while the others range from 0 to 256.
After merging and viewing the individual channels from the merged image, the V happens to be totally dark unlike its original form before merging.
Bjorn Gustavsson
Bjorn Gustavsson le 17 Août 2021
That's the problem I hinted at with my caution about "compatible types" - it seems like your HSV-image are in double format normalized to the 0 - 1 range while the others are uint8 in the range 0 - 255. Simply cast the L and G channels to doubles and scale them to 0 - 1:
L = double(L);
L = (L - min(L(:)))/(max(L(:))-min(L(:)));
% or simpler:
L = normalize(L,'range'); % I'm too old to remember this function
Then you can do the same for G, typically also check the data-type using whos and the range of the intensities using max and min.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Convert Image Type dans Help Center et File Exchange

Produits


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by