Ask Your Question

Revision history [back]

How to determine if an image/video is pixelated or not

I have come across a use case where i have to determine if a video/frame is pixelated or not.

I was refering link text but it doesn't work for me. Please suggest the solution

How to determine if an image/video is pixelated or not

I have come across a use case where i have to determine if a video/frame is pixelated or not.

I was refering link textstackoverflowImagepixelation but it doesn't work for me. Please suggest the solution

click to hide/show revision 3
None

updated 2018-12-05 10:12:28 -0600

berak gravatar image

How to determine if an image/video is pixelated or not

I have come across a use case where i have to determine if a video/frame is pixelated or not.

I was refering stackoverflowImagepixelation but it doesn't work for me. Please suggest the solution

import numpy as np
import Image, ImageChops

im = Image.open('tryanypixelatedimagefromGoogle.jpeg')    
im2 = im.transform(im.size, Image.AFFINE, (1,0,1,0,1,1))
im3 = ImageChops.subtract(im, im2)
im3 = np.asarray(im3)
im3 = np.sum(im3,axis=0)[:-1]
mean = np.mean(im3)
peak_spacing = np.diff([i for i,v in enumerate(im3) if v > mean*2])
mean_spacing = np.mean(peak_spacing)
std_spacing = np.std(peak_spacing)
print 'mean gap:', mean_spacing, 'std', std_spacing