I am working with images that I need to process. However, only specific areas of these images are of interest so for each image I have a corresponding mask (that can be of any shape, not a bounding box or anything specific). I would like to do Histogram Equalization but only on the "masked surface" as I am not interested in the rest of the image.
A similar question has been asked here, however the solutions proposed rely on bounding boxes or equalizing the whole image which is not my goal.
Any solution using Histogram Equalization or CLAHE, RGB or grey scale images would be interesting
This is possible. Here is a simple approach:
Flow:
You can perform histogram equalization for a given region with the help of the mask.
Code:
The following is an illustration using a grayscale image.
The following is the mask:
I want to perform histogram equalization only on the flower.
Store the coordinates where pixels are white (255) in
mask:Store all pixel intensities on these coordinates present in
gray:Perform histogram equalization on these pixel intensities:
Create a copy of
graynamedgray2. Place the equalized intensities in the same coordinates:Comparison: