Balancing colours between map tiles

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
RobShawUK
Posts: 7
Joined: 2018-09-24T02:14:53-07:00
Authentication code: 1152

Balancing colours between map tiles

Post by RobShawUK »

I have a large number (10k+) of aerial image tiles that have been colour matching in small groups. This means that between some pair of tiles there is a noticeable "cliff edge" as the tint of the changes. I'm hoping to use IM to correct this.

I've tried using Snibgo's ImgGainBias batch files but have had limited success because the range of colors in each tile vary (some are all green fields and some are all greyish urban). I wondered if it was possible to take the RGB averages of one row/column of pixels at the edge of one tile and calibrate the next tile's adjoining row/column of pixels to match. But i don't know how to code something like that.

Has anyone tried to do anything similar or can give any advice please?

thanks
Rob

---
IM 7.0.8-11 Q8 x64 2018-08-29
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Balancing colours between map tiles

Post by snibgo »

You want to distribute the "cliff edge" change that occurs between some adjacent tiles so it occurs over a wider area. You might distribute the change over individual tiles, or over a larger range of tiles.

Distributing over individual tiles could be done with the method shown at Seamless photomontage: Colour-correction for panoramas.

To distribute the change over a wider area, for exactly your problem, I've put some thoughts at Seamless photomontage: Large mosaics.

Those would give exact colour matches at tile boundaries. However, they use "fill by relaxation", and I don't (yet) have a fast method for that. So it is very slow.

A more approximate but faster method would be to distribute the change across a group of images so that (for example) the right side column of each image matched a given column in some other image. For "match" we could use gain-and-bias, histogram equalisation, or whatever. The two columns would be cropped to find the process required. (we could use groups of columns instead of a single column.) Apply that process to the image, then blend it with the original image so there is no processing on the left side and full processing on the right side.

Perhaps you can link to some sample images.
snibgo's IM pages: im.snibgo.com
RobShawUK
Posts: 7
Joined: 2018-09-24T02:14:53-07:00
Authentication code: 1152

Re: Balancing colours between map tiles

Post by RobShawUK »

Snibgo

Thanks. Here's an example of where 4 of the tiles intersect. You can see the strong colour shift at the edges.

https://photos.app.goo.gl/kjaVxgTMP584VcuF7

What I'm going to do it convert to greyscale using

Code: Select all

-color-matrix "1 -0.5 -0.5 1 -0.5 -0.5 1 -0.5 -0.5"
i.e. R-(G+B)/2 so I could do that before trying to match them up.

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

Re: Balancing colours between map tiles

Post by snibgo »

I guess that is the result from two tiles, with the boundary about one-third down from the top? Is this the result of merely appending two tiles, or has other processing been done?

If other processing has been done, can you post the two input tiles?

The colour change from top to bottom doesn't seem to be consistent. True, the top third is "greenish" where the bottom two-thirds third is "reddish", but a specific colour in two places at the top doesn't map to the same colours at the bottom.

As you mention "-color-matrix", I'll add that we can do color-matching by color matrix, as a generalisation of gain-and-bias. See Colours to matrix and polynomials.
snibgo's IM pages: im.snibgo.com
RobShawUK
Posts: 7
Joined: 2018-09-24T02:14:53-07:00
Authentication code: 1152

Re: Balancing colours between map tiles

Post by RobShawUK »

The image shows where 4 tiles come together (slightly up and right from the image centre). I haven't done any pre-processing, although the full images are a higher resolution than that snapshot.

It possible that the cols2mat functionality you explain on your web page may do what I need so I'll give that a try. The histogram matching process may also work.

Thanks
Rob
RobShawUK
Posts: 7
Joined: 2018-09-24T02:14:53-07:00
Authentication code: 1152

Re: Balancing colours between map tiles

Post by RobShawUK »

When I try to compile cols2mat.c I'm getting the error

Code: Select all

vsn_defines.h(66) : error C2198: 'SetImageStorageClass' : too few arguments for call
have you any idea why that might be?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Balancing colours between map tiles

Post by snibgo »

Line 66 of vsn_defines.h uses SetImageStorageClass() with 2 arguments. It is compiled when IMV6OR7 is 6. Later in the file, it uses SetImageStorageClass() with 3 arguments, for when IMV6OR7 is 7.

So I suspect you are compiling with IM V7, but your imv6or7.h incorrectly says 6.
snibgo's IM pages: im.snibgo.com
Post Reply