Sub-pixel Reprojection

When reprojecting images, if we choose forward, average as the Method option of the Reproject Component dialog, a Pixel division box appears that allows us to specify the number of divisions into which each individual pixel will be subdivided, for finer reprojection rendering computations.  It enables computation of coordinate system transformations for images to conversion accuracy even more detailed than the size of a single pixel, producing better quality reprojected images than the inverse, bilinear method used by default to reproject images.   The better quality may be important in some use cases when a single original pixel during warping / georegistration expands to more than one pixel in the new image, or vice versa.

 

 

The Render box in the dialog allows us to choose the reprojection rendering method:

 

 

See the Notes section at the end of this topic for tips on choosing Render methods.

 

When we choose forward, average as the Method, a Pixel Divisions box appears that allows us to specify the number of pixel divisions.    The Pixel divisions parameter controls quality by using more subdivisions of individual pixels: higher values produce results of higher quality, but are more computationally expensive, taking longer for reprojection.

 

 

One division splits each pixel into four quarters for computation.  Two divisions splits each pixel into nine sections.

Example

Consider the image at left below, a zoomed in view of an aerial photography image provided by the state of Indiana showing Indianapolis.  Each pixel covers a 6-inch (15 cm) square.   The image is in NAD83 / Indiana East (ftUS) (EPSG:2965) projection.

 

 

At right above, we zoom further into the monument near the center of the view, using View - Zoom to Native so that each pixel in the image fills one pixel on screen.

 

 

Zooming even further, we begin to see individual pixels in the image.   The illustration above is contrived using graphics editing software, since Manifold will automatically smooth and interpolate pixels when zooming further into views, instead of growing pixels into blocks.

 

 

Zooming even further, we have marked a single pixel in the center of the display with a black box.    Using the

 

 

The default pixel division of 1 splits each pixel into four quarters, each of which can be computed independently in the coordinate system transformation.  A pixel division of 2 would split the pixel further into nine sections.

A Thought Example

We can imagine how the process works by considering a thought example, using nine pixels from the center of the display above.

 

 

We start with the original image pixels, shown above.  

 

We can image that the reprojection process of converting to a new coordinate system re-sizes, warps and repositions each of the pixels into a new position and shape, as seen below.

 

 

The inverse, bilinear method works with whole pixels, as seen above, to resize, warp and reposition them into a new coordinate system.

 

 

Pixels in images are an array of adjacent rectangles of the specified X and Y size, not warped rhomboid shapes with spaces in between, so the result image (represented by the grid above) creates pixels by interpolating pixel values, whatever those values represent, such as height or colors, from our thought experiment pixel shapes.   

 

When we use the forward, average method, we can imagine that each individual starting pixel is sub-divided into smaller units, each of which can be independently converted into the new coordinate system.

 

 

The forward, average method works with smaller subunits, as seen above.  We can imagine how using many more, smaller sections allows the coordinate transformation mathematics to apply more accurate and detailed transformations, instead of averaging out the calculations to the full size of the original pixels.

 

 

The resulting image nonetheless will consist of the same size pixels as if we had used the inverse, bilinear method, but each result pixel can be interpolated from a greater number of contributing parts.  This provides a more accurate result from the coordinate transformation and interpolation.

 

While the forward, average method provides more accurate results of coordinate system transformations, the inverse, bilinear method is still very good, and in many cases there will be no visible difference between the two.

Comparison:  Pseudo Mercator Projection

We can see the differences between the inverse, bilinear and the forward, average methods by re-projecting our sample image from NAD83 / Indiana East projection it uses into Pseudo Mercator.

 

In the examples that follow, we use the inverse, nearest method for examples, since the inverse, nearest method uses nearest neighbor interpolation and not bilinear interpolation.  Nearest neighbor interpolation with this particular image tends to produce more jagged, pixelated edges than bilinear interpolation.  We deliberately use the worst choice in interpolation method to emphasize the difference between inverse, nearest and forward, average, since the difference using inverse, bilinear is so subtle it can be difficult to see in zoomed out illustrations like those used in this documentation.

 

 

We start with a zoomed in view of the base of the monument and surrounding walkway.   

 

