Exemplo n.º 1
0
def FT3(im,
        test=1,
        phase2=False,
        upperrange=1.1,
        lowerrange=0.45):  #AverageBlur
    img = np.array(im)
    if test != 0:
        img = img[:, :, :3]
    kernel = np.ones((3, 3), np.float32) / 25
    dst = cv2.blur(img, (5, 5), 0)
    snr2 = float(signaltonoise(dst, axis=None))
    index = img == dst
    dst2 = np.abs(img - dst)
    snr3 = float(signaltonoise(dst2, axis=None))
    if phase2 == True:
        if snr3 < upperrange and snr3 > lowerrange:
            return im
    return []
Exemplo n.º 2
0
def FT1(im,
        test=1,
        phase2=False,
        upperrange=0.7,
        lowerrange=0.15):  #medianblur
    img = np.array(im)
    if test != 0:
        img = img[:, :, :3]
    kernel = np.ones((3, 3), np.float32) / 25
    dst = cv2.medianBlur(img, 25)
    snr2 = float(signaltonoise(dst, axis=None))
    index = img == dst
    dst2 = np.abs(img - dst)
    snr3 = float(signaltonoise(dst2, axis=None))
    if phase2 == True:
        if snr3 < upperrange and snr3 > lowerrange:
            return im
    return []
Exemplo n.º 3
0
def FT12(im, test=1, phase2=False, upperrange=0.6, lowerrange=0.15):  #TopHat
    img = np.array(im)
    if test != 0:
        img = img[:, :, :3]
    try:
        img = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
    except:
        img = img
    kernel = np.ones((3, 3), np.uint8)
    dst = cv2.morphologyEx(img, cv2.MORPH_TOPHAT, kernel)
    snr2 = float(signaltonoise(dst, axis=None))
    index = img == dst
    dst2 = np.abs(img - dst)
    snr3 = float(signaltonoise(dst2, axis=None))
    if phase2 == True:
        if snr3 < upperrange and snr3 > lowerrange:
            return im
    return []
Exemplo n.º 4
0
def FT8(im, test=1, phase2=False, upperrange=0.7, lowerrange=0.25):  #Dialte
    img = np.array(im)
    if test != 0:
        img = img[:, :, :3]
    try:
        img = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
    except:
        img = img
    kernel = np.ones((5, 5), np.uint8)
    dst = cv2.dilate(img, kernel, iterations=1)
    snr2 = float(signaltonoise(dst, axis=None))
    index = img == dst
    dst2 = np.abs(img - dst)
    snr3 = float(signaltonoise(dst2, axis=None))
    if phase2 == True:
        if snr3 < upperrange and snr3 > lowerrange:
            return im
    return []
Exemplo n.º 5
0
def FT4(im,
        test=1,
        phase2=False,
        upperrange=1.1,
        lowerrange=0.3):  #Bilateral blur
    img = np.array(im)
    if test != 0:
        img = img[:, :, :3]
    try:
        img = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
    except:
        img = img
    dst = cv2.bilateralFilter(img, 6, 75, 75)
    snr2 = float(signaltonoise(dst, axis=None))
    index = img == dst
    dst2 = np.abs(img - dst)
    snr3 = float(signaltonoise(dst2, axis=None))
    if phase2 == True:
        if snr3 < upperrange and snr3 > lowerrange:
            return im
    return []
Exemplo n.º 6
0
def FT6(im,
        test=1,
        phase2=False,
        upperrange=1.3,
        lowerrange=0.7):  #AdditivePoissonNoise
    img = np.array(im)
    if test != 0:
        img = img[:, :, :3]
    aug = iaa.AdditiveGaussianNoise(loc=0, scale=0.1 * 255)
    im_arr = aug.augment_image(img)
    dst2 = np.abs(img - np.array(im_arr))
    snr3 = float(signaltonoise(dst2, axis=None))
    if phase2 == True:
        if snr3 < upperrange and snr3 > lowerrange:
            return im
    return []
Exemplo n.º 7
0
def FT5(im,
        test=1,
        phase2=False,
        upperrange=1.3,
        lowerrange=0.7):  #AdditivePoissonNoise
    img = np.array(im)
    if test != 0:
        img = img[:, :, :3]
    kernel = np.ones((3, 3), np.float32) / 25
    aug = iaa.AdditivePoissonNoise(lam=10.0, per_channel=True)
    im_arr = aug.augment_image(img)
    dst2 = np.abs(img - np.array(im_arr))
    snr3 = float(signaltonoise(dst2, axis=None))
    if phase2 == True:
        if snr3 < upperrange and snr3 > lowerrange:
            return im
    return []