Page 1 of 1

Rectify images from weather satellite

Posted: 2019-01-23T12:45:00-07:00
by machs
Hi All, I'm looking to use imagemagick in a script to rectify images received from a weather satellite.

The raw images received are compressed at the left and right edges but correct at the center. The image needs to be stretched non linearly along the width to mimic a flat map like projection. I'm thinking the command line options for -distort barrel A,B,C,D sounds about right but I'm not clear on how to use this option. Can someone point me in the right direction?

https://imagemagick.org/script/command- ... hp#distort

I'm looking to achieve something similar to this
http://leshamilton.co.uk/meteor3m.htm

Re: Rectify images from weather satellite

Posted: 2019-01-23T12:57:46-07:00
by snibgo
I suggest you research to find the mathematical distortion required to do whatever you want.

In the example you show, there is clearly distortion in the x direction but not the y direction. Maybe "-distort barrel" can undistort it, at least approximately. But a website somewhere will probably tell you the exact maths needed.

Re: Rectify images from weather satellite

Posted: 2019-01-23T13:25:27-07:00
by fmw42
Looks a little line the opposite of my cylinderize script. It appears to be similar to unwrapping an image wrapped about a cylinder. But it is more likely a specific map projection type transformation. See https://en.wikipedia.org/wiki/Map_projection and https://en.wikipedia.org/wiki/List_of_map_projections

Re: Rectify images from weather satellite

Posted: 2019-01-28T10:25:02-07:00
by machs
So barrel distort transforms the image in both X and Y axises so that isn't appropriate.
I've been reading the examples for simple displacement and I think i have a solution in mind. As this is for a hobby project i'm not concerned with accuracy or geo-referencing, just going for a looks right solution. Here is what I'm thinking

Code: Select all

#build displacement map
convert --size 2695x100 xc: -channel G -fx 'sin(pi*i/w)' -separate -transverse displacementMap.png
#scale displacementMap.png to match m2 image height, haven't figured this out yet
get rawImage height
resize displacementMap.png to imageHeight
#apply transform
convert rawImage.bmp displacementMap.png -fx 'p{u[1]*w,u[2]*h}' adjustedImage.png  
The displacement map i'm looking to build would displace the pixels at the edges of the image the most, and leave the images in the center untouched.

Re: Rectify images from weather satellite

Posted: 2019-01-28T11:02:34-07:00
by snibgo
machs wrote:So barrel distort transforms the image in both X and Y axises ...
That's not correct. You can specify the four parameters (A,B,C,D) for the x and y directions independently. So you can use (0,0,0,1) for the y-direction to give no distortion in that direction. See http://www.imagemagick.org/script/comma ... hp#distort

But it's good that you have found a solution.