diff --git a/FGLG.py b/FGLG.py index aecad58..7873649 100644 --- a/FGLG.py +++ b/FGLG.py @@ -14,7 +14,7 @@ def fglg(img): height,width = np.shape(img) Npix = height * width - scipy.misc.imsave('original_img.jpg',img) + cv2.imwrite('original_img.jpg',img) hist = cv2.calcHist([img],[0],None,[256],[0.0,255.0]) # show histogram of the original image @@ -130,6 +130,9 @@ def main(): if not os.path.isfile(options.img): parser.error("Image %s does not exist.)" % options.network) res = options.res + + e1 = cv2.getTickCount() + img = cv2.imread(options.img,cv2.IMREAD_GRAYSCALE) Trans,PixDist = fglg(img) height, width = np.shape(img) @@ -139,8 +142,14 @@ def main(): for j in range(0,width): image[i][j] = Trans[img[i][j]] #print GLG.ten(img),GLG.ten(image) - scipy.misc.imsave(res,image) - print 'ten:', GLG.ten(image) - print "The PixDist is %.1lf" %PixDist + cv2.imwrite(res,image) + print ('ten:', GLG.ten(image)) + print ("The PixDist is %.1lf" %PixDist) + + e2 = cv2.getTickCount() + t = (e2 - e1)/cv2.getTickFrequency() + print ("Execution took '%(val).3f' seconds." % {'val': t}); + + if __name__ == '__main__': - main() \ No newline at end of file + main() diff --git a/GLG.py b/GLG.py index 0d8d579..5e6dc4c 100644 --- a/GLG.py +++ b/GLG.py @@ -4,6 +4,7 @@ import scipy.misc import os #import matplotlib.pyplot as plt +import imageio import warnings from argparse import ArgumentParser warnings.filterwarnings("ignore") @@ -53,7 +54,7 @@ def ten(img): def glg(img): height,width = np.shape(img) Npix = height * width - scipy.misc.imsave('original_img.jpg', img) + cv2.imwrite('original_img.jpg', img) hist = cv2.calcHist([img], [0], None, [M], [0.0, 255.0]) #show histogram of the original image ''' @@ -180,6 +181,9 @@ def main(): if not os.path.isfile(options.img): parser.error("Image %s does not exist.)" % options.network) res = options.res + + e1 = cv2.getTickCount() + img = cv2.imread(options.img, cv2.IMREAD_GRAYSCALE) Trans,PixDist = glg(img) height, width = np.shape(img) @@ -188,7 +192,13 @@ def main(): for i in range(0,height): for j in range(0,width): image[i][j] = Trans[img[i][j]] - scipy.misc.imsave(res,image) - print "The PixDist is %.1lf" %PixDist + + cv2.imwrite(res,image) + print ("The PixDist is %.1lf" %PixDist) + + e2 = cv2.getTickCount() + t = (e2 - e1)/cv2.getTickFrequency() + print ("Execution took '%(val).3f' seconds." % {'val': t}); + if __name__ == '__main__': - main() \ No newline at end of file + main()