Valentin H
Valentin H

Reputation: 7448

Equalize image brightnes of an optical system

There is a camera attached to a 200x microscope. The image shows the un-even distribution of the brightnes caused either by the camera matrix or by the lightning or by both.

image diagonal profile

I want to equalize the pixel brightnes. It is not easy to find a material, which I can use for the callibration. The paper e.g. in that microscpe looks like a landscape - the surface is not equal. My idea is to move the microscope out of focus during the device calibration and make an image. Using that distribution it should be possible to calculate the correction value per pixel. Unfortunatelly, it looks like the factors vary depending on the exposure. But it is still feasible.

For me it looks like a very common problem. Does OpenCV provide something to handle it?

P.S. On single images this uneven distribution of the brightnes is not an issue. It becomes visible, when big surfaces are scanned and stitched.

Upvotes: 0

Views: 67

Answers (1)

Jason
Jason

Reputation: 13964

I had to solve a similar problem a while back. Is this the same throughout all color channels? You could:

  1. Blur the image with cv::blur(...)
  2. Scale the minimum of the blurred image down, so the the minimum is now zero
  3. Subtract that blurred image from all input images with cv::subtract(...)

The full code would look like this:

// Input matrix
// Image with "nothing"
Mat colorProfile = ...;

// Blur
blur(colorProfile, colorProfile, Size( 3, 3), Point(-1,-1));

// Translate the pixels down
double min, max;
minMaxLoc(colorProfile, &min, &max);
colorProfile = colorProfile - min

// Then for every image:
Mat inputImage = ...;

subtract(inputImage, colorProfile, inputImage);

Upvotes: 2

Related Questions