Skip to content


Abstract: In this tutorial, you'll learn to neatly assemble an image which was for example scanned in two parts. In the end we will make a wallpaper out of the scanned image. We'll make use of the measurement tool, "difference" layer mode, a layer mask in a handy way, improve the image some with "levels", and mention some things about the handling of huge images.

Tutorial: Assembling images properly

(c) Carl-Johan Sveningsson, woc@wlug.westbo.se, 2003

Ever wanted to assemble two images, perhaps from scanning an image too big to fit in your scanner? Some time ago, I wanted to create background images from two Despair-calendars (www.despair.com). For obvious reasons, the images provided at their website aren't good enough to make pretty backgrounds, so I made my own.

This tutorial might seem a bit over the top, but this is as much effort you will have to put into it to have a really good result, and you don't want to hurt your eyes with ugly images, do you? Once you learn, you intuitively do things like these in just a couple of minutes. Hey, it should be quite possible to write a script for this using edge-detection tecniques and checking correlations... that's for another tutorial. :-)

I'm sorry about running Gimp in swedish. This it they way I usually have it, and I didn't bother changing it. Things are in the same places anyway, so it shouldn't really pose a problem.

First I scanned each picture at 300 dpi. I hade to make two passes, since they were larger than what the A4-scanner could handle. Now I want to assemble them. 300 dpi (dots-per-inch) is less than most printshops want to print at, but I think it is proper to call it hires anyway. After all, it can compensate for most problems related to low resolution, and I rarely scan at higher resolutions, and if I do, I do it at 900 dpi, just to reduce the image to one-third (one ninth the data) as quick as possible.

Such high resolutions create large amounts of data. You might think the ~1 Mb the image takes up jpg-compressed is enough, but Gimp has work with it uncompressed. Uncompressed, these two images represent some 48 Mb of data ( (2x24x2512x3388)/(8x1024x1024) ), and its then easy to imagine just a couple of layers in this size seriously can diminish the performance of your computer. I run an Athlon 1.2GHz with I dunno, 256 Mb of memory I think, and it can handle it at least. I've heard mentioned that if you run into performance penalties with large images, try so set the "Image block size" in the Gimp preferences to something larger.


Here is an overview of what the pictures look like. Two overlapping parts. And as you can see on the 1:1 magnification, 300 dpi make pretty large images! But I like it that way, the scanner lacks an oppurtunity the gimp has - to sample many points and blend them into a single pixel when reducing the image size. This is especially important when working with offset-printed stuff with low-resolution rasters. Unless scanning at a high enough resolution, it's impossible to get a clear representation of what colours the CMYK-raster-dots should blend together to, and you will have really ugly (or interesting, depends on how you look at it) interference artifacts (interference between the sample dots of the scanner and the raster dots of the print).

First I check that the images are properly aligned. This is simplest if they have a straight line somewhere in the image, I pick the border around the photo. Zoom up closely, pick the measurement tool, and draw a ruler as far and accurately as you can along the straight line you've picked.

The left half was ok, but here we see that the right half is off by 0.13 degrees if we measure along the top line of the border. Anything below 0.05 degrees can and should be compensated or it will cause really ugly misalignments in these large images.


Actually, I was a bit uncertain which orientation the 0.13 degrees had, but as I checked the pixels of the ruler closely, they told me the image was misaligned counter-clockwise. Thus, we want to rotate it some clockwise. Pick the transformation tool, make sure it's set for rotation, and just rotate the image some, clockwise. I can never remember which has the negative sign, CW or CCW, so I overdo it by hand first to get the correct orientation. Keep the sign, but in this case, typ in '0.13' in the information box. Click rotate. Wait for the transformation to complete... we're still talking pretty much data here...


Now let's make room in the left image for the right half. Choose Image -> Canvas Size. There, first uncheck the link icon, so that you then can choose that you wish only to increase the width of the image by two.


Mark all (Ctrl+A) of the right half, copy it (Ctrl+C) and paste it into the now enlarged canvas of the left half (Ctrl+V). Place it fairly well, and choose that you want to paste into a new layer by clicking the "New layer" icon. Go ahead and close the image for the right half too, to save some memory.


Now for the interesting part. Select the layer of the right half, and set it to "Difference" mode. Not the image will look pretty weird, and only the part of the layer overlapping the left half will show at all. On closer analysis, this will of course help us position the right half properly.


