python如何判断图片分辨率_在python中检测像素化图像

本文介绍了如何在Python中检测像素化的图像。建议的方法包括获取像素的相邻邻居以检查RGB值的跳跃,以及使用OpenCV进行边缘检测和轮廓大小分析。提供了一个get_neighbors函数来获取像素周围的邻居,并提出了使用边缘检测作为更简单且健壮的解决方案。
摘要由CSDN通过智能技术生成

I'm trying to determine if an image is squared(pixelated).

I've heard of 2D fourrier transform with numpy or scipy but it is a bit complicated.

The goal is to determine an amount of squared zone due to bad compression like this (img a):

解决方案

I have no idea if this would work - but, something you could try is to get the nearest neighbors around a pixel. The pixellated squares will be a visible jump in RGB values around a region.

You can find the nearest neighbors for every pixel in an image with something like

def get_neighbors(x,y, img):

ops = [-1, 0, +1]

pixels = []

for opy in ops:

for opx in ops:

try:

pixels.append(img[x+opx][y+opy])

except:

pass

return pixels

This will give you the nearest

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值