Corner Detection using corner_harris, corner_peaks is not detecting corners correctly

Viewed 58

I am trying to detect corners of an image using corner_harris. But the corners are not displayed correctly. Does anyone know how to get the corners correct? I am attaching input. input

from skimage.feature import corner_harris, corner_peaks
from matplotlib import pyplot as plt
from skimage import color
from skimage.io import imread


def show_image_with_corners(image, coords, title="Corners detected"):
 plt.imshow(image, interpolation='nearest', cmap='gray')
 plt.title(title)
 plt.plot(coords[:, 1], coords[:, 0], '+r', markersize=15)
 plt.axis('off')
    

def show_image(image, title='Image', cmap_type='gray'):
 plt.imshow(image, cmap=cmap_type)
 plt.title(title)
 
read_image = imread('test_img.png')

# Convert image from RGB to grayscale
 img_gray = color.rgb2gray(read_image )
# Apply the detector to measure the possible corners
measure_image = corner_harris(img_gray)

# Find the peaks of the corners using the Harris detector
coords = corner_peaks(measure_image, min_distance=5, threshold_rel=0.02)
show_image_with_corners(img_gray, coords)

Now i am getting output as output Does anyone know how to detect only the rectangles in image? Any idea about parameters used-corner_peaks(measure_image, min_distance=5, threshold_rel=0.02) How to get only rectangles?

0 Answers
Related