We reproject to Pseudo Mercator using the inverse, nearest method to create the image at left below, and then we reproject to Pseudo Mercator using the forward, average method, using 1 pixel division, to create the image at right below.

 

 

The magenta arrow in the illustration at left shows how the inverse, nearest method resulted in a slightly jagged edge to the walkway, while the forward, average method resulted in a smoother, better interpolated edge.  

 

 

We can again reproject to Pseudo Mercator using the forward, average method, using 2 pixel divisions, to create the image at above right.  The 1 pixel division result is repeated at above left, for easy comparison.  For this image, there is no evident difference between using 1 and 2 pixel divisions.

 

 

We can compare the visual effect of smoother interpolation by zooming into both the inverse, nearest and the 1 division windows.    Complicating the view is automatic interpolation Manifold is doing when we zoom so far into a display that individual pixels would appear as blocks without interpolation on the fly during display.

 

 

The 2 divisions view shows no evident difference from the 1 division view.

Comparison:  Sinusoidal Projection

The more radically different the new coordinate system, the more we will normally see a difference between using the inverse, nearest method and the forward, average method.    

 

The Sinusoidal projection is a particularly inappropriate projection for realistic views of downtown Indianapolis because of the distortion it causes in that region, so we will use that as an example.

 

 

We start with a zoomed in view of the base of the monument and surrounding walkway.   

 

We reproject to Sinusoidal using the inverse, nearest method to create the image at left below, and then we reproject to Sinusoidal using the forward, average method, using 1 pixel division, to create the image at right below.

 

 

The image is very distorted in Sinusoidal, with a jagged edge to the walkway visible when using the inverse, nearest method. The forward, average method, using 1 pixel division, provides a visibly smoother result.

 

 

Comparing the 1 division result at left with the 2 divisions result at right there is barel any gain using 2 pixel divisions.  If we examine the two images very carefully, we can see there is a slight improvement in contrast and pseud-sharpness in the steps.

Differences between Inverse Methods

Differences between the various inverse methods depend upon the different interpolations used within each method.  The inverse, bilinear choice for method uses bilinear interpolation, while the inverse, bicubic and inverse, nearest methods use bicubic or nearest neighbor interpolation.  Depending on the particular image, the differences between interpolation methods may be visible or not visible at all.  

 

Generally, we choose the interpolation based on the data and how we intend to use the results.  For example, when reprojecting rasters that show abstract scientific data, we may want to choose a specific interpolation method that is used in a coordinate system transformation so the same interpolation is used that was used for other data.

 

 

Comparing the original image created using inverse, nearest at left above with the result of a reprojection using the default, inverse, bilinear interpolation method at above right, we see bilinear interpolation produces very good results, in some places smoother than the original.

 

 

Comparing default inverse, bilinear interpolation to inverse, bicubic interpolation, we see that for this particular raster there are few visible differences, with possibly slightly better contrast using bicubic interpolation for the edges of steps surrounding the monument.

 

 

Comparing default inverse, bilinear interpolation to inverse, nearest interpolation, we see that nearest neighbor interpolation results in stronger pixelation effects on the edges of pavement surrounding the monument.

Notes

Render methods -   Inverse methods are faster than forward methods,  but forward methods are more accurate. Map windows use inverse methods for automatic reprojection, because the accuracy is more than good enough for dynamic screen display. For permanent reprojection it is better to use forward methods.

 

Pixel divisions - This parameter controls accuracy in the forward, average method.  The current default of 2 is a great sweet spot which gets most of the quality without giving up a lot of  processing time. Increasing pixel divisions to 3 or more will improve quality slightly, but there will be heavy diminishing returns in processing time. The jump from 2 to 3 has a much greater effect than the next jump from 3 to 4, and so on.  Processing times increase a lot as well.  If greater accuracy than 2 is desired, try 3 or 4 as an experiment.   The forward, nearest method also uses pixel divisions, but no Pixel divisions parameter box appears for the forward, nearest method since the parameter is internally set by the system.  The current value used internally is 2 divisions.  Future builds may vary that dynamically for different parts of the image.

 

Interpolation variations - The inverse, bilinear, inverse, bicubic, and inverse, nearest methods utilize bilinear, bicubic and nearest neighbor interpolations within the method. The forward, average and forward, nearest methods utilize averaging and nearest neighbor interpolation, respectively.

 

