Page 1 of 1
recolor an s/w image with his colored thumbnail?
Posted: 2012-10-23T10:32:06-07:00
by tenim
hello,
i have a problem, i cant solve: i have a grayscale image(430x420) and an thumbnail of this image(91x120) which is a 24bit rgb image(colored). the thumbinail is horizontal smaller than the original image, but only a few pixels. i want to recolor the s/w image with the informations from the thumbnail but i doesn´t know how. can imagemagick do that and if not, which tool can do this?
i use imagemagick 6.7.6 Q8 static for win32.
thanks
Re: recolor an s/w image with his colored thumbnail?
Posted: 2012-10-23T10:34:04-07:00
by fmw42
tenim wrote:hello,
i have a problem, i cant solve: i have a grayscale image(430x420) and an thumbnail of this image(91x120) which is a 24bit rgb image(colored). the thumbinail is horizontal smaller than the original image, but only a few pixels. i want to recolor the s/w image with the informations from the thumbnail but i doesn´t know how. can imagemagick do that and if not, which tool can do this?
i use imagemagick 6.7.6 Q8 static for win32.
thanks
If not proprietary, please post links to your two input images, so that others can test some ideas. Post your images to some free image hosting site and then put the links to them here.
Best thought is to resize the thumbnail to the same size as your grayscale image. Then convert the new colored thumbnail to YCbCr, extract the Cb and Cr channels and combine them with the grayscale to replace the Y channel, then convert back to RGB. This might work better with LAB or HCL, but those would require a more current IM version.
Re: recolor an s/w image with his colored thumbnail?
Posted: 2012-10-23T10:57:29-07:00
by tenim
as i mentioned in the other thread, the images are some personal stuff i want to post. the method should also work for every image and his thumbnail.
the thumbnail has not the exact aspect ratio as the original image, it has a ca. 10% lesser width.
Re: recolor an s/w image with his colored thumbnail?
Posted: 2012-10-23T11:03:46-07:00
by fmw42
tenim wrote:as i mentioned in the other thread, the images are some personal stuff i want to post. the method should also work for every image and his thumbnail.
If you resize your thumbnail to the exact same size as the grayscale image, to they match exactly? Or has the thumbnail come from some other image that is not exactly the same as the grayscale image?
If they do not match exactly (or nearly so) then the method mentioned above may not work too well.
The only other method I can think of is to use histogram matching. I have a script, histmatch, at the link below) to try to do that, but it only runs on Linux/Mac or Windows w/cygwin. I tried it on a grayscale version of the logo: image and though it recolored it. The colors were a bit faded or desaturated.
Re: recolor an s/w image with his colored thumbnail?
Posted: 2012-10-23T11:18:14-07:00
by tenim
the scaled image doesn´t match exact. an other scope of application are 2 fotos (one in color, the other in s/w) with the same person on the same background in different poses. in general, the colors should be recalculateble. i think to write a c-program which makes the following stuff:
thumbnail (color):
* convert every pixel to greyscale and save the old rgb-equivalent in a table (with pixel-position in the image) i.e. grey 123, rgb(23,55,104), area a3
image(s/w):
* scan the s/w image for the greyscale-values in the table and replace every greyscale-value with the one in the table if the value and the area matches (area is nessessary because it´s possible that 2 different rgb-values have the same greyscale-value).
this sould work, or? but i will start only coding if it exists no other, easier solution.
Re: recolor an s/w image with his colored thumbnail?
Posted: 2012-10-23T14:49:04-07:00
by fmw42
convert your color image to 256 max colors. get the colormap from the verbose info. make it into an array. convert the array values to grayscale and sort both arrays. Then take the sorted color array and convert it back to a 1D image and use that with -clut to apply it to the other grayscale image. see
http://www.imagemagick.org/Usage/color_mods/#clut.
To convert r,g,b values to grayscale use the formula at
http://www.imagemagick.org/script/comma ... colorspace for colorspace gray
You can extract the colormap from the verbose into using sed in unix and do the sorting with sort in unix. If on windows, sorry, I do not know how to do those as I am not a windows user.
Re: recolor an s/w image with his colored thumbnail?
Posted: 2012-10-24T11:17:27-07:00
by tenim
sounds complex. have written my c program to test the stuff i mentioned in the last post. well, the colorizing doesn´t work as i expected. the new image is not greyscale and not full colored. colors are very weak and some pixels are not treated.
it is much more difficult as i expected.
Re: recolor an s/w image with his colored thumbnail?
Posted: 2012-10-24T13:34:22-07:00
by fmw42
tenim wrote:sounds complex. have written my c program to test the stuff i mentioned in the last post. well, the colorizing doesn´t work as i expected. the new image is not greyscale and not full colored. colors are very weak and some pixels are not treated.
it is much more difficult as i expected.
Yes I coded some unix script to do the same and found the same results. I tested with the logo: image and its grayscale equivalent.
Color Image:
Gray Image:
Recoloring by sorting in sync the colormap for the color and gray images and creating a lut applied with -clut:
Recolored using my histmatch script: