I’m trying to make an image uniformly bright using a morphological closing operation, as a prelude to an adaptive threshold. My method is to divide each pixel in the image by the value of that pixel after the closing operation, then normalize:
Imgproc.GaussianBlur(sudokuImage, sudokuImage, new Size(5,5), 0);
Mat kernel = Imgproc.getStructuringElement(Imgproc.MORPH_ELLIPSE, new Size(11,11));
Imgproc.morphologyEx(image, closedImage, Imgproc.MORPH_CLOSE, kernel);
Core.divide(image, closedImage, image);
Core.normalize(image, image, 0, 255, Core.NORM_MINMAX);
Here is the result:
- Top left – original image
- Top right – after Gaussian blur
- Bottom left – result of the closing operation
- Bottom right – final result

I’d like the final image to be less washed-out, more like the image below (which was obtained using what looks like the same method in this post). How can I accomplish this?

Maybe the problem lies in the dividing step which you seem to perform on ints while the post you link to perform on floats.