PSD文件保存图层为PNG加入图像的噪声

时间:2015-07-17 08:31:52

标签: python opencv python-imaging-library pillow

我正在研究角点检测。我有一个3层的PSD文件,我想只提取我要提取的角落的1层。

  1. 使用psd-tool我提取图层:

    if layer.name == 'Layer 3':
    img = layer.as_PIL().save("tmp.png")
    
  2. 接下来我阅读了tmp.png文件并执行以下操作:

    img = cv2.imread(filename)
    gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
    (thresh, im_bw) = cv2.threshold(gray, 1, 255, cv2.THRESH_BINARY)
    cv2.imwrite('bw_image.png', im_bw)
    
    
    _ ,contours, hierarchy = cv2.findContours(im_bw, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
    
    contours = sorted(contours, key=cv2.contourArea,reverse=True)[:1]
    
    cv2.drawContours(img, contours, -1, (0,255,0), 5)
    
    cv2.imwrite("image_processed.png", img)
    
  3. 但是如果我手动提取图层并保存它。算法工作正常并返回4个角点。

    请在这里建议可能出现的问题。

0 个答案:

没有答案
相关问题