this is my first question, any criticism is welcome.
I've been trying to implement the sharpness estimator presented in section 2.2 of this paper, using Python and OpenCV, but haven't been very succesful.
First I load the Original Image:
and crop the face using the landmarks, resulting in this Landmark Cropped Picture
.
Then I run the custom Laplace Filters presented on the paper:
# Custom kernels for laplace filter
kernel1 = np.array([[1, -2, 1]])
kernel2 = np.array([[1],
[-2],
[1]])
# Use custom Laplace filter to obtain contours and edges, the more sharp an
# image is the greater the response from the laplace filter
pass1 = cv2.filter2D(cropped_image, cv2.CV_32F, kernel1)
pass2 = cv2.filter2D(cropped_image, cv2.CV_32F, kernel2)
# Get the magnitude (absolute value) of pass1 and pass2
pass1 = np.absolute(pass1)
pass2 = np.absolute(pass2)
# Sum the response from both filters
lap_sum = cv2.add(pass1, pass2, dtype=cv2.CV_32F)
Here's where things seem to go wrong, the expected result would look something like this:
but I get this instead:
.
Furthermore, the paper says that the final measure is the
"averaged Laplace operator response by masked image"
and that the score should fall in the interval of [0.0, 1.0]
. However for that to happen I had to average only non-zero pixels and normalize the final score, and even then I get an abismal score of 0.1 that I think should be higher for the picture I used in this example.
I have implemented it on colab if you want to run it yourself, should be easier to interpret my results seeing the code and the pictures. Thank you very much.