Beispiel #1
0
    def select_lines(self):
        image_gray = img_fun.image_gray(self.image)
        image_bin = cv2.adaptiveThreshold(image_gray, 255, cv2.ADAPTIVE_THRESH_MEAN_C, cv2.THRESH_BINARY_INV, 33, 5)

        horizontalsize = 50
        horizontalStructure = cv2.getStructuringElement(cv2.MORPH_RECT, (horizontalsize, 1))
        image_bin = cv2.erode(image_bin, horizontalStructure, iterations=1)
        image_bin = cv2.dilate(image_bin,horizontalStructure, iterations=1)

        # image_bin = cv2.dilate(image_bin,np.ones((2,500)), iterations=1)
        image_bin = cv2.dilate(image_bin,np.ones((2,200)), iterations=1)


        img,reg,pos = self.select_horizontal_lines(self.image.copy(),image_bin)

        lines,groups = npt.add_additional_lines(pos)

        self.lines = lines
        self.groups = groups

        # cv2.imshow('lines',cv2.resize(image_bin, (1000, 750), interpolation=cv2.INTER_NEAREST))
        # cv2.waitKey(0)
        # cv2.imshow('aaaaaaaaaa',img)

        img_fun.show_image('bin',image_bin)
        img_fun.show_image('img' ,img)
Beispiel #2
0
    def get_groups(self,image):
        gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)


        ret, image_bin = cv2.threshold(gray, 180, 255, cv2.THRESH_BINARY)

        image_bin=img_fun.invert(image_bin)

        horizontalsize = 200;
        horizontalStructure = cv2.getStructuringElement(cv2.MORPH_RECT, (horizontalsize, 1));

        image_bin = cv2.erode(image_bin, horizontalStructure, iterations=1)
        image_bin = cv2.dilate(image_bin,horizontalStructure, iterations=1)

        image_orig, selected_regions, lines = nt_fun.select_horizontal_lines(image.copy(), image_bin)

        lines,groups = nt_fun.add_additional_lines(lines)

        return groups