how to convert from grayscale to rgb by lightness method ??
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hanan Elsayed
il 24 Ago 2021
Commentato: Hanan Elsayed
il 24 Ago 2021
how to convert from grayscale to rgb by lightness (desaturation) method (matlab code)??
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/720099/image.png)
2 Commenti
Risposta accettata
Turlough Hughes
il 24 Ago 2021
Modificato: Turlough Hughes
il 24 Ago 2021
You can do the following:
I=imread('peppers.png');
newImage = uint8(( double(min(I,[],3)) + double(max(I,[],3)) ) ./ 2);
imshow(newImage)
5 Commenti
Turlough Hughes
il 24 Ago 2021
Thanks @Image Analyst. I should have converted to a datatype not capped at 255 in order to add the values. I've edited the answer with the correction.
Actually, one could also just do the following without converting datatypes:
I=imread('peppers.png');
newImage = min(I,[],3)./2 + max(I,[],3)./2;
imshow(newImage)
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Image Processing Toolbox in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!