Login

forbidden the porn image

Author:
dingdongquan
Posted:
December 27, 2010
Language:
Python
Version:
Not specified
Score:
3 (after 3 ratings)

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. Template tag - list punctuation for a list of items by shapiromatron 3 months, 2 weeks ago
  2. JSONRequestMiddleware adds a .json() method to your HttpRequests by cdcarter 3 months, 3 weeks ago
  3. Serializer factory with Django Rest Framework by julio 10 months, 2 weeks ago
  4. Image compression before saving the new model / work with JPG, PNG by Schleidens 11 months, 1 week ago
  5. Help text hyperlinks by sa2812 12 months ago

Comments

Please login first before commenting.