Conversion from HSV to RGB
显示 更早的评论
Good afternoon,
I had to reproduce a "scotoma" condition on an image.
To do so I converted my RGB image to the HSV space, applied a gaussian bynary mask to the v channel and then reconverted from the HSV space to the RGB space. Here is the code:
A = imread('lena .bmp');
%conversion from RGB to HSV space
HSV = rgb2hsv(A);
%separation of the channels
[h,s,v] = imsplit(HSV);
%creation of the gaussian mask and application to the v channel
[r,c,~] = size(v);
[X Y] = meshgrid(1:r,1:c);
Z = mvnpdf([X(:) Y(:)], [r c]./2, diag(500.*[r c])); %maschera gaussiana
Z = (Z-min(Z(:)))./range(Z(:));
Z = reshape(Z',[c r])';
Z_gauss = 1-Z;
%reconstruction of the image
HSV_new = cat(3,h,s,Z_gauss); %immagine hsv dopo il filtraggio con la gaussiana
%conversion from HSV to RGB space
RGB_new = hsv2rgb(HSV_new);
figure
imshow(RGB_new)
By confronting the original RGB image with the modified one as shown below, I noticed that in the second image colors are not the same as the original image.
What I'd like to know is if this is a consequence of the conversion to the HSV space and then back to the RGB space or if there is the possibility to restore the original colors and in case how to do so.
Thank you in advance

2 个评论
Walter Roberson
2020-8-11
They are not supposed to be the same, as you modified them.
The question is whether the output is the same as the input except with a different Value (V).
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Color 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!