for f in fileNames: fname, suffix = Common.getFileNameAndSuffix(f) if suffix in Opt_dmtler.validImageFormat: filename = os.path.join(dirPath, f) # Loading Images img = cv.imread(filename) print filename # node_list = Dmtler.dismantle(img) if len(img.shape) == 3: img = cv.cvtColor(img, cv.COLOR_BGR2GRAY) root0, count_standalone = Dmtler.split(img, 0) map0 = Dmtler.getSalientMap(img, root0) root1, count_standalone = Dmtler.split(img, 1) map1 = Dmtler.getSalientMap(img, root1) map = (map0 + map1) / 2 # Dismantler.showImg(map) savePath = os.path.join(resultPath, f) # print savePath cv.imwrite(savePath, map) nImageAll += 1 if nImageAll % 100 == 0: print '%d images have been mapped.' % nImageAll