I am trying to tell whether an image is pixelated or not. I was trying to use the laplacian variance method to do this, but I'm not sure that it is working correctly because a pretty distorted/pixelated image comes back with a very high variance of 1011 using my code:
import sys
import cv2
import imutils as im
csv_filename = sys.argv[1]
def variance_of_laplacian(image):
# compute the Laplacian of the image and then return the focus
# measure, which is simply the variance of the Laplacian
# image = cv2.copyMakeBorder(image, 100, 100, 100, 100, cv2.BORDER_CONSTANT, value = [255, 255, 255])
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
# invert gray image
gray = 255 - gray
# cv2.imshow("result", gray)
# cv2.waitKey(0)
laplacian_var = cv2.Laplacian(gray, cv2.CV_64F).var()
return laplacian_var
image = im.url_to_image(sys.argv[1])
laplacian_var = variance_of_laplacian(image)
print laplacian_var
Is there another method to detect pixelation in an image or something like that?
Here is one image that I would deem pixelated/distorted/blurry for my tests:








