forbidden the porn image

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
import sys, Image

img_name = sys.argv[1]
img = Image.open(img_name).convert('YCbCr')
w, h = img.size
data = img.getdata()
cnt = 0

for i, ycbcr in enumerate(data):
    y, cb, cr = ycbcr
    if 86 <= cb <= 117 and 140 <= cr <= 168:
        cnt += 1

print '%s %s a porn image.'%(img_name, 'is' if cnt > w * h * 0.3 else 'is not')

More like this

  1. thumbnail an image by limodou 7 years, 1 month ago
  2. Image inlining template tag example by rbeck 3 years, 5 months ago
  3. Sharpening images by rajeshd 7 years, 1 month ago
  4. Handling Image uploading and Delete Old Image in Django by mulianto 1 year, 11 months ago
  5. Image Standarization by garcia_marc 6 years ago

Comments

(Forgotten your password?)