RGB image to HSV image conversion

13 次查看(过去 30 天)
Hello all
I have an rgb image and I want to convert it into HSV image and want to get only SV image.I have code like that
img=imread('lena.bmp');
[H S V]=rgb2hsv(img);
this computes each H,S and V channel individual I want to compute only SV only how can I do it..
it is not possible to o it like
cat(2,S,V);...?
or
rgbimage=img;
rgbimage(:,:,2)=S;
rgbimage(:,:,3)=V;
Any help is appreciated...

回答(1 个)

Image Analyst
Image Analyst 2013-9-9
No - none of that is right. For one, you can't get the separate channels out of rgb2hsv(), though that might be a nice new enhancement/feature to add. You can do this:
hsv = rgb2hsv(rgbImage);
h = hsv(:, :, 1); % Hue image.
s = hsv(:, :, 2); % Saturation image.
v = hsv(:, :, 3); % Value (intensity) image.
You certainly would not want to combine them into a 3D image called anything like rgbimage because that would be very deceptive since it's not an RGB image.
  6 个评论
azam sayeed
azam sayeed 2015-9-17
编辑:Walter Roberson 2015-9-17
sir when i apply meanValue to different images i still get the same mean value based on hue component
%window1
hsv2=rgb2hsv('testw1.png');
hueImage2 = hsv2(:,:, 1);
meanHue2 = mean2(hueImage2);
display(meanHue2 );
%window4
hsv3=rgb2hsv('test.png');
hueImage3 = hsv3(:,:, 1);
meanHue3 = mean2(hueImage3);
display(meanHue3);
output:
meanHue2 =
38.9913
meanHue3 =
38.9913
Image Analyst
Image Analyst 2015-9-17
You need to send in an image to rgb2hsv, not a string that happens to be a filename:
rgbImage = imread('testw1.png'); % Get image from file
hsv2=rgb2hsv(rgbImage); % Convert image, not string.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Convert Image Type 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by