阅读背景:

使用numpy和cv2操作大型二进制图像数组

来源:互联网 

My code is the following:

我的代码如下:

import cv2; import numpy as np

class MyClass:
    def __init__(self,imagefile):
        self.image = cv2.imread(imagefile)

        #image details
        self.h,self.w = self.image.shape[:2]
        #self.bPoints, self.wPoints = np.array([[0,0]]),np.array([[0,0]])
        self.bPoints, self.wPoints = [],[]

        #CAUTION! Points are of the form (y,x)
        # Point filtering
        for i in xrange(self.h):
            for j in xrange(self.w):
                if self.th2.item(i,j) == 0:
                    #self.bPoints = np.append([[i,j]], self.bPoints, axis=0)
                    self.bPoints.append((i,j))
                else:
                    self.wPoints.append((i,j))
                    #self.wPoints = np.append([[i,j]], self.wPoints, axis=0)

        #self.bPoints = self.bPoints[:len(self.bPoints) - 1]
        #self.wPoints = self.wPoints[:len(self.wPoints) - 1]
        self.bPoints, self.wPoints = np.array(self.bPoints), np.array(self.wPoints)
import cv



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: