Source: Google

Fun Image Processing using Python ๐Ÿ๐Ÿ

Rahul Sil
3 min readJun 9, 2021

Most of us are familiar with image processing, not in formal terms of image processing but we all edit our pictures and post them on social media. ๐Ÿ’–

Here I am going to show some interesting ways of doing image processing that we normally do every day using OpenCV and python.

What I am going to demonstrate specifically?

  1. Creating a custom image using OpenCV ๐Ÿ˜โœจ
  2. Cropping pictures and pasting them ( We do that every day, donโ€™t we while making memes ๐Ÿ˜‚๐Ÿ˜‚ )
  3. Making a collage of 2 pictures

So let's get going โœŒ๐Ÿ’ฅ

Using the above code we can create a smiley face ๐Ÿ˜Š

I have basically used the drawing functions that are available from the OpenCV library in the cv2 module and created the image.

Image Output

Keep smiling ๐Ÿ˜Š in your tough times and things will definitely come back to normal and you will achieve all the success in the world ๐Ÿ˜ŠโœŒ๐Ÿ™

๐Ÿšฉ You can get creative and create your own custom image like this. ๐Ÿ˜‰๐Ÿ˜‰

Now I will show you how to crop a face from an image and paste it somewhere ( the thing we mostly do while meme-making ๐Ÿ˜‚๐Ÿ˜‚ )

The Original Image I am going to use is -

Source: Google

Our very favorite Tom and Jerry.๐Ÿ˜

Who all got reminded of their childhood memories? ๐Ÿ’–๐Ÿคฉ

Now using the above code we can crop Tom and Jerryโ€™s faces and swap them also.

Results -

Tomโ€™s cropped image

Here the face of Tom is cropped and swapped with Jerryโ€™s face.

Jerryโ€™s cropped image

Here the face of Jerry is cropped and swapped with Tomโ€™s face.

โ— In the above code, only one face swap code will work at a time, that is if you run the code for pasting Tomโ€™s face on top of Jerryโ€™s face then the other wonโ€™t work, and vice-versa. You need to then run the codes separately. I have given the codes together here. โ—

Now I will be creating a collage of Tom and Jerry ( after all they were the best of buddies ๐Ÿ’– )

Collage made using OpenCV

This way I have performed few fun experiments with OpenCV and NumPy. ๐Ÿ’–

You can find all the codes and images that I used here from the below GitHub link โ€”

A lot more things can be done using OpenCV and NumPy but for now this much.โœŒ

I hope you liked this article.๐Ÿ’–

Would definitely like to hear your views on this and feedbacks so that I can improve on those points in future articles. ๐Ÿ™Œ Comment your views below.

You can also check my LinkedIn profile and connect with me.

Follow me on medium as I will come up with articles on various technologies like Cloud Computing, DevOps, Automation, and their integration.

Thatโ€™s all for now. Thank You !! ๐Ÿ˜ŠโœŒ

--

--

Rahul Sil
Rahul Sil

Written by Rahul Sil

I am a tech enthusiasts. I love exploring new technologies and creating stuff out of them !! โœŒ

No responses yet