Reputation: 497
I'm trying to recreate an algorithm (from this publication) on Python's OpenCV to detect if an image has a washed-out effect or not.
The paper states the following:
"Washed out images have a reduced dynamic range (in the gray-scale image) with respect to images with natural colors. The compliance score is simply calculated by rescaling the dynamic range of the gray-scale image to [0;100]"
The problem is, I dont understand what a grayscale dynamic range is.
Is this about calculating the difference between the min and max pixel value of a grayscale image [0-255] and rescale that value to a range of [0-100]?
Upvotes: 4
Views: 1092
Reputation: 21233
I found the paper on researchgate.com. The paper talks about the various standards that face images have to pass in order to be labelled as machine readable. Because machines unlike humans cannot understand face images under various conditions like lighting, occlusion, pose difference, etc. There was not much info regarding ICAO 13 apart from the statement in the question. So I presume it would be the following way.
Converting the gray-scale image to a dynamic range according to ICAO 13 can be done the following way:
I have taken a sample image from the OpenCV docs to illustrate this:
Code:
import cv2
import numpy as np
img = cv2.imread(path + 'wiki.jpg', 0)
print(((np.max(img) - np.min(img)) * 100) / 255)
cv2.imshow(path + 'normal.jpg', img)
equ = cv2.equalizeHist(img)
print(((np.max(equ) - np.min(equ)) * 100) / 255)
cv2.imshow(path + 'equalized.jpg', equ)
Result:
Dynamic range of original image : 36
Dynamic range of equalized image : 100
Original Image:
Equalized Image:
Now since you have the value between 0 - 100, you can select a threshold value (say 85) and say that images having value of 85 and above are qualified as machine-readable. If the value is below the threshold, discard the image.
Upvotes: 4