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
recolor an s/w image with his colored thumbnail?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: recolor an s/w image with his colored thumbnail?
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.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
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?
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.
the thumbnail has not the exact aspect ratio as the original image, it has a ca. 10% lesser width.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: recolor an s/w image with his colored thumbnail?
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?
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.
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.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: recolor an s/w image with his colored thumbnail?
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.
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?
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.
it is much more difficult as i expected.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: recolor an s/w image with his colored thumbnail?
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: