示例#1
0
def main():
    filename = "../data/img/fingerprint.png"
    img = np.empty((2, 2))
    if cv2.os.path.exists(filename):
        img = image_processing.load_image_grayscale(filename)
    else:
        print("file does not exist")
        exit(1)
    result_img = Optimal_pattern(img)
    image_processing.image_show(result_img)
    young_pattern_hist(result_img)
示例#2
0
def width_init_img(img, debug=False):
    logger.debug("width of initial img")
    img = image_processing.blur(img, debug=debug)
    img = image_processing.threshold(img, debug=debug)
    img = image_processing.bitwise_not(img, debug=debug)
    img = image_processing.morphological_transformations(img, debug=debug)
    img = image_processing.thinning(img, debug=debug)
    # image_processing.image_save(img, title="sample")
    if debug:
        image_processing.image_show(img, title="width_init_img")
    return get_width(img, debug=debug)
def noise(img, noise_param=10000, debug=False):
    logger.debug("generating noise")
    row, col = img.shape
    logger.debug("noise" + str(noise_param / (row * col) * 100) + "%")

    # 白
    pts_x = np.random.randint(0, col - 1, noise_param)
    pts_y = np.random.randint(0, row - 1, noise_param)
    img[(pts_y, pts_x)] = 255  # y,xの順番になることに注意

    # 黒
    pts_x = np.random.randint(0, col - 1, noise_param)
    pts_y = np.random.randint(0, row - 1, noise_param)
    img[(pts_y, pts_x)] = 0
    if debug:
        image_processing.image_show(img)
    return img
def trim(img, left=0., right=1., top=0., bottom=1., debug=False):
    """
    トリミングする
    :param debug:
    :param img: 0~1
    :param left: 0~1
    :param right: 0~1
    :param top: 0~1
    :param bottom: 0~1
    :return:
    """
    if debug:
        print("start: trim")
    height = img.shape[0]
    width = img.shape[1]

    if (left > right) or (top > bottom):
        print("left & top should be lower than right & bottom")
        exit(1)
    elif (0 > left) and (left > 1):
        print("parameter left should be 0 to 1")
        exit(1)
    elif (0 > right) and (right > 1):
        print("parameter right should be 0 to 1")
        exit(1)
    elif (0 > top) and (top > 1):
        print("parameter top should be 0 to 1")
        exit(1)
    elif (0 > bottom) and (bottom > 1):
        print("parameter bottom should be 0 to 1")
        exit(1)
    else:
        result = img[int(height * top):int(height * bottom),
                     int(width * left):int(width * right)]
        if debug:
            image_processing.image_show(img, "trim - before")
            image_processing.image_show(result, "trim - after")
            print("end  : trim")
        return result
示例#5
0
import cv2
import numpy as np

from edit_img import image_processing
from optimise.Optimal_pattern import Optimal_pattern
import sys

print("animal")
print(sys.path)

for i in range(1, 5):
    filename = "../data/img_animal/animal0{0}.jpg".format(i)
    print(filename)
    img = np.empty((2, 2))
    if cv2.os.path.exists(filename):
        img = image_processing.load_image_grayscale(filename)
    else:
        print("file does not exist")
        exit(1)
    result_img = Optimal_pattern(img)
    image_processing.image_show(result_img)