what's the diffeence between those two intsructions to tranform the RGB image to HSV one
2 ビュー (過去 30 日間)
古いコメントを表示
the first example:
frame1=rgb2hsv(frameRGB);
frame=frame1;
frame(:,:,3)=0;
the seconde example:
frame1=rgb2hsv(frameRGB);
frame=frame1;
frame(:,:,3)=0.7;
frame=hsv2rgb(frame);
0 件のコメント
採用された回答
Geoff Hayes
2016 年 1 月 29 日
bay - the difference is in the third step
frame(:,:,3)=0;
vs
frame(:,:,3)=0.7;
In the first case, the value (or "brightness") is set to 0 for all elements and in the second case, the value is set to 0.7 for all (so a constant brightness value across all elements). Since the values of the frame matrix range from 0 to 1, then the smaller the value, the darker the image will become.
4 件のコメント
Image Analyst
2016 年 1 月 29 日
Neither one "handle the luminoisty variation". The first one just sets the image to all black and the second one sets the color image to a constant brightness, though there will still be color variations because the saturation and hue can still change. Like Geoff says, try it. Cast back into RGB and cast to uint8 though to see it.
DGM
2022 年 5 月 31 日
編集済み: DGM
2022 年 5 月 31 日
I think the question here was that OP is observing that the result from the second method truly does not have a uniform brightness and OP was asking why.
Simple models like HSV are simple ways to rearrange RGB. They aren't necessarily good at separating perceived color properties; they're just convenient. Unlike something like L* or even luma, V in HSV is a poor descriptor of perceived brightness.
Let's look at what happens
rgbpict = imread('peppers.png');
% three copies of the image, converted to HSV
hsvpict1 = rgb2hsv(rgbpict);
hsvpict2 = hsvpict1;
hsvpict3 = hsvpict1;
% set the V channel in each copy to a different constant
hsvpict1(:,:,3) = 0;
hsvpict2(:,:,3) = 0.5;
hsvpict3(:,:,3) = 1;
% convert all images back to RGB
outpict1 = hsv2rgb(hsvpict1);
outpict2 = hsv2rgb(hsvpict2);
outpict3 = hsv2rgb(hsvpict3);
% concatenate examples for simplified viewing
outpict = [outpict1; outpict2; outpict3];
imshow(outpict)
% convert output to BT601 luma
ypict = rgb2gray(outpict);
imshow(ypict)
Despite setting V to a constant, it's reasonable to say that the output does not have even approximately constant "brightness" in any measure except V. While I used BT601 luma, the conclusion is the same regardless of whether it's BT709 luma, L* or something else. The only point at which constant V equates to perceived constant brightness is when V = 0. Why is that?
For a given RGB tuple [R G B], V is simply max([R G B]). Consequently, all colors on the upper three faces of the RGB cube have V = 1. In other words, white is not uniquely the "brightest" color in V. On the other hand, the only point at which V is zero is when all three channels are zero -- so black is the uniquely "darkest" color in V.
One doesn't need to dig deep into color science to suspect that this simply cannot produce a result of perceived constant brightness. If the eye has any nonzero response to the three color channels, then [1 0 0] and [1 1 1] cannot have the same perceived brightness, even if they have the same V.
So what works better than HSV? It depends what the requirements are and how much time and system resources you want to throw at the task. If the reader wants that question answered, they're free to ask it.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Modify Image Colors についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!