One aspect that has been concerning me for some time when using panoramic photography in scientific or heritage contexts is the geometric fidelity offered by one projection or another, or by the image stitching process itself. It is true that every photographic image has a series of geometric distortions derived from the type of lens and obviously the perspective; however, it is in panoramic technique, even when less than 180º, where the geometric aspects of the image worry me the most.
However, this situation should not be worrisome since image stitching in disciplines such as aerial photography and ultimately image processing for GIS is a very routine and precise task; nevertheless, these techniques remain within the realm of cartography or surveying and rarely transcend to the photographer.
To provide geometric or dimensional validity to a photograph, whether a single shot or a panorama resulting from stitching a mosaic of images, it is necessary to rectify that image to approximate the concept of what is understood by an orthophoto, or in other words, an exact geometric representation of all the elements contained in that shot, free from perspective and scale errors just as a map would do. In fact, orthophotos are the basis for map drawing. The creation of a good orthophoto is actually a bit more complex since they are usually obtained by photogrammetry, stereoscopic imaging, terrain models, etc., as the goal is to minimize as much as possible the distortions of the terrain or objects when projected onto a 2D image. Recent tools based on SFM such as CMPCMVS have recently incorporated output for orthophotos, and in general, any professional photogrammetry tool is capable of generating this type of image.
Rectifying an image is a highly relevant process when making measurements within the image itself, although there are very simple techniques to assign a scale and subsequently make measurements in an image, these are scarcely valid if there is some perspective in the shot, since that scale will not be consistent throughout the scene.
The image rectification process occurs based on the coordinates of known points within our scene. For example, if we speak in geographic terms, to rectify an aerial image we need to locate certain points in the image whose geographic coordinates we know; this is also known in some processes as georeferencing an image. For our shots of elevations, objects, or scenes, the principle is the same, requiring leaving certain markers or reference points in the scene whose coordinates relative to each other we know.
As an example, I am going to rectify a simple image of my Colorchecker taken with a bit of perspective; for this, I need to know the coordinates of the corner marks so that if these marks form a rectangle whose width or longer side is 9 cm and its height is 6 cm, the X,Y coordinates of these corners will be (0,0) (9,0) (0,6) (9,6) as can be seen in the image on the left.
The rectification process needs these coordinates to relate them to the pixel coordinates representing those points in order to correct the image until the relationship of those coordinates is fulfilled on our image.
For the rectification process, we will use a free tool called RECTIF available for Linux or Windows via command line or visually through the georeferencing plugin of the Quantum GIS Desktop (QGis) tool, also available for Win, Linux, and Mac; personally, I have tested the entire process on Ubuntu.
Using RECTIF is quite simple, although it can become a bit tedious since it is necessary to create a small ASCII file with the information or coordinate correspondences related to the pixels that describe our reference points.
The file format must have the same name as our image with the extension .points, for example: P1100298.JPG.points
mapX mapY pixelX pixelY 0.000000000000000 0.000000000000000 573.235127478753384 -1178.923512747875293 9.000000000000000 0.000000000000000 1655.841359773371096 -601.019830028328556 0.000000000000000 6.000000000000000 361.337110481586251 -531.671388101982984 9.000000000000000 6.000000000000000 1255.161473087818649 -88.611898016997202
Where the first two columns represent our coordinates, the next two the X and Y coordinates of the image pixels where our marks or reference points are located, which we can easily obtain with our PS or GIMP. The rows correspond to the number of established points.
Great attention must be paid to the consistency of our coordinates since otherwise our rectified image will be created with significant distortions.
Once this document is constructed, we simply invoke RECTIF with the command:
rectif P1100298.JPG
So it is not necessary to indicate the points file as a parameter since it is deduced from the name of our image.
The result of the process is an image in PNG format. With RECTIF, we have no options for further configurations or parameters. This tool only accepts JPG images as input format.
The second way for this process is to use the QGis tool. For this, we first have to download from the plugins menu the GDAL Georeferencer plugin, which will be located under the Raster menu once activated.
From the georeferencing submenu, a new window opens in the application where we can load our image, either TIFF or JPEG, and place points visually on our image as well as define the coordinates of each point. Once the process is finished, some attributes of the process must be defined in the Transformation Settings icon, indicating the output path for our rectified image and the type of transformation (Projective, Polynomial, Helmert, or Linear). Each of these transformations has slight implications on the geometry of the final image; perhaps the best options are Projective or Polynomial. We can also choose the usual image resampling models.
During these processes, we will be asked about the coordinate reference system; this is an inherent aspect of geographic work, but since we are only doing rectification, it has little interest for our objective. In any case, by default, we can use WGS84 since it is the standard.
Once these parameters are adjusted, we can activate the play button to generate our rectified image according to our coordinates. In parallel, we can save the list of points and coordinates with the aforementioned .points format to be used in RECTIF independently of the rectification that QGIS may perform. It is worth mentioning that the .points file generated by QGIS is comma-separated and not space-separated, so it would look like this:
mapX,mapY,pixelX,pixelY,enable 0.000000000000000,0.000000000000000,573.235127478753384,-1178.923512747875293,1 9.000000000000000,0.000000000000000,1655.841359773371096,-601.019830028328556,1 0.000000000000000,6.000000000000000,361.337110481586251,-531.671388101982984,1 9.000000000000000,6.000000000000000,1255.161473087818649,-88.611898016997202,1
Theoretically, to use this format with RECTIF, you only have to use the “q” parameter so that it looks like this:
rectif P1100298.JPG q
Personally, this situation has not worked for me, with RECTIF throwing various errors; I do not know the reason or if it is something exclusive to the version I tested. The solution is easy, since you simply have to replace the commas with spaces and then it is possible to use that document perfectly.
During the use of QGIS, a .pgw file will also be generated with the georeferencing information of our image, essential for constructing mosaics from orthophotos.
The rectification result is quite spectacular and simple beyond the planning of placing reference points in our scene, since our image is corrected until it fits the coordinates of those points, so it is a highly recommended process if we want to provide our images with a certain geometric rigor, beyond the spectacular results of panoramic photography or wide-angle lenses.