Nearest neighbor interpolation should be used whenever pixel values cannot be averaged, for example, if pixel values in an image represent classification codes, such as 5 = forest, 10 = water, 15 = unknown, and similar.  In such cases, averaging pixels for forest and unknown can produce water, which does not make sense, and averaging pixels for water and unknown can produce a value like 13.75 which does not match any classification code.  

 

If values in pixels can be averaged, it is usually better to use an interpolation option other than nearest.   For forward methods, there is only one alternative to nearest neighbor, and that is the forward, average method.  The forward, average method produces very accurate weighted averages. For inverse methods, the alternative to inverse, nearest is a choice between inverse, bilinear and inverse, bicubic methods.  The inverse, bilinear method is faster while the inverse, bicubic method is slightly more accurate.   However, the inverse, bicubic method tends to be used less frequently because usually when we want greater accuracy we go with forward, average.   If we use an inverse method that is usually because we want speed and care less about accuracy.  In that case, we tend to choose the inverse, bilinear method.  That is what map windows do when reprojecting on the fly, since they value speed and fine differences in accuracy are not visible given the resolution of dynamic screen displays.

 

Sample imagery - The image of Indianapolis used in this topic is part of the 6-inch (15 cm) resolution 2013 IndianaMap Data, RGBI Orthophotography data set available for free download in GeoTIFF form from the Indiana University website.   The specific tile used is in2013_01871645_06.zip   The zip file unzips into a GeoTIFF with .aux and .tfw sidecar files.  The GeoTIFF provides correct georeferencing information, but the two sidecar files provide bogus information to override the coordinate system information in the GeoTIFF.  To import the file into Manifold, first delete the aux and .tfw sidecar files.  The .tif will then be imported with the GeoTIFF coordinate system information and will be accurately georegistered.

 

See Also

Info Pane

 

Coordinates

 

Enhanced Accuracy

 

Projections

 

Assign Initial Coordinate System

 

Repair Initial Coordinate System

 

Sub-pixel Reprojection

 

Map Projection

 

Coordinate System

 

Coordinate System Metrics

 

Base Coordinate System

 

Favorite Coordinate Systems

 

Favorite Base Coordinate Systems

 

Reprojection Creates a New Image - Why changing the projection of an image creates a new image.

 

Example: Detecting and Correcting a Wrong Projection - A lengthy example exploring projection dialogs and a classic projection problem.  We save a drawing into projected shapefiles and then show on import how a projection can be quickly and easily checked and corrected if it is wrong.

 

SQL Example: List Transformation Grids - In this example we use a few snippets of easy SQL to list NTv2 and NADCON transformation grids that are available within the grids.dat compressed collection of transformation grid files.   Grid transformation files can be used when creating custom base coordinate systems, for NADCON / HARN / HPGN and NTv2 high accuracy transformations that use grid files.

 

About Coordinate Systems

 

Projections Tutorial

 

Latitude and Longitude are Not Enough

 

Example: Convert a 0 to 360 Degree Projection - We often encounter data, both images and drawings, using latitude and longitude degrees that appears to be in Latitude / Longitude projection but which has longitude values from 0 degrees to 360 degrees and latitude values from 0 degrees to 180 degrees, instead of the usual arrangement of -180 degrees to 180 degrees for longitude centered on the Prime Meridian, and -90 degrees to 90 degrees for latitude centered on the Equator.  This example shows how to utilize such data by assigning the correct projection.

 

Example: Assign Initial Coordinate System - Use the Info pane to manually assign an initial coordinate system when importing from a format that does not specify the coordinate system.

 

Example: Reproject a Drawing - An essential example on changing the projection of a drawing, either within the drawing itself, or by changing the projection of a map window that shows the drawing and on the fly reprojects the drawing for display.

 

Example: Change Projection of an Image - Use the Reproject Component command to change the projection of an image, raster data showing terrain elevations in a region of Florida, from Latitude / Longitude to Orthographic centered on Florida.

 

Example: Adding a Favorite Coordinate System - Step by step example showing how to add a frequently used coordinate system to the Favorites system.

 

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.