Zoom in and move the layer better in place. The difference mode will help you get a feeling for when things are improving or worsening. Go ahead and nudge the layer with the arrow-keys. You might have to make sure you both have the move tool (M) chosen and NumLock disabled.


When you're ready, the image should have a section in the middle which look really black like this. Do note that we've only managed to keep the so-called correlation-length up to a couple of inches. Any way we move the layer now, the situation won't improve, the correlated area will just move around.


Now let's add a "layer mask" to the right-half layer. The layer mask is for controlling which parts of the layer should show. You do so by manipulating the layer mask, black = transparent and white = opaque. Select black and white in the bg/fg-color-box, and pick the fg->bg-mode of the gradient tool. Now think. We want the layer of the right half to fade out in the left side, i.e. the left side of the mask should be black, the right side white. Go ahead and click the layer mask to make it active and paint a B/W-gradient from left to right horisontally in the overlapping area. If you got it wrong, just do it again in the other direction.


When finished it should look like this. The messy black portion is left on the right, clearing up to the left.


Set the layer of the right half back into normal mode and - tadaa! You should have a really pretty image showing no trace of ever being cut in half. We should take a moment to go ahead and crop the image. And oh yeah, merge the layers too. The order is not important.


Now it's time to restore the colors of the image some. Use the Image->Colors->Levels dialogue. This can sometimes be substituted either with the Curves dialogue (more complex) or Threshold (very simple), but now this is what I want. Levels produce a histogram of the color contents of the image, ordered by lightness. See those two little bumps, one in each side of the histogram? You usually see those in scanned images, they represent the level which used to be black and white, respectively, but have slid into the greys during the process. Sometimes there are some 10% unused spectrum in the sides of the histogram, you would be surprised with what information you can actually pull forth in an image just by making sure it use the entire spectrum! If appropriate with the particular image, this should of course be corrected. Slide the black arrow slightly to the right of the "black" bump, and the white arrow to the left of the "white" bump. Don't touch the grey midtones arrow, it will follow automatically.


Awww...that's a mighty pretty result. Really saturated black, real white. Oh ok, you can se the fading on the top-left of the 'A', but that will have to do. Perhaps it's better to make a much shorter gradient in the layer mask. I guess that depend on what type of image it is. Let's save this version of the image for later purposes, we don't want to go over it all again. '.jpg' is ok, since we have no layers we want to save, and even though jpeg is bad at handling sharp lines, no lines look sharp enough at these resolutions to be distorted by the compression.


Now we want to rescale the image to make it fit for a background. Now you have to think, this is different in every image. Do you want the image to fill the entire screen? Perhaps you want to place it in a corner? Then you shall have to scale it down more. I feel that the margins already in the image are ok, and I just want to pad it to the correct ratio which my screen use. The left of my screens (now I got to mention that too :-) ) run at 1280x1024, and entering any of these two values reveal that if I have 1280 as the width of the image, the corresponding height would be larger than 1024, i.e. in need of cropping to fit the screen. Instead, if I choose 1024 as the height of the image, the width is lesser than 1280, i.e. in need of padding. I choose the latter.


Now we want to pad. We do that under Image->Canvas size. This dialogue won't scale the image, just add or remove space from the "canvas". We already have 1024 as the height, now uncheck the 'link' icon (to not make it force us to retain image ratio) and type in 1280 in the width-box. In the bottom of the dialogue, you can now slide the current image around in the new space which will be created. Place it reasonably in the middle.


Lacking background in the edges. Add a new (black) layer. Oh, you can't move an opaque background layer above the new black layer. Make a copy of the background and move it above the black layer. Nudge it in place if needed, flatten the image, save your new pretty background as '.jpg', and you're done!. Rince and repeat as needed.

That's all for today kids, hope you had a good time, and next time I'll show you how to best isolate and replace the colors of that text and the background so we don't have to stick to that black (I prefer the bright blue).


Footnote: Of course the images are copyrighted (by Despair inc.), but as owner of the two calendars I have scanned, I'm pretty sure I'm entitled to use them for my own computer backgrounds and such. This is of course also why I can't provide any "before" and "after"-images. I think I have made sure all of the screenshots are at least less usable than the images provided for free at despair.com.