Rectify images from weather satellite

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
machs
Posts: 2
Joined: 2019-01-23T11:43:55-07:00
Authentication code: 1152

Rectify images from weather satellite

Post by machs » 2019-01-23T12:45:00-07:00

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

snibgo
Posts: 11932
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Rectify images from weather satellite

Post by snibgo » 2019-01-23T12:57:46-07:00

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.
snibgo's IM pages: im.snibgo.com

User avatar
fmw42
Posts: 25274
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Rectify images from weather satellite

Post by fmw42 » 2019-01-23T13:25:27-07:00

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

machs
Posts: 2
Joined: 2019-01-23T11:43:55-07:00
Authentication code: 1152

Re: Rectify images from weather satellite

Post by machs » 2019-01-28T10:25:02-07:00

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.

snibgo
Posts: 11932
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Rectify images from weather satellite

Post by snibgo » 2019-01-28T11:02:34-07:00

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.
snibgo's IM pages: im.snibgo.com

Post Reply