added script to show lowest image (laplacian) variance from folder (dataset)

main
Pavol Debnar 2 years ago
parent ee8313e0ea
commit f19d05d62d

@ -0,0 +1,38 @@
import cv2
import numpy as np
import os
from imutils import paths
import argparse
def variance_of_laplacian(image):
return cv2.Laplacian(image, cv2.CV_64F).var()
def minVarInFolder(path):
minVar = 90000
minPath=""
files = os.listdir(path)
for p in files:
if ".png" in p and ".mask" not in p:
print(path+p)
img = cv2.imread(path+p)
cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
var = variance_of_laplacian(img)
if var < minVar:
minPath = path+p
minVar = var
return minPath,minVar
ap = argparse.ArgumentParser()
ap.add_argument("-i", "--images", required=True,
help="path to image")
args = vars(ap.parse_args())
path = args["images"]
#img = cv2.imread(path)
#cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
#var = variance_of_laplacian(img)
print(minVarInFolder(path))
Loading…
Cancel
Save