Logo elodees  elodees

A caring AI for a better world













Only alphabetic characters accented or not as well as the space are accepted

Logo IA




Harris Feature Detection





No account yet ?

Sign up to access all content


Tested in Anaconda and Python 3.7

# # Harris Corner Detection

 
# ### Import resources and display image

import matplotlib.pyplot as plt
import numpy as np
import cv2
 
 
# Read in the image
image = cv2.imread('carre-04.jpg')
 
# Make a copy of the image
image_copy = np.copy(image)
 
# Change color to RGB (from BGR)
image_copy = cv2.cvtColor(image_copy, cv2.COLOR_BGR2RGB)
 
plt.imshow(image_copy)
 
 
# ### Detect corners

# Convert to grayscale
gray = cv2.cvtColor(image_copy, cv2.COLOR_RGB2GRAY)
gray = np.float32(gray)
 
# Detect corners 
dst = cv2.cornerHarris(gray, 2, 3, 0.04)
 
# Dilate corner image to enhance corner points
dst = cv2.dilate(dst,None)
 
plt.imshow(dst, cmap='gray')
 
 
# ### Extract and display strong corners

# This value vary depending on the image and how many corners you want to detect
# Try changing this free parameter, 0.1, to be larger or smaller and see what happens
thresh = 0.1*dst.max()
 
# Create an image copy to draw corners on
corner_image = np.copy(image_copy)
 
# Iterate through all the corners and draw them on the image (if they pass the threshold)
for j in range(0, dst.shape[0]):
    for i in range(0, dst.shape[1]):
        if(dst[j,i] > thresh):
            # image, center pt, radius, color, thickness
            cv2.circle( corner_image, (i, j), 1, (0,255,0), 1)
 
plt.imshow(corner_image)
 
 
Free image provided by pexel.com
Free image provided by pexel.com










Introduction To Feature Detection And Matching - GitHub











Welcome, my name is Eric Soupet and I am the administrator of the site elodees.com. elodees.com is a state of the art of Artificial Intelligence and aims to be collaborative, you can now offer content such as articles, events, tutorials, ... so don't hesitate !

Platform images credit : Pixabay - Pixabay License | Pexels - Pexels License