Refactor image loading to class imgrate
This commit is contained in:
parent
64561d7be4
commit
66942b9b4b
14
imgrate.py
14
imgrate.py
@ -16,8 +16,13 @@ def image_required(fun):
|
|||||||
|
|
||||||
|
|
||||||
class imgrate:
|
class imgrate:
|
||||||
def __init__(self, image=None):
|
def __init__(self, imgfile=None):
|
||||||
self.image = image
|
self.image = None
|
||||||
|
if imgfile: self.load_image(imgfile)
|
||||||
|
|
||||||
|
def load_image(self, imgfile):
|
||||||
|
image = cv2.imread(imgfile)
|
||||||
|
self.image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
|
||||||
|
|
||||||
@image_required
|
@image_required
|
||||||
def laplacian_variance(self):
|
def laplacian_variance(self):
|
||||||
@ -38,7 +43,4 @@ if __name__ == '__main__':
|
|||||||
ap.add_argument('images', type=str, nargs='+', help='')
|
ap.add_argument('images', type=str, nargs='+', help='')
|
||||||
args = ap.parse_args()
|
args = ap.parse_args()
|
||||||
|
|
||||||
image = cv2.imread(args.images[0])
|
print(imgrate(args.images[0]).laplacian_variance())
|
||||||
grayscale = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
|
|
||||||
|
|
||||||
print(imgrate(grayscale).laplacian_variance())
|
|
||||||
|
Loading…
Reference in New Issue
Block a user