Exemplo n.º 1
0
def test_inpainted_input_output_spec_check():
    img1 = cv2.imread('./fixture/real_proj/images/bw1.png')
    img2 = cv2.imread('./fixture/real_proj/images/bgr1.png')
    seg1 = core.segmap(img1)
    seg2 = core.segmap(img2)
    ret1 = core.inpainted(img1, seg1)
    ret2 = core.inpainted(img2, seg2)
Exemplo n.º 2
0
    def rm_txt(self):
        imgpath  = state.now_image()
        maskpath = state.now_mask()
        if imgpath is None: return None

        self.saveMask.emit(maskpath) # save edited mask
        image = io.load(imgpath, io.IMAGE)
        mask  =(io.load(maskpath, io.MASK) 
                if Path(maskpath).exists()
                else io.mask2segmap(self.gen_mask()))
        inpainted = core.inpainted(image, mask)

        io.save(state.now_image(), inpainted) 
        self.update_gui()
Exemplo n.º 3
0
 def segmentPage(self,imgPath,outputInpaintedPath,outputTextOnlyPath):
     
     self.resize(imgPath)        #because of sickzil has poor quality on high resolution image
     
     
     #process sickzil
     fileName=os.path.basename(imgPath)
     oriImage = imgio.load(imgPath, imgio.IMAGE)                      #ori image
     maskImage  = imgio.mask2segmap(self.imgpath2mask(imgPath))        #mask image
     inpaintedImage = core.inpainted(oriImage, maskImage)        #notext image
     textOnlyImage= cv2.bitwise_and(oriImage,maskImage)         #text only image
     textOnlyImage[maskImage==0] = 255                     
     imgio.save(outputInpaintedPath+fileName, inpaintedImage)
     imgio.save(outputTextOnlyPath+fileName, textOnlyImage)
    def segmentImage(self, downloadFileList, inpaintedFolder, textOnlyFolder):
        # image segmentation
        for i, imgPath in enumerate(tqdm(downloadFileList)):
            print("image path: ", imgPath)
            fileName = os.path.basename(imgPath)
            oriImage = imgio.load(imgPath, imgio.IMAGE)  #ori image
            # imgpath2mask(imgPath)
            # mask image is a black image with features (text) being white
            maskImage = imgio.mask2segmap(
                self.imgpath2mask(imgPath))  #mask image
            # remove all the text from the original image
            # this is used later on to write new translated texts on it.
            inpaintedImage = core.inpainted(oriImage, maskImage)  #notext image

            # convert all the texts from white to black color (white-white => white, else black)
            # we need to convert to black color text for what ?
            # for easier reading and easier for oct algo to detect text
            textOnlyImage = cv2.bitwise_and(oriImage,
                                            maskImage)  #text only image
            #if i==0:
            #cv2.imshow("text_only_img", textOnlyImage)
            textOnlyImage[maskImage == 0] = 255
            imgio.save(inpaintedFolder + fileName, inpaintedImage)
            imgio.save(textOnlyFolder + fileName, textOnlyImage)
Exemplo n.º 5
0
def rm_txt(imgpath, maskpath, outputpath):
    if imgpath is None: return None
    image = io.load(imgpath, io.IMAGE)
    mask = io.load(maskpath, io.MASK)
    inpainted = core.inpainted(image, mask)
    io.save(outputpath, inpainted)