Brightness equalization between different images I am dealing with a proprietary whole slide image format from 3DHistech, namely MRXS. This image is produced by scanning a glass slide biopsy. The scanner takes pictures at certain positions which eventually make up one big image (in the range of hundreds of thousands pixels per side). 

Subsequently, the software produces downscaled versions of the original image, effectively generating a pyramid, in order to make viewing the image faster.

The camera pictures, as well as the downscaled versions, are saved as small rectangular JPEG images, usually around 300x300 pixels. 

I have written a parser for the image and I am able to render these digital slides appropriately. However, I came across some slides that have different brightness (?) among tiles. It seems that the vendor's software does compensate for this, while my software obviously doesn't. 

I have opened some of the JPEG streams in Photoshop (among other tools), and I was able to manually fix the brightness difference and make the image look smooth. My question therefore, is what kind of algorithm could I incorporate to do this automatically as I render these images?

I am attaching a sample original tile produced by the scanner software and an edited version I did in Photoshop.

ORIGINAL


EDITED
You could do Histogram equalization on the histogram of brightness values across all tiles.

Alternatively, you can loop over all tiles, accumulate the minimum and maximum brightness value of each tile, and then scale all brightness values in all tiles against the overall minimum/maximum.