# Matching colours in already mosaiced single image? [closed]

I have an already mosaiced image for a large area. I need to match colours in this single image. I do not have each image separately. I just have this large single image downloaded from GLS. How can I match the colour of this image if I do not have its image in parts? I did a Histogram match but it does not work. Please provide me steps for any of the following:

• Erdas 2014
• ArcGIS
• ENVI
• QGIS

• you can´t, maybe you can separate it in parts and then match the histogram.
– Pau
Commented Sep 30, 2014 at 12:19
• That could help indeed. Cut the mosaic into pieces, apply some LUT stretch to each piece for making them to look about similar and combine to a new mosaic with ERDAS Mosaic Pro. Commented Sep 30, 2014 at 14:24
• I think you have to use Photoshop to change the color. But this is a tricky work.
– JZH
Commented Oct 1, 2014 at 14:20

The image needs to be cut apart and re-mosaiced after adjusting the colors in each piece. This can be done.

As an example, I extracted the green band of the image. To make my work simple (the computing platform I am using, Mathematica 9, does not easily extract pixels along arbitrary polylines), I rotated it to make some of the image boundaries perfectly horizontal and then focused on one of them in the middle of the image. I extracted the rows immediately above and below the apparent seam, shown in orange at the right of the figure below. (It comprises only 232 pixels, which is relatively limited information.) The "Profiles" plots in the middle of the figure show the intensities moving across this seam, with the profile lower in the image drawn in blue and the profile higher in the image drawn in red. The clear systematic difference in the two profiles reflects the relative lightness of the lower patch.

The scatterplot compares lower pixels to their nearest upper counterparts on log-log axes. This is the key idea: although there is substantial amount of scatter around a line, nevertheless a linear relationship is still apparent. By fitting a line appropriately to this scatterplot, we can recover a good estimate of the amount of correction to make in order to match the two sides.

Although many people would reflexively resort to using least squares to fit this line, that would be incorrect. The reason is that neither of the two patches should be favored as the "independent variable", but rather the two should be treated in a symmetrical fashion. Instead, the slope of the line, "gamma," was estimated in a robust way as the median ratio of the logarithms of the pixel intensities. The lower patch was gamma-corrected using this value (of 1.32), which darkened it, and re-mosaiced to the upper patch. The new "corrected" mosaic is shown at the left next to the original.

Even though the portions of the images used to compute the gamma correction did not overlap--they were separated by two pixels in the original mosaic--enough information remained in this cross-boundary comparison to do an adequate job of matching one patch to another. By choosing one reference patch and performing a sequence of gamma corrections across the full image, one could achieve noticeable improvement throughout.

This gamma correction can be applied separately to each band, finally reassembling the bands into a full-spectrum image.

Automating this process would require identifying the separate patches. I suppose these could be found with a clustering algorithm (supervised or unsupervised), but I have not implemented or tested one.

Although this approach is not perfect--starting with the original images and re-mosaicing them would be better--it shows potential to create a noticeable improvement, which at the least could be used as the starting point for any further efforts (such as the feathering mentioned in another answer).

• Good approach indeed! Assuming this imagery is multispectral, according to your experience, is there a way to reflect this correction factor onto other bands instead of recalculating for each band separately, say if you calculate correlation between the bands? Maybe I should raise this a separate question but was thinking the answer would be a simple yes or no. Commented Jun 29, 2016 at 6:21
• @fatih That's a very interesting and challenging question. Many possible solutions come to mind. They depend on the specifics of how the pieces of the image vary from one block to the next and from one wavelength to the next. If in fact the correction factors vary slowly with wavelength, then you could incorporate that in a statistical model and exploit it in the mosaicing. But I cannot tell you what model to use: that would require further study of the set of images in question. Commented Jun 29, 2016 at 12:14

Histogram matching works by forcing the histogram of one image to match as closely as possible the histogram of a second target image. I'm afraid that it won't work on a single image. (There is the exception of using Histogram Matching to force an image to theoretical distribution, like the Gaussian, but that won't help in this case either.) Also, I'm not sure that histogram matching would be the preferred way of creating a seamless mosaic anyhow. Or rather, histogram matching would only serve as the pre-processing step for the preferred method. Instead, feathering techniques, which perform a weighted combination of two partially overlapping images based on the distance to an edge. Unfortunately, unless you have the original images from which the mosaic image was created, I don't think that there is much you can do to reduce the edge effects in this image. Filtering techniques (blur) may be useful to lessen the severity of the edges, but it will also degrade the overall quality of the image, so I wouldn't recommend it as an approach.

EDIT

The reason that I'm saying that histogram matching is not a good approach here is that there is no basis for assuming that the distribution of values should be similar across borders of adjacent images. Take the two tiles highlighted using the yellow and blue polygons below. Despite being neighbouring tiles, they contain vastly different landcover, with one being largely mountainous while the other is a steppe or lowland. Forcing them to have the same histogram is unlikely to produce satisfactory results. You may try to perform a localized histogram matching technique across the boundaries between tiles but you will run into exactly the same problem. Take the location designated by the large cyan coloured dot below as an example. On one side of the boundary, it is largely vegetated while on the opposite side it is largely open water. Again, matching techniques won't work well here and filtering away the edges will only result in overall degradation of image quality. A weighted combination in areas of overlap, i.e. feathering, is definitely the best approach for this particular problem. The mosaic appears to be composed of either Landsat or SPOT images. If this is the case, then I would guess that the raw images are widely available and that you have the opportunity to create a seamless mosaic by going back to these images.

• I don't think it's as bad as all that. Wherever there is a contrast large enough to be of concern, then (in principle) the edges of the component image can automatically be detected. The pixels along the boundary of that patch could be matched to the pixels across the boundary in order to estimate an equalizing transformation. In effect, the image could be cut apart and re-mosaiced. Commented Oct 1, 2014 at 19:22
• @whuber I truly like how positive you are about these things and I know your skills are such that you may be able to achieve good results. (You probably know about some magic method for doing it!) My issue is that cutting the mosaic apart won't bring back the overlapping areas between tiles, which are needed to make a good seamless mosaic. And matching across tile boundaries can also be problematic; I've edited the answer to reflect this reasoning. Commented Oct 1, 2014 at 20:11
• I think your edit may be too speculative (and negative) :-). Although you are correct that those polygons "contain vastly different landcover," the difference across the boundary can be quantified and estimated with reasonable accuracy. I posted an answer to explain how and illustrate the result. Commented Oct 1, 2014 at 21:57

What about using **Seamless Mosaic**of ENVI. I use this to interactively generate seamless mosaic image.This tool has several functionalities some of them as below:

1. You can color correct the images
2. You can generate image seam automatically
3. You can define feathering distance
4. You can set no data/ background value as you want
5. Finally what is the most amazing is you can interactively see the preview of the output and can change the parameters accordingly until you get the correct output.

P.S. I am not affiliated to ENVI