Spaces:
Running
Running
import os | |
import numpy as np | |
import cv2 | |
from skimage.restoration import estimate_sigma | |
import logging | |
def image_brightness(image,thresh=0.37): | |
L,A,B = cv2.split(cv2.cvtColor(image,cv2.COLOR_BGR2LAB)) | |
norm_L = L/np.max(L) | |
L_mean = np.mean(norm_L) | |
if L_mean > thresh: | |
return "image is Bright enough " | |
else: | |
return "image is not bright enough " | |
def variance_of_laplacian(img,threshould=250): | |
# compute the Laplacian of the image and then return the focus | |
# measure, which is simply the variance of the Laplacian | |
gray = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY) | |
laplacian_value = cv2.Laplacian(gray, cv2.CV_64F).var() | |
logging.info(laplacian_value) | |
if laplacian_value <= threshould: | |
return " Image is very blurry" | |
elif laplacian_value <= 3*threshould: | |
return " Image is visible but have some regions out of foucs." | |
elif laplacian_value >= 3*threshould: | |
return "Image is Very Sharp." | |
def get_signal_to_noise_ratio(image): | |
snr_text = None | |
snr_value = estimate_sigma(cv2.cvtColor(image,cv2.COLOR_RGB2GRAY), average_sigmas=False) | |
logging.info(snr_value) | |
if snr_value > 1 : | |
snr_text = "Signal to Noise is greater than 1 - More Signal in image " | |
else: | |
snr_text = "Signal to Noise is less than 1 - More Noise in image " | |
return snr_text | |