Reputation: 1884
I want to fix the bottom right area of the fingerprint image that is overexposed which make harder to see the ridge. I have tried to divide the image into 4 sub-images and apply histogram equalization to each one but the result is quite bad, it appears the line on the edge of the sub-image.
Original image Image after applied histogram equalization
Here is my code of histogram equalization:
img = cv.imread('fingerptint.jpg', cv.IMREAD_UNCHANGED)
img = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
dst = cv.equalizeHist(img)
cv.imwrite('fingerprint_hist.jpg', dst)
Upvotes: 2
Views: 2887
Reputation: 735
OpenCV's Adaptive Gaussian Thresholding is not originally meant to fix this, but it produces an image with almost no overexposure and some processing artifacts as downside. Depending on the kind of processing that you are using in later steps, it could be useful.
import cv2
import urllib
import numpy as np
from matplotlib import pyplot as plt
req = urllib.request.urlopen('https://i.sstatic.net/9AP7J.jpg')
arr = np.asarray(bytearray(req.read()), dtype=np.uint8)
img = cv2.imdecode(arr, -1)
img_gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
img_th = cv2.adaptiveThreshold(
img_gray,
255,
cv2.ADAPTIVE_THRESH_GAUSSIAN_C,
cv2.THRESH_BINARY,
11,
1
)
plt.subplot(1, 2, 1)
plt.imshow(img_gray, 'gray')
plt.title('Original Image')
plt.xticks([]),plt.yticks([])
plt.subplot(1, 2, 2)
plt.imshow(img_th, 'gray')
plt.title('Adaptive Gaussian Thresholding')
plt.xticks([]),plt.yticks([])
plt.show()
Upvotes: 1