예제 #1
0
def laplacian_filter_test():
    i = imageio.imread('images/moon.jpeg')
    i = colors.rgb2gray(i)
    img = cv2.imread('images/moon.jpeg', 0)
    it1 = cv2.Laplacian(img, cv2.CV_64F)
    it2 = bk.laplacian_filter(i)
    util.subplot_img(it1, it2)
예제 #2
0
            for col in range(width):
                if image[row, col] > threshold:
                    output[row, col] = 255
                else:
                    output[row, col] = 0

    # change pixels > threshold
    elif flag == 2:
        for row in range(height):
            for col in range(width):
                if image[row, col] > threshold:
                    output[row, col] = 255

    # pixels between 0 and threshold
    elif flag == 3:
        for row in range(height):
            for col in range(width):
                if image[row, col] > threshold:
                    output[row, col] = threshold

    return output


if __name__ == '__main__':
    i = imageio.imread('images/dipxe.jpeg')
    #i = rgb2gray(i)
    #it = equalize_hist(i)
    #it = sharpen_filter(i)]
    it = highboost(i, -3, 5)
    util.subplot_img(i, it)
예제 #3
0
def negative_filter_test():
    i = imageio.imread('images/breast.jpeg')
    i = colors.rgb2gray(i)
    it1 = cv2.bitwise_not(i)
    it2 = bk.negative_filter(i)
    util.subplot_img(it1, it2)
예제 #4
0
def sobel_filter_test():
    i = imageio.imread('images/lens.jpeg')
    i = colors.rgb2gray(i)
    it = bk.sobel_filter(i)
    util.subplot_img(i, it)
예제 #5
0
def median_filter_test():
    i = imageio.imread('images/salt_pepper.jpeg')
    i = colors.rgb2gray(i)
    it1 = cv2.medianBlur(i, 3)
    it2 = bk.median_filter(i, 3)
    util.subplot_img(it1, it2)
예제 #6
0
def mean_filter_test():
    i = imageio.imread('images/blurring.jpeg')
    i = colors.rgb2gray(i)
    it1 = cv2.blur(i, (5, 5))
    it2 = bk.mean_filter(i, 5)
    util.subplot_img(it1, it2)
예제 #7
0
def gamma_filter_test():
    i = imageio.imread('images/aerial.jpeg')
    i = colors.rgb2gray(i)
    it = bk.gamma_filter(i, 1, 5)
    util.subplot_img(i, it)
예제 #8
0
def logarithm_filter_test():
    i = imageio.imread('images/dft.jpeg')
    i = colors.rgb2gray(i)
    it = bk.logarithm_filter(i, 1)
    util.subplot_img(i, it)
예제 #9
0
    for x in range(width):
        for y in range(height):
            xp = int((x - center_x) * np.cos(angle) -
                     (y - center_y) * np.sin(angle) + center_x)
            yp = int((x - center_x) * np.sin(angle) +
                     (y - center_y) * np.cos(angle) + center_y)
            if 0 <= xp < width and 0 <= yp < height:
                output[x, y] = image[xp, yp]

    return output


if __name__ == '__main__':
    filename = 'einstein'
    path = 'images/' + filename + '.jpeg'
    i = imageio.imread(path)
    i = rgb2gray(i)
    print('Shape: ', i.shape)
    #it = bilinearRotate(i, 30)
    #it = nnscale(i, i.shape[0]*1.5, i.shape[1]*1.5)
    it = nnrotate(i, 30)
    print('New shape: ', it.shape)
    #imshow(it)
    #it2 = image.rotate(30)
    #it = resizeBilinearInterpolation(i, i.shape[0]+50, i.shape[1]+50)
    #cv2.imshow('ImageWindow', cv2.cvtColor(it, cv2.COLOR_BGR2RGB))
    #cv2.waitKey()
    #cv2.imshow('ImageWindow', cv2.cvtColor(i, cv2.COLOR_BGR2RGB))
    #cv2.waitKey()
    subplot_img(i, it)