Created
March 5, 2017 22:07
-
-
Save soravux/e3be6f526b643d2aff8c9c4426360bd4 to your computer and use it in GitHub Desktop.
Revisions
-
soravux created this gist
Mar 5, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ import sys import csv import numpy as np from scipy.misc import imread output_file = 'sharpnesses.txt' imgs = sys.argv[1:] with open(output_file, 'w', newline='') as csvfile: writer = csv.writer(csvfile, quoting=csv.QUOTE_MINIMAL) for img in imgs: im = imread(img).astype('float32') / 255. # We suppose a Latitude-Longitude format, so we remove the ground (bottom part) im = im[:np.round(im.shape[0]*0.47).astype('int'),:,:] im_grayscale = np.dot(im, [0.299, 0.587, 0.114]) im_fft = np.abs(np.fft.fft2(im_grayscale)) sharpness = np.sum(im_fft.ravel() > 5) / im_grayscale.size writer.writerow([img, sharpness])