Page 1 of 1

Daylight map image generation

Posted: 2008-04-21T13:52:38-07:00
by vladm
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

Re: Daylight map image generation

Posted: 2008-04-24T21:58:34-07:00
by fmw42
I don't know if IM can do this, but post links to your input and output images.

Re: Daylight map image generation

Posted: 2008-04-25T08:35:53-07:00
by vladm
Daytime image (input#1):
Image

Nighttime image (input#2):
Image

Output image:
Image

Thanks!
VM

Re: Daylight map image generation

Posted: 2008-04-25T10:50:39-07:00
by fmw42
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.

Re: Daylight map image generation

Posted: 2008-04-25T11:03:48-07:00
by vladm
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/

Re: Daylight map image generation

Posted: 2008-04-25T11:26:29-07:00
by fmw42
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.

Re: Daylight map image generation

Posted: 2008-05-20T22:55:23-07:00
by anthony
-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.