File size: 1,527 Bytes
0e78cbf
 
 
 
 
cd6e927
c457ff3
0e78cbf
 
 
 
cd6e927
0e78cbf
cd6e927
0e78cbf
c457ff3
0e78cbf
 
 
 
 
 
 
cd6e927
0e78cbf
cd6e927
0e78cbf
cd6e927
0e78cbf
c457ff3
0e78cbf
 
 
 
cd6e927
0e78cbf
cd6e927
0e78cbf
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import os 
import numpy as np 
import cv2
from skimage.restoration import estimate_sigma
import logging

def brightness_check(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 to process object detection and segmentation task"
    else:
        return "image is not bright enough to process object detection and segmentation task "

def gaussian_noise_check(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 "There is Blur/Gaussian noise in the image"
    elif laplacian_value <= 3*threshould:
        return " There is Blur/Gaussian noise in few regions of the image."
    elif laplacian_value >= 3*threshould:
        return "Image has high sharpness , no need to process futher." 

def snr_check(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 = "SnR is greater than 1 meaning : image has less noise "
    else:
        snr_text = "SnR is less than 1 Meaning : image has noise , it needs to be processed . "
    return snr_text