How to build amazing image filters with Python— Median filter 📷 , Sobel filter ⚫️ ⚪️

Enzo Lizama
3 min readSep 16, 2017

--

This post is published too on my personal blog. Take a look at it 👀.

Nowadays, I’m starting in a new programming language : Python 🐍 . And I am pleased to share some of my knowledge about this new topic , which is image processing.

What is digital image processing ?

It is a set of techniques whose objective is to obtain a result with a specific application from a source image, improving certain characteristics that allow you to extract information from the image.

OK , After a short introduction about the meaning of image processing, Let’s continue with the filters that I will show you in this post.

Median filter

Taken from http://artemhlezin.com/2016/09/04/median.html

This filter is used to eliminate the ‘noise’ of the images, mainly is salt-n-pepper noise.

There is not much theory beyond the one in the picture. This is how the filter works : gets all the values inside a mask, sorts them and then assigns the mean value to the coordinate.

This is how it looks an image with salt and pepper noise :

Salt and pepper noise

In Python 🐍 the filter works like this, enter to check the result:

And this is the result :

Sobel filter

The Sobel operator is an algorithm for edge detection, a technique to find the limits between regions in an image. The edge detection algorithm help us separate some specific parts of the source image and take them off from the background. There is more interesting theory about edge detection and the Sobel operator , but we will focus on the Python 🐍 implementation.

Taken from http://www.bogotobogo.com

Due to the excitement for the South American World Cup qualifiers I decided to use this image for example :

In Python 🐍 the filter works like this, enter to check the result:

And this is the result :

Conclusion

I mentioned that there is much more theory about this subject; so, I will leave some articles that, in my opinion, are the most complete and better explained in the web.

References

Thanks for reading this little post , totally open to feedback. Questions in the comment box and show your support 👏❤️ .

About the autor 😄

Student of software engineering at UPC. Passionate about Android technologies, Python and Web Development. Active participant in software development communities.

You can watch my open-source projects in my GitHub account.

--

--

Enzo Lizama

Software engineering student, passionate about Mobile technologies and web development. @enzoftware anywhere.