I would like make a gradient from a color image, and apply it to another black and white image.
How would I get the gradient from the color image?
An example is to get a gradient from a photo of clouds at sunset, and apply it another photo of black and white clouds.
How would you do this with ImageMagick?
Generate a gradient from a image?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Generate a gradient from a image?
A perfect solution is not possible, because many colors may map to the same gray intensity. There is no way to know which color to use.
My best suggestion is to correlate a few colors from locations in the colored image with shades of gray in your grayscale image. Then build a clut image (what you call the gradient) and apply it using -clut.
For example:
Here is a color image:
Here is a corresponding grayscale image:
My command, where I have selected just a few colors (unix syntax):
(windows syntax, I think)
Resulting image:
My best suggestion is to correlate a few colors from locations in the colored image with shades of gray in your grayscale image. Then build a clut image (what you call the gradient) and apply it using -clut.
For example:
Here is a color image:
Here is a corresponding grayscale image:
My command, where I have selected just a few colors (unix syntax):
Code: Select all
convert gray_image.jpg \
\( xc:black xc:blue xc:green1 xc:red xc:white +append -resize 256x1! \) \
-clut gray_image_colored.jpg
Code: Select all
convert gray_image.jpg ^
( xc:black xc:blue xc:green1 xc:red xc:white +append -resize 256x1^! ) ^
-clut gray_image_colored.jpg