how to generate a color palette from a grayscale image which has been scribbled with color at some places.

Basically, in the scribbled grayscale image, i am not able to separate the colored and the gray pixels. once they get separated, only the colored pixels can be stored in the color palette.

 Accepted Answer

Just extract the separate color channels and compare them for non-equality
RG_mismatch = rgbImage(:,:,1) ~= rgbImage(:,:,2);
and so on (same for RB and GB and then OR all those together). Write back if you can't figure it out.
As far as color palette goes, you'll need to supply an example. Let's say that R = G = B everywhere except for a few pixels where R=123, G=200, and B=222. Exactly how would you like your palette (colormap) to look (and why)?

2 Comments

i did the same thing as u have specified.. as i am traversing the image into 2x2 blocks.. in each block, m checking that how many pixels are colored.. and to check that if a pixel is colored or not, m doing the same condition i.e. img(:,:,1)~= img(:,:,2)|| img(:,:,2)~= img(:,:,3) || img(:,:,1) ~= img(:,:,3). if the condition is tru , that menas that the pixels is colored... right na?.. i need to generate the color palette to color the actual gray image which has not been scribbled. Please write back soon.
Why are you traversing in 2x2 blocks??? And are you talking about reproducing that patent where someone can scribble some colors on a grayscale image and then the code figure out how to take those hues and spread them out to colorize the whole image? I think it's a method used to colorize things like black and white movies and photos.

Sign in to comment.

More Answers (2)

What mechanism do you use for "scribbling", and what mechanism do you use to retrieve the mixed image?

2 Comments

i first converted a color image to gray using rgb2gray. then i saved this grayscale image and opened it into paint. i scribbled certain colors using color brush and saved it. the mechanism which m using to extract the r,g,and b components of the color pixels from this scribbled image is that m traversing the image in 2x2 block and m checking that if r, g and b components of a pixel are not same then only its colored. but on running the program . its also including pixels of the image which are not scribbled with color. Please help me... its urgent as i have my project on this...
What file format are you saving in to in paint ? If you are saving in to JPEG format in anything other than Lossless JPEG, you should expect to see this kind of issue.

Sign in to comment.

Categories

Find more on Images in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!