Daylight map image generation

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
vladm

Daylight map image generation

Post 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 convert -fx and composite, and if not - any references to C++/C/Python code would be much appreciated.

Thanks in advance!
VM
Klaws

Re: Daylight map image generation

Post by Klaws »

I have serious doubts that the line between day and night is a sine wave line. The projection which is used to map the globe's surface onto a rectangular area will happily get into the way.

As an approximation, you could use a third image as a "shadow mask". If it repeat wtice horizontally, you can shift right or left according to the time and up and down according to the date.

Multiply the "shadow" picture with daylight picture. Multiply the negative shadow picture with the night picture. Sum the two results.

More accurate would of course be a per-pixel calculation. For every pixel, calculate how much sunlight it receives (bases on the angle of direct sunlight, if any, refracted sunlight during the three different twilights, plus, if you really want to calculate everything, reflected moonlight, obstruction and scattering by clouds and dust/dirt. Note that the different wavelengths of the sunlight are differently refracted and scattered).

If the map has really good resolution, terrain elevation will begin to play a role (shadows of mountains and valleys).

Best regards, Klaus
Post Reply