geo*_*ram 2 python android image-processing
我有一个Android应用程序,其中包含用户提供的图像.有很多用户向后端应用程序提交黑色或非常暗的图像,我想过滤掉.最佳解决方案是过滤手机上已有的图像,并通知用户更多光线并重新拍摄照片.如果更容易实现的另一个解决方案是在python中编写的后端过滤它.我看了一下opencv,但我真的不知道从哪里开始.任何提示在哪里获取信息来测量Android和/或python中图像的亮度/颜色?
您可以尝试使用图像的直方图作为第一个近似值.
使用PIL的示例,如果存在更多"暗"像素(灰度表示中的前128个值)而不是"浅"像素,则会提醒您:
import Image
img = Image.open('m.jpg')
gsimg = im.convert(mode='L')
hg = gsimg.histogram()
# count should be 256 most/all of the time (an index for each shade of grey)
count = len(hg)
if sum(hg[:count/2]) > sum(hg[count/2:]):
print "the image is too dark"
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1929 次 |
最近记录: |