DEV Community

Cover image for A naive approach to finding corners on an image
Victor Ribeiro
Victor Ribeiro

Posted on

2 1

A naive approach to finding corners on an image

Naive Corners

A naive algorithm to find corners on a image.

detected

About

When I was still studying the basics of digital image processing I came up with this "algorithm" to detect corners on a image.

How it works

Well, as the name suggests, this is a very naive approach.

Given any image we will look at it a window of 3 by 3 at a time. (We could resize the image to speed up the process, but who's in a hurry?)

3x3 window.

grid

We will then just count how many colored pixels we have at that window. If there's 4 colored pixels, it must be a corner.

Corner.

grid

Rotated corner.

rotated corner

Anything else, is not a corner.

Not a corner.

grid

Not a corner either.

grid

See it working

Run by calling

python corner.py img/mess.png

I also used this algorithm to process corners on a real time webcam video.

A python implementation of this algorithm is hosted here

Image of Datadog

The Future of AI, LLMs, and Observability on Google Cloud

Datadog sat down with Google’s Director of AI to discuss the current and future states of AI, ML, and LLMs on Google Cloud. Discover 7 key insights for technical leaders, covering everything from upskilling teams to observability best practices

Learn More

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more