【问题标题】:opencv resize changing the RGB valuesopencv调整大小改变RGB值
【发布时间】:2020-10-08 10:50:31
【问题描述】:

使用 opencv resize 我注意到图像在向上和向下调整大小后变得模糊。有没有办法,我在调整大小后消除图像中的模糊?`我相信这个问题是由于采样问题...... 2 images before zoomreset and after zoomreset is shared here for reference

Image2 shows there is a change in color around a solid color

def zoomreset(self):

    imagergb=self.bae.image
    originalimage=cv2.imread('original.png')
    imagergb.save('resetzoomed.png')
    cvresetzoomimage=cv2.imread('resetzoomed.png',cv2.IMREAD_UNCHANGED)
    # pixels_x=self.bae.image.width
    # pixels_y = self.bae.image.height
    pixels_x=self.orgwdth
    pixels_y=self.orghght
    dim=(int(pixels_x),int(pixels_y))
    cvresetzoom=cv2.resize(cvresetzoomimage,dim,interpolation=cv2.INTER_AREA)
    # cv2.imshow("Resized Image", cvresized)
    cv2.imwrite('resetzoomedimage.png',cvresetzoom)
    self.bae.image=Image.open('resetzoomedimage.png')
    self.tkinter_image = PIL.ImageTk.PhotoImage(self.bae.image)
    self.show_image()
    self.image_canvas.configure(scrollregion = self.image_canvas.bbox("all"))
    self.image_canvas.config(width=int(pixels_x), height=int(pixels_y), scrollregion=(0, 0, int(pixels_x), int(pixels_y)))

【问题讨论】:

    标签: python image opencv resize rgb


    【解决方案1】:

    如果缩小图像,无论采用何种插值方法,都会丢失像素值。同样,如果您尝试使用像素算法的现有值放大图像进行插值。

    您可以研究插值算法(最近邻、Inter_linear、..)它们的工作原理以便更好地理解。

    【讨论】:

      猜你喜欢
      • 2015-03-20
      • 2017-05-12
      • 1970-01-01
      • 1970-01-01
      • 2014-07-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多