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)
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)
def generateInferior2MeanMatrix(self): if self.GEN_MEAN_INF_ZONE_MAT: vietImcp = self.loadImageCol() vietslice = vietImcp[:, 550:600] carver = SeamMarker(img=vietImcp) emap = carver.calc_energy(vietslice) normalized = normalizeImageVals(emap.copy()) # vietEmap = ImageOps.grayscale(Image.fromarray(emap)) funcs = SeamFuncsAI() zones = funcs.getInferior2MeanZones(normalized) np.save(self.mean_inf_zone_mat_path, zones)
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")
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" )
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")
def test_seammarker_minimum_seam_ai(self): vietImcp = self.loadImageCol() vietslice = vietImcp[:, 550:600] carver = SeamMarker(img=vietImcp) emap = carver.calc_energy(vietslice) funcs = SeamFuncsAI()