I am trying to generate a daylight map image from 2 high resolution world maps: daytime and nighttime. To do that, I need to crop both images along a sine wave line, apply a twilight gradient along the crop line, and splice them into one image. Does anybody know or point me to some info on how to accomplish cropping of the image along a sinusoidal line and apply a gradient along the cut? Can this be done just with the command line tools, and if not - any references to C++/C/Python code would be much appreciated.
Thanks in advance!
VM
Daylight map image generation
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Daylight map image generation
I don't know if IM can do this, but post links to your input and output images.
Re: Daylight map image generation
Daytime image (input#1):
Nighttime image (input#2):
Output image:
Thanks!
VM
Nighttime image (input#2):
Output image:
Thanks!
VM
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Daylight map image generation
It looks to me like you are just trying to overlay the two images. I do not understand where the sine wave comes in? Can be more specific or make a drawing to show what you want to do? Where are the parts that come from the one image and the parts that come from the other image and where does the sine wave come in to the picture?
P.S.
If I alternate the display of the three image I can see kind of what you are trying to do. You just need a mask image that is white on one side of the "sign wave" and black on the other and fades between the two. If you can generate the sine wave as a binary image (mask), it can be faded with a blurring function. The mask can then be used to control the composite of the two image. See http://www.imagemagick.org/Usage/compose/ However, I do not see anything that looks exactly like a sign wave. It has somewhat that shape, but does not look exactly like that. What map projection are you using and is the sine wave in that projection. Do you have a formula for the sine wave? If so, then -fx might be able to generate the binary mask.
P.S.
If I alternate the display of the three image I can see kind of what you are trying to do. You just need a mask image that is white on one side of the "sign wave" and black on the other and fades between the two. If you can generate the sine wave as a binary image (mask), it can be faded with a blurring function. The mask can then be used to control the composite of the two image. See http://www.imagemagick.org/Usage/compose/ However, I do not see anything that looks exactly like a sign wave. It has somewhat that shape, but does not look exactly like that. What map projection are you using and is the sine wave in that projection. Do you have a formula for the sine wave? If so, then -fx might be able to generate the binary mask.
Re: Daylight map image generation
The images are not overlayed, but rather combined as the daylight part comes from one image and nighttime part comes from another. The delineation, depending on date and time, is a sinewave, oval, or inverted sinewave. Here is a more obvious representation on daylight map: http://www.daylightmap.com/
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Daylight map image generation
OK, but your merging is equivalent to using a mask image to use one image where it is white and the other image where it is black and a combination blending of the two images where the mask is gray. All you need is to create the mask image using -fx and a sine wave. The rest can be done by blurring the binary mask to make the transitions gray areas and using
convert daytime nighttime mask -composite daynight
Here is a little test command that I built to do the mask generation along a sine way
# set up the image size and "amount" of blurring (gradient)
width=200
height=100
grad=10
# build sine wave mask and blur with 1D horizontal motion-blur function (but I am not sure it is working quite right)
convert -size ${width}x${height} xc: -fx "yy=(h/2)*(1+sin(2*pi*i/w)); j>yy?black:white" -motion-blur 0x${grad}+0 daynightmask.png
or
# build sine wave mask and blur with 2D gaussian blur function
convert -size ${width}x${height} xc: -fx "yy=(h/2)*(1+sin(2*pi*i/w)); j>yy?black:white" -blur 0x${grad} daynightmask.png
You can change the width and height to match your image and set the blur to the amount you need for that size image. The run the convert command to build the mask image.
Then run the convert ... composite as above to overlay the day and night images using the mask.
convert daytime nighttime mask -composite daynight
Here is a little test command that I built to do the mask generation along a sine way
# set up the image size and "amount" of blurring (gradient)
width=200
height=100
grad=10
# build sine wave mask and blur with 1D horizontal motion-blur function (but I am not sure it is working quite right)
convert -size ${width}x${height} xc: -fx "yy=(h/2)*(1+sin(2*pi*i/w)); j>yy?black:white" -motion-blur 0x${grad}+0 daynightmask.png
or
# build sine wave mask and blur with 2D gaussian blur function
convert -size ${width}x${height} xc: -fx "yy=(h/2)*(1+sin(2*pi*i/w)); j>yy?black:white" -blur 0x${grad} daynightmask.png
You can change the width and height to match your image and set the blur to the amount you need for that size image. The run the convert command to build the mask image.
Then run the convert ... composite as above to overlay the day and night images using the mask.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Daylight map image generation
-fx is very slow. and their is no need.
Look at the three image Composite masking instead.
http://imagemagick.org/Usage/compose/#mask
It will do exactly what you want.
Blur the mask a bit to contol the amount of blending in the border reagions.
Look at the three image Composite masking instead.
http://imagemagick.org/Usage/compose/#mask
It will do exactly what you want.
Blur the mask a bit to contol the amount of blending in the border reagions.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/