Пример #1
0
 def generateBacktrackSliceMatrix(self):
     if self.GEN_SLICE_BACKTRACK_MAT:
         vietcp = self.loadImageCol()
         vietslice = vietcp[:, 550:600]
         carver = SeamMarker(img=vietcp)
         emap = carver.calc_energy(vietslice.copy())
         mat, backtrack = carver.minimum_seam(img=vietslice, emap=emap)
         np.save(self.slicemat_backtrack_path, backtrack)
Пример #2
0
 def generateSliceMatrix(self):
     if self.GEN_SLICE_MAT:
         img = self.loadImageCol()
         viet = np.array(img.copy(), dtype=np.uint8)
         vietslice = viet[:, 550:600]
         carver = SeamMarker(img=None)
         emap = carver.calc_energy(viet.copy())
         mat, backtrack = carver.minimum_seam(img=vietslice.copy(),
                                              emap=emap)
         np.save(self.slicemat_path, mat)
Пример #3
0
 def test_seammarker_minimum_seam_emap_matrix(self):
     "tests the minimum seam function of pointcarver"
     matrixPath = os.path.join(self.npdir, "vietSliceMatrix.npy")
     compmatrix = np.load(matrixPath)
     vietImcp = self.loadImageCol()
     vietslice = vietImcp[:, 550:600]
     carver = SeamMarker(img=vietImcp)
     emap = carver.calc_energy(vietslice)
     mat, backtrack = carver.minimum_seam(img=vietslice, emap=emap)
     self.compareArrays(
         mat, compmatrix,
         "Point carver minimum seam function emap given, checking matrix")
Пример #4
0
    def test_seammarker_minimum_seam_emap_backtrack(self):
        backtrackPath = os.path.join(self.npdir, 'vietSliceBacktrack.npy')
        compBacktrack = np.load(backtrackPath)

        vietcp = self.loadImageCol()
        vietslice = vietcp[:, 550:600]
        carver = SeamMarker(img=vietcp)
        emap = carver.calc_energy(vietslice)
        mat, backtrack = carver.minimum_seam(img=vietslice, emap=emap)
        self.compareArrays(
            backtrack, compBacktrack,
            "Point carver minimum seam function emap given, checking backtrack"
        )
Пример #5
0
 def test_seammarker_calc_energy(self):
     "tests the calc energy function of pointcarver"
     vietEmap = Image.open(self.emap_path)
     vietEmap = ImageOps.grayscale(vietEmap)
     vietImg = self.loadImageCol()
     vietEmap = np.array(vietEmap, dtype=np.uint8)
     #
     vietImcp = vietImg.copy()
     vietEmapcp = vietEmap.copy()
     #
     carver = SeamMarker(img=vietImcp)
     emap = carver.calc_energy(vietImcp)
     emap = np.interp(emap, (emap.min(), emap.max()), (0, 256))
     emap = np.uint8(emap)
     self.compareArrays(emap, vietEmapcp,
                        "Point carver energy calculation function")