How to get the 10 color shaded images from a query image.

Hi Team, For a given RGB query image , I've to find the 10 color shades(color shades represent object color in an image) by varying hue value for the same query image. For example, if i take a red colored rose as my query image then i've to create 10 rose images with different shades of red by varying hue of query image and save them. For any given query image , its 10 color shades need to be retrieved.
Could you please help me on this.
Regards, Malini

 Accepted Answer

You mean like this: http://labs.tineye.com/multicolr/? Maybe I don't know what you mean by the 10 shades because an aribtrary RGB image will have thousands of hundreds of thousands of colors in it, as many as one unique color for every pixel, not just 10. Perhaps you want to call rgb2ind()
Or maybe you just want to convert your image to hsv with rgb2hsv(), then add some random number to the hue channel, then inverse transform with hsv2rgb()? That would alter the hue of the image.

8 Comments

Thank you for your response. Yes my request was same as that in the link you have provided. I meant 10 shades meaning , i need only first 10 variations of color from the original image color.
Please request you to correct my code and help me.
rgb = imread('img.jpg');
hsv = rgb2hsv(rgb);
h = hsv(:,:,1);
[rows cols] = size(h);
for i = 1:rows
for j = 1:cols
hmod(i,j) = h(i,j)+10;
end
end
figure,imshow(hmod);
for taking inverse transform how do i go about with hsv2rgb using hmod.
Regards, Malini
newHSVImage = cat(3, hmod, s, v);
newRGBImage = hsv2rgb(newHSVImage);
Thank you so much for your guidance. I'm in need of one more doubt to be clarified .The output image appears to be in HSV even after implementing the above code.I'm not getting the original image colors.
newHSVImage = cat(3, hmod, s, v);
newRGBImage = hsv2rgb(newHSVImage);
And moreover after incrementing the value of h(i,j) by 10 , 20, 30 etc., there is no color change in the output image . Could you please let me know why i'm facing this problem and guide me accordingly.
Regards, Malini
Did you look up rgb2hsv in the help? You can't add 10. Whatever you add, the sum has to be in the range 0-1. Try adding a smaller number, like 0.1 or something.
Yes i could visualize the color change by varying h(i,j) by 0.1.Thank you so much for helping and guiding patiently.
You're welcome, and glad it worked out for you. Thanks for marking it "Answered."
Hi Image Analyst,
I would like to achieve something like the following : http://labs.tineye.com/color/ in Matlab.
Any advice?
Thank you.
I don't know how many colors you want. If you just want to replace each color pixel with the color from a predefined list of colors, then you can find the Euclidean distance of each (r,g,b) color to each of the predefined (r,g,b) colors and assign to the pixel the predefined color with the smallest distance.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!