问题描述
我正在尝试学习关于图像处理的课程,并且作为其中的一部分,如果使用 cv2.下面是我的代码:
def DoJpegCompression(img):
(h,w) = img.shape[:2]
for x in range(0,h,8):
for y in range(0,w,8):
avg3x3 = img[x:x+8,y:y+8]
(h1,w1) = avg3x3.shape[:2]
if h1%2 == 0 and w1%2 == 0:
#print(avg3x3,file = open("input.txt",'a'))
iDct = numpy.zeros(avg3x3.shape[:2],dtype = numpy.float32)
getDctimage(avg3x3.astype(numpy.float32),iDct)
#print(iDct,file = open("dct.txt",'a'))
iQuant = getQuantizedImage(iDct,2)
print(iQuant,file = open("Quantized.txt",'a'))
img[x:x+8,y:y+8] = iQuant.astype(int)
pass
pass
pass
print(img,file = open("Compressed.txt",'a'))
在这里,我看到“Quantized.txt”中的值与“Compressed.txt”中的值不同,并且差异很大。从某种意义上说,“Compressed.txt”中存在某些值在量化值中只是零。
这里可能出了什么问题:img[x:x+8,y:y+8] = iQuant.astype(int)
?
任何线索表示赞赏。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)