Spaces:
Running
Running
Commit
·
cd6e927
1
Parent(s):
5899389
changes image quality check
Browse files
tool_utils/image_metadata.py
CHANGED
|
@@ -3,14 +3,15 @@ import numpy as np
|
|
| 3 |
import cv2
|
| 4 |
from skimage.restoration import estimate_sigma
|
| 5 |
import logging
|
|
|
|
| 6 |
def image_brightness(image,thresh=0.37):
|
| 7 |
L,A,B = cv2.split(cv2.cvtColor(image,cv2.COLOR_BGR2LAB))
|
| 8 |
norm_L = L/np.max(L)
|
| 9 |
L_mean = np.mean(norm_L)
|
| 10 |
if L_mean > thresh:
|
| 11 |
-
return "
|
| 12 |
else:
|
| 13 |
-
return "image is not bright enough "
|
| 14 |
|
| 15 |
def variance_of_laplacian(img,threshould=250):
|
| 16 |
# compute the Laplacian of the image and then return the focus
|
|
@@ -20,20 +21,20 @@ def variance_of_laplacian(img,threshould=250):
|
|
| 20 |
laplacian_value = cv2.Laplacian(gray, cv2.CV_64F).var()
|
| 21 |
logging.info(laplacian_value)
|
| 22 |
if laplacian_value <= threshould:
|
| 23 |
-
return "
|
| 24 |
elif laplacian_value <= 3*threshould:
|
| 25 |
-
return "
|
| 26 |
elif laplacian_value >= 3*threshould:
|
| 27 |
-
return "Image
|
| 28 |
|
| 29 |
def get_signal_to_noise_ratio(image):
|
| 30 |
snr_text = None
|
| 31 |
snr_value = estimate_sigma(cv2.cvtColor(image,cv2.COLOR_RGB2GRAY), average_sigmas=False)
|
| 32 |
logging.info(snr_value)
|
| 33 |
if snr_value > 1 :
|
| 34 |
-
snr_text = "
|
| 35 |
else:
|
| 36 |
-
snr_text = "
|
| 37 |
return snr_text
|
| 38 |
|
| 39 |
|
|
|
|
| 3 |
import cv2
|
| 4 |
from skimage.restoration import estimate_sigma
|
| 5 |
import logging
|
| 6 |
+
|
| 7 |
def image_brightness(image,thresh=0.37):
|
| 8 |
L,A,B = cv2.split(cv2.cvtColor(image,cv2.COLOR_BGR2LAB))
|
| 9 |
norm_L = L/np.max(L)
|
| 10 |
L_mean = np.mean(norm_L)
|
| 11 |
if L_mean > thresh:
|
| 12 |
+
return "Image is bright enough to process object detection and segmentation task"
|
| 13 |
else:
|
| 14 |
+
return "image is not bright enough to process object detection and segmentation task "
|
| 15 |
|
| 16 |
def variance_of_laplacian(img,threshould=250):
|
| 17 |
# compute the Laplacian of the image and then return the focus
|
|
|
|
| 21 |
laplacian_value = cv2.Laplacian(gray, cv2.CV_64F).var()
|
| 22 |
logging.info(laplacian_value)
|
| 23 |
if laplacian_value <= threshould:
|
| 24 |
+
return "There is Blur/Gaussian noise in the image"
|
| 25 |
elif laplacian_value <= 3*threshould:
|
| 26 |
+
return " There is Blur/Gaussian noise in few regions of the image."
|
| 27 |
elif laplacian_value >= 3*threshould:
|
| 28 |
+
return "Image has high sharpness , no need to process futher."
|
| 29 |
|
| 30 |
def get_signal_to_noise_ratio(image):
|
| 31 |
snr_text = None
|
| 32 |
snr_value = estimate_sigma(cv2.cvtColor(image,cv2.COLOR_RGB2GRAY), average_sigmas=False)
|
| 33 |
logging.info(snr_value)
|
| 34 |
if snr_value > 1 :
|
| 35 |
+
snr_text = "SnR is greater than 1 meaning : image has less noise "
|
| 36 |
else:
|
| 37 |
+
snr_text = "SnR is less than 1 Meaning : image has noise , it needs to be processed . "
|
| 38 |
return snr_text
|
| 39 |
|
| 40 |
|