In this topic we use the Merge Images command to change the size of an image, a process also known as re-sampling an image. Although the Merge Images command is most frequently used to combine multiple images into a single image, we can also use it to change the size of an image while maintaining georegistration. This example shows how to take an image that is 3,038 x 4,334 pixels in size, using approximately 36 meter pixels, and to create a re-sampled image that is 1,115 x 1,590 pixels in size, using 100 meter pixels.
There are two ways in Manifold to resize an image by changing the size of pixels, a process also known as resampling an image:
The data set used in this topic is an image showing terrain elevation around Mount Hood in Oregon. It may be downloaded in the Mt_Hood_DEM.mxb example file in the Examples page on the Manifold web site.
For use in this example, the Mt Hood image has been re-projected into Pseudo-Mercator projection, so pixel sizes are reported in meters.
We open the Mt Hood image, and zoom in near to Mount Hood. We choose Edit - Merge - Merge Images
We enter a name for the new image the dialog will create, Mt Hood 100m pixels.
There is only one layer in the image window we have opened. By default, the dialog will use the coordinate system of that single layer as the coordinate system for the new image that the dialog will create. The dialog reports the destination coordinate system (same as that for the one layer in the image) will result in an image that is 3,038 x 4,334 pixels in size, with pixels that are 36.667 meters in size, the same as the single layer.
If we do not make any changes, the result of the Merge dialog applied to one image layer will simply be a copy of that image, with pixels the same size and thus the same resolution and the same number of pixels in X and Y dimensions of the image. We can change the resolution of the new image by altering the coordinate system, specifically, by altering the local X and Y scale values in the coordinate system metrics, so the new image uses different sized pixels for a different resolution. The Merge dialog will automatically interpolate the starting image into the new image's resolution.
We press the coordinate picker button to change the coordinate system the new image will use. We will resize the image by changing the metrics of the new coordinate system, to use larger pixels that are 100 meters in size.
In the drop down menu we choose Edit Coordinate System.
In the Coordinate System dialog we click the Custom tab.
We press the coordinate system metrics picker button.
We choose Edit in the drop down menu.
In the Coordinate System Metrics dialog, we change the Local scale X and Local scale Y values to 100. Press OK.
Back in the Coordinate System dialog we press OK, to get back to the Merge dialog.
The Merge dialog now shows that the destination coordinate system will result in a new image that is 1,115 x 1,590 pixels in size, using 100 meter pixels.
Press Merge Components, and a new image (and table) called Mt Hood 100m pixels is created in the project.
We pop open the new image and zoom to the same location as the Mt Hood image window uses. By default, the new image is not styled, so we apply the same Style used by the Mt Hood image, with one difference. The difference is that in the shading options the original Mt Hood image uses a Z scale of 0.03, while in the new Mt Hood 100m pixels image we use a Z scale of 0.01. We use a Z scale for the new image that is approximately one-third of the Z scale of the original, because the pixels in the new image are approximately three times bigger than in the original, so the relative amount of shading is approximately the same.
Visually, the new, resized image is similar to the original. When working with detailed images, the reduced resolution when going from 36 meter to 100 meter pixels might not be obvious when looking at a view that covers 30 or 40 kilometers.
We can see the effects of different sized pixels, and different numbers of pixels in X and Y dimensions, by zooming to native scale.
In the Mt Hood window, we choose View - Zoom to Native. The resulting display has one pixel in the display monitor filled by exactly one pixel from the image. We can see terracing in the image from scanning process used to create the original terrain elevation data set.
Starting with exactly the same location, in the Mt Hood 100m pixels window, we choose View - Zoom to Native. The resulting display also has one pixel in the display monitor filled by exactly one pixel from the image. Because each pixel in the Mt Hood 100m pixels image covers approximately three times the geographic extent of a pixel in the Mt Hood image, the number of pixels in the same sized display window cover three times the geographic area. If we zoomed further into the image, we would see a less detailed image.
We can compare the two images by dragging and dropping both as layers into a map, using a Bing street maps image server layer as a background. In the illustration above, we have the Mt Hood image turned on, and the Mt Hood 100m pixels image layer turned off.
Turning the Mt Hood 100m pixels image layer on, we see that the re-sampled image created by the Merge dialog is exactly georeferenced just like the starting image. To see differences between the two, we can zoom further into the display.
Zooming far into the left edge of the images, near the town of Brightwood, we can turn the image layers on and off to compare. At left we see the original Mt Hood image and at right we see the Mt Hood 100m pixels image layer turned on. The original image clearly has more detailed resolution, which is lost when the image is re-sampled to use 100 meter pixels instead of 36 meter pixels.
Note that we cannot compare resolutions in a map by using View - Zoom to Native, because the same scale will result whether we launch the command with the Mt Hood image layer as the active layer or the Mt Hood 100m pixels image layer as the active layer. When zooming to native scale in a map, the scale used is whatever is the native scale implied by the coordinate system metric in the coordinate system used by the map, in this case, the Bing streets layer. Zooming to native with any layer active thus results in the same zoom level.
A happy side effect - No, Manifold does not think that the best way to present a dialog for resizing images is to bury the capability as a side effect of a Merge Images dialog. No doubt in the future we can expect Transform templates or other dialogs to provide image re-sampling with desired options in purpose-built commands. However, until then, as sharp-eyed, expert Manifold user tjhb noticed, and reported in the georeference.org forum, when used with a single image the Merge Images dialog is a fast and easy way to re-sample images. Thanks, Tim!
Manifold 9 - Merge Images - Manifold makes it easy to combine rasters like images and terrain elevation data from many different files or layers into a single layer or data set. The new Merge dialog will automatically deal with overlaps, different coordinate systems and similar real world complications. This video shows how to merge step by step, and then colors the result with a palette and applies hill shading.
Example: Change the Pixel Size of a Terrain Elevation Image - Use the Reproject Component dialog to change the pixel size of a terrain elevation image, reducing the total number of pixels used. This process is also called resampling.
Edit - Merge - Merge Drawings
Example: Merge Images - A step-by-step example using the Merge Images command showing how to merge dozens of images showing SRTM terrain elevation data into one image, with various tricks for faster workflow as an experienced Manifold user would do the job. After creating the new image we style it with a palette and use hill shading to better show terrain elevation.
SQL Example: Re-tile an Image using a Different Tile Size - Starting with an image that uses a tile size of 128 x 128 pixels this SQL example creates a copy of the image using 500 x 500 pixel tiles.
Example: Rescale a Raster Image - See how to rescale pixel values from one raster image, using a given range of values such as 8 bit unsigned integers, into a new raster image using a different range of values such as 16 bit unsigned integers, so that the relative distribution of pixel values, that is, the histogram, does not change.