For quite a few years, I have had a need in my personal projects and my research to accurately combine multiple images into a single image. For example, say I have a map of an area, and I want to mark out different pieces in different colors. However, I want to do this once a month for several months, and at the end, make a visual average of all the months. In most circumstances, you'd want to make each month contribute equally to the visual average, so you would first take each image and open it as a layer in a new image, with all the layers stacked up. I'm sure anyone with even a passing familiarity with GIMP would be able to get this far, if nothing else with File->Open as Layers.

The trick, though, is you have to set each layer to some degree of transparency to make it work. At the end, you want a patch of color to have the same apparent saturation regardless of whether it's on the bottom layer of the set or the top layer. For a long time, I assumed you would use a simple linear progression. For example, given four layers, the top would be 25% opacity, the next would be 50% opacity, the third 75%, and the bottom 100%. For the application for which I used this, it seemed more than adequate, and I attributed any inconsistencies or possible problems with the final image to be the result of tired eyes or perfectionism.

Today, however, I was examining a case just like the example in the first paragraph, and I noticed that using the linear scheme, areas of the same color and saturation ended up having different apparent saturations in the final image! To make sure that I was correct, I copy'd merged, then used the eyedropper to confirm that they were indeed different. And they were, although not by horribly large amounts. The solution turned out to be a geometric sequence. I'll detail this with an example:



You can see at a glance what I mean by geometric: the bottom layer has an opacity of 1/1 or 100%, the next up has 1/2 or 50%, the next up 1/3 or 33.3%, and the top of the four 1/4 or 25%. This result was quite a surprise to me, but I checked it for a variety of test cases and was gratified to see it held true. A fifth layer should be 20%, a sixth 16.7%, etc. In addition, I was happy to notice that this means adding extra layers on top does not necessitate changing the opacity of any of the existing layers!

In the image about, each of the images started with a solid, 100% opacity white background, a 100% opacity black border, and a 100% opacity red stripe. As you can see in the top of the image, four such layers are placed on top of one another with the geometric progression of opacity that I suggest. The output image is shown on the bottom: each stripe, regardless of the position or opacity of its image, appears as a uniform 25% opacity, just as one would hope.

Please note that this method relies on having *fully filled* layers, not transparent areas. In this case, I filled all the normally-transparent areas with white, which is necessary to lighten the stripes in the lower layers properly. Hope this helps you!
That is interesting, thanks for sharing this with us Kerm.
Glenn wrote:
That is interesting, thanks for sharing this with us Kerm.
My pleasure, I hope it's useful to someone other than myself. Smile
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement