how to extract the orange color from the image? how to convert the red band to orange band?
4 次查看(过去 30 天)
显示 更早的评论
i want to change the red band of the image to the orange band others remaining unaffected.
回答(1 个)
Image Analyst
2015-4-13
Three different color segmentation methods are given in my File Exchange. http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862 You might try the HSV one first.
The basic concept is to find the range of hues that represents orange. Let's say orange ranges from 0.2 to 0.3 in the hue component. Then just set all of those to 0.2 (the shade of red closest to the orange boundary).
hsv = rgb2hsv(rgbImage);
h = hsv(:,:,1);
imshow(h, []); % Display the hue channel
axis on;
s = hsv(:,:,2);
v = hsv(:,:,3);
% Get mask for orange pixels.
orangePixels = h > 0.2 & h < 0.3;
% Set those pixels to a hue of red - the red that is closest to orange
h(orangePixels) = 0.2;
% Now convert back to RGB
hsv = cat(3, h, s, v);
rgbImage = hsv2rgb(hsv);
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!