how to extract the orange color from the image? how to convert the red band to orange band?
1 view (last 30 days)
Show older comments
i want to change the red band of the image to the orange band others remaining unaffected.
Answers (1)
Image Analyst
on 13 Apr 2015
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 Comments
See Also
Categories
Find more on Convert Image Type in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!