{"id":7463,"date":"2023-09-12T16:07:35","date_gmt":"2023-09-13T00:07:35","guid":{"rendered":"https:\/\/live-cometml.pantheonsite.io\/?p=7463"},"modified":"2025-04-24T17:14:09","modified_gmt":"2025-04-24T17:14:09","slug":"image-transformations-using-opencv-in-python","status":"publish","type":"post","link":"https:\/\/www.comet.com\/site\/blog\/image-transformations-using-opencv-in-python\/","title":{"rendered":"Image Transformations Using OpenCV in Python"},"content":{"rendered":"\n<link rel=\"canonical\" href=\"https:\/\/www.comet.com\/site\/blog\/image-transformations-using-opencv-in-python\">\n\n\n\n<div class=\"fh fi fj fk fl\">\n<div class=\"ab ca\">\n<div class=\"ch bg et eu ev ew\">\n<p id=\"5107\" class=\"pw-post-body-paragraph mf mg fo be b gm mh mi mj gp mk ml mm mn mo mp mq mr ms mt mu mv mw mx my mz fh bj\" data-selectable-paragraph=\"\">Image transformations such as cartooning images are a common hobby for many people. Cartoons were a great source of entertainment during our childhood and image cartooning has been trending for a while and people use different applications to transform their images into cartoon images.<\/p>\n<p id=\"c2aa\" class=\"pw-post-body-paragraph mf mg fo be b gm mh mi mj gp mk ml mm mn mo mp mq mr ms mt mu mv mw mx my mz fh bj\" data-selectable-paragraph=\"\">In this article, we are interested in the process involved in the transformation of RGB images to cartoon images. We aim to use OpenCV and Python to transform images into its cartoon.<\/p>\n<figure class=\"nd ne nf ng nh ni na nb paragraph-image\">\n<figure><img loading=\"lazy\" decoding=\"async\" class=\"bg nj nk c\" role=\"presentation\" src=\"https:\/\/miro.medium.com\/v2\/resize:fit:400\/1*gVIPxVakNUTDTvyNwC5jDA.png\" alt=\"\" width=\"400\" height=\"451\"><\/figure><div class=\"na nb nc\"><picture><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/format:webp\/1*gVIPxVakNUTDTvyNwC5jDA.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/format:webp\/1*gVIPxVakNUTDTvyNwC5jDA.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/format:webp\/1*gVIPxVakNUTDTvyNwC5jDA.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/format:webp\/1*gVIPxVakNUTDTvyNwC5jDA.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/format:webp\/1*gVIPxVakNUTDTvyNwC5jDA.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/format:webp\/1*gVIPxVakNUTDTvyNwC5jDA.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:800\/format:webp\/1*gVIPxVakNUTDTvyNwC5jDA.png 800w\" type=\"image\/webp\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 400px\"><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/1*gVIPxVakNUTDTvyNwC5jDA.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/1*gVIPxVakNUTDTvyNwC5jDA.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/1*gVIPxVakNUTDTvyNwC5jDA.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/1*gVIPxVakNUTDTvyNwC5jDA.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/1*gVIPxVakNUTDTvyNwC5jDA.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/1*gVIPxVakNUTDTvyNwC5jDA.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:800\/1*gVIPxVakNUTDTvyNwC5jDA.png 800w\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 400px\" data-testid=\"og\"><\/picture><\/div><figcaption class=\"nl nm nn na nb no np be b bf z dv\" data-selectable-paragraph=\"\">Cartoon image example similar to what we\u2019re aiming for<\/figcaption><\/figure>\n<h2 id=\"72ce\" class=\"nq nr fo be ns nt nu nv nw nx ny nz oa mn ob oc od mr oe of og mv oh oi oj ok bj\" data-selectable-paragraph=\"\"><strong class=\"al\">What is OpenCV?<\/strong><\/h2>\n<p id=\"8202\" class=\"pw-post-body-paragraph mf mg fo be b gm ol mi mj gp om ml mm mn on mp mq mr oo mt mu mv op mx my mz fh bj\" data-selectable-paragraph=\"\"><a class=\"af oq\" href=\"https:\/\/opencv.org\/\" target=\"_blank\" rel=\"noopener ugc nofollow\">OpenCV<\/a> is an open-source, cross-platform library used for real-time computer vision and model execution for Machine Learning. It is commonly used for image processing and transformation, object detection, face recognition among others. OpenCV is also used in creating image processing or rendering applications.<\/p>\n<p id=\"b18f\" class=\"pw-post-body-paragraph mf mg fo be b gm mh mi mj gp mk ml mm mn mo mp mq mr ms mt mu mv mw mx my mz fh bj\" data-selectable-paragraph=\"\">We intend to perform some image transformations such as making sketches, smoothening, cartooning on images using CV2 version of OpenCV. You can access the full code of this project in Google Colab <a class=\"af oq\" href=\"https:\/\/colab.research.google.com\/drive\/1gCgXWtEkxgFlKHcu97lzIrXcvAMdQEEb?usp=sharing\" target=\"_blank\" rel=\"noopener ugc nofollow\">here<\/a>. In this project we will go through the following steps:<\/p>\n<p id=\"16d1\" class=\"pw-post-body-paragraph mf mg fo be b gm mh mi mj gp mk ml mm mn mo mp mq mr ms mt mu mv mw mx my mz fh bj\" data-selectable-paragraph=\"\">1. Install OpenCV<\/p>\n<p id=\"2f1b\" class=\"pw-post-body-paragraph mf mg fo be b gm mh mi mj gp mk ml mm mn mo mp mq mr ms mt mu mv mw mx my mz fh bj\" data-selectable-paragraph=\"\">2. Import required libraries<\/p>\n<p id=\"5c1b\" class=\"pw-post-body-paragraph mf mg fo be b gm mh mi mj gp mk ml mm mn mo mp mq mr ms mt mu mv mw mx my mz fh bj\" data-selectable-paragraph=\"\">3. Uploading and reading the image<\/p>\n<p id=\"bb60\" class=\"pw-post-body-paragraph mf mg fo be b gm mh mi mj gp mk ml mm mn mo mp mq mr ms mt mu mv mw mx my mz fh bj\" data-selectable-paragraph=\"\">4. Transform image to grayscale<\/p>\n<p id=\"f5cd\" class=\"pw-post-body-paragraph mf mg fo be b gm mh mi mj gp mk ml mm mn mo mp mq mr ms mt mu mv mw mx my mz fh bj\" data-selectable-paragraph=\"\">5. Smoothing the grayscale image<\/p>\n<p id=\"e1bc\" class=\"pw-post-body-paragraph mf mg fo be b gm mh mi mj gp mk ml mm mn mo mp mq mr ms mt mu mv mw mx my mz fh bj\" data-selectable-paragraph=\"\">6. Detect and enhance the image edges<\/p>\n<p id=\"dc1a\" class=\"pw-post-body-paragraph mf mg fo be b gm mh mi mj gp mk ml mm mn mo mp mq mr ms mt mu mv mw mx my mz fh bj\" data-selectable-paragraph=\"\">7. Create a mask image<\/p>\n<p id=\"c44a\" class=\"pw-post-body-paragraph mf mg fo be b gm mh mi mj gp mk ml mm mn mo mp mq mr ms mt mu mv mw mx my mz fh bj\" data-selectable-paragraph=\"\">8. Cartoonify the image<\/p>\n<p id=\"8070\" class=\"pw-post-body-paragraph mf mg fo be b gm mh mi mj gp mk ml mm mn mo mp mq mr ms mt mu mv mw mx my mz fh bj\" data-selectable-paragraph=\"\">9. Plot all transitions<\/p>\n<p id=\"00a0\" class=\"pw-post-body-paragraph mf mg fo be b gm mh mi mj gp mk ml mm mn mo mp mq mr ms mt mu mv mw mx my mz fh bj\" data-selectable-paragraph=\"\">10. Other image transformations<\/p>\n<h2 id=\"2823\" class=\"nq nr fo be ns nt nu nv nw nx ny nz oa mn ob oc od mr oe of og mv oh oi oj ok bj\" data-selectable-paragraph=\"\"><strong class=\"al\">Installing OpenCV<\/strong><\/h2>\n<p id=\"6f04\" class=\"pw-post-body-paragraph mf mg fo be b gm ol mi mj gp om ml mm mn on mp mq mr oo mt mu mv op mx my mz fh bj\" data-selectable-paragraph=\"\">We will run the following command to install OpenCV:<\/p>\n<pre class=\"nd ne nf ng nh or os ot ou ax ov bj\"><span id=\"d6cd\" class=\"nq nr fo os b ia ow ox l iq oy\" data-selectable-paragraph=\"\"><em class=\"oz\">#installing opencv<\/em><\/span><span id=\"bda7\" class=\"nq nr fo os b ia pa ox l iq oy\" data-selectable-paragraph=\"\"><em class=\"oz\">%pip install opencv-python<\/em><\/span><\/pre>\n<p id=\"b680\" class=\"pw-post-body-paragraph mf mg fo be b gm mh mi mj gp mk ml mm mn mo mp mq mr ms mt mu mv mw mx my mz fh bj\" data-selectable-paragraph=\"\">We are now ready to start our image transformation process.<\/p>\n<h2 id=\"8147\" class=\"nq nr fo be ns nt nu nv nw nx ny nz oa mn ob oc od mr oe of og mv oh oi oj ok bj\" data-selectable-paragraph=\"\"><strong class=\"al\">Libraries<\/strong><\/h2>\n<p id=\"2951\" class=\"pw-post-body-paragraph mf mg fo be b gm ol mi mj gp om ml mm mn on mp mq mr oo mt mu mv op mx my mz fh bj\" data-selectable-paragraph=\"\">We will import the following required libraries:<\/p>\n<pre class=\"nd ne nf ng nh or os ot ou ax ov bj\"><span id=\"136d\" class=\"nq nr fo os b ia ow ox l iq oy\" data-selectable-paragraph=\"\"><em class=\"oz\">#importing required libraries<\/em><\/span><span id=\"a957\" class=\"nq nr fo os b ia pa ox l iq oy\" data-selectable-paragraph=\"\"><em class=\"oz\">import cv2<\/em><\/span><span id=\"0b58\" class=\"nq nr fo os b ia pa ox l iq oy\" data-selectable-paragraph=\"\"><em class=\"oz\">import numpy as np<\/em><\/span><span id=\"b39e\" class=\"nq nr fo os b ia pa ox l iq oy\" data-selectable-paragraph=\"\"><em class=\"oz\">import matplotlib.pyplot as plt<\/em><\/span><\/pre>\n<p id=\"231b\" class=\"pw-post-body-paragraph mf mg fo be b gm mh mi mj gp mk ml mm mn mo mp mq mr ms mt mu mv mw mx my mz fh bj\" data-selectable-paragraph=\"\">CV2 \u2014 this will be used for image processing.<\/p>\n<p id=\"f7ca\" class=\"pw-post-body-paragraph mf mg fo be b gm mh mi mj gp mk ml mm mn mo mp mq mr ms mt mu mv mw mx my mz fh bj\" data-selectable-paragraph=\"\">Numpy \u2014 Images are normally stored and processed as arrays. Numpy is optimized for dealing with arrays.<\/p>\n<p id=\"4b80\" class=\"pw-post-body-paragraph mf mg fo be b gm mh mi mj gp mk ml mm mn mo mp mq mr ms mt mu mv mw mx my mz fh bj\" data-selectable-paragraph=\"\">Matplotlib \u2014 This library will be used to plot the transformed images.<\/p>\n<h2 id=\"788c\" class=\"nq nr fo be ns nt nu nv nw nx ny nz oa mn ob oc od mr oe of og mv oh oi oj ok bj\" data-selectable-paragraph=\"\"><strong class=\"al\">Uploading and Reading the Image<\/strong><\/h2>\n<p id=\"730d\" class=\"pw-post-body-paragraph mf mg fo be b gm ol mi mj gp om ml mm mn on mp mq mr oo mt mu mv op mx my mz fh bj\" data-selectable-paragraph=\"\">The colab function allows us to select an image from a device. Imread is a function in CV2 used to store images in the form of numbers. The image is read as a numpy array where the cell values depict R, G, and B values of a pixel. This helps to perform custom operations on the image.<\/p>\n<pre class=\"nd ne nf ng nh or os ot ou ax ov bj\"><span id=\"4ebe\" class=\"nq nr fo os b ia ow ox l iq oy\" data-selectable-paragraph=\"\"><em class=\"oz\">#upload image file using colab function<\/em><\/span><span id=\"9a30\" class=\"nq nr fo os b ia pa ox l iq oy\" data-selectable-paragraph=\"\"><em class=\"oz\">from google.colab import files<\/em><\/span><span id=\"add7\" class=\"nq nr fo os b ia pa ox l iq oy\" data-selectable-paragraph=\"\"><em class=\"oz\">uploaded_image=files.upload()<\/em><\/span><span id=\"217b\" class=\"nq nr fo os b ia pa ox l iq oy\" data-selectable-paragraph=\"\"><em class=\"oz\">#reading image<\/em><\/span><span id=\"5e21\" class=\"nq nr fo os b ia pa ox l iq oy\" data-selectable-paragraph=\"\"><em class=\"oz\">original_image = cv2.imread('passport_new.jpg')<\/em><\/span><span id=\"f7c9\" class=\"nq nr fo os b ia pa ox l iq oy\" data-selectable-paragraph=\"\"><em class=\"oz\">original_image = cv2.cvtColor(original_image,cv2.COLOR_BGR2RGB)<\/em><\/span><span id=\"a12c\" class=\"nq nr fo os b ia pa ox l iq oy\" data-selectable-paragraph=\"\"><em class=\"oz\">resized1=cv2.resize(original_image, (960,840))<\/em><\/span><span id=\"37c0\" class=\"nq nr fo os b ia pa ox l iq oy\" data-selectable-paragraph=\"\"><em class=\"oz\">plt.imshow(resized1)<\/em><\/span><\/pre>\n<figure class=\"nd ne nf ng nh ni na nb paragraph-image\">\n<div class=\"pc pd eb pe bg pf\" tabindex=\"0\" role=\"button\">\n<figure><img loading=\"lazy\" decoding=\"async\" class=\"bg nj nk c\" role=\"presentation\" src=\"https:\/\/miro.medium.com\/v2\/resize:fit:374\/1*W8h8tx19QYgrcKxdvBpqHA.png\" alt=\"\" width=\"374\" height=\"467\"><\/figure><div class=\"na nb pb\"><picture><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/format:webp\/1*W8h8tx19QYgrcKxdvBpqHA.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/format:webp\/1*W8h8tx19QYgrcKxdvBpqHA.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/format:webp\/1*W8h8tx19QYgrcKxdvBpqHA.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/format:webp\/1*W8h8tx19QYgrcKxdvBpqHA.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/format:webp\/1*W8h8tx19QYgrcKxdvBpqHA.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/format:webp\/1*W8h8tx19QYgrcKxdvBpqHA.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:748\/format:webp\/1*W8h8tx19QYgrcKxdvBpqHA.png 748w\" type=\"image\/webp\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 374px\"><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/1*W8h8tx19QYgrcKxdvBpqHA.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/1*W8h8tx19QYgrcKxdvBpqHA.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/1*W8h8tx19QYgrcKxdvBpqHA.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/1*W8h8tx19QYgrcKxdvBpqHA.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/1*W8h8tx19QYgrcKxdvBpqHA.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/1*W8h8tx19QYgrcKxdvBpqHA.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:748\/1*W8h8tx19QYgrcKxdvBpqHA.png 748w\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 374px\" data-testid=\"og\"><\/picture><\/div>\n<\/div>\n<figcaption class=\"nl nm nn na nb no np be b bf z dv\" data-selectable-paragraph=\"\">original image<\/figcaption>\n<\/figure>\n<h2 id=\"80a4\" class=\"nq nr fo be ns nt nu nv nw nx ny nz oa mn ob oc od mr oe of og mv oh oi oj ok bj\" data-selectable-paragraph=\"\"><strong class=\"al\">Transform Image to Grayscale<\/strong><\/h2>\n<p id=\"d17b\" class=\"pw-post-body-paragraph mf mg fo be b gm ol mi mj gp om ml mm mn on mp mq mr oo mt mu mv op mx my mz fh bj\" data-selectable-paragraph=\"\">The cvtColor (image, flag) method in CV2 transforms an image into the color-spaced referred to as \u2018flag\u2019. We can choose any color flag but, in this case, we opted for the grayscale and thus used the BGR2GRAY flag.<\/p>\n<pre class=\"nd ne nf ng nh or os ot ou ax ov bj\"><span id=\"ea33\" class=\"nq nr fo os b ia ow ox l iq oy\" data-selectable-paragraph=\"\"><em class=\"oz\">#transforming image to grayscale<\/em><\/span><span id=\"0a26\" class=\"nq nr fo os b ia pa ox l iq oy\" data-selectable-paragraph=\"\"><em class=\"oz\">grayscale_image=cv2.cvtColor(original_image, cv2.COLOR_BGR2GRAY)<\/em><\/span><span id=\"dc0f\" class=\"nq nr fo os b ia pa ox l iq oy\" data-selectable-paragraph=\"\"><em class=\"oz\">resized2=cv2.resize(grayscale_image, (960,840))<\/em><\/span><span id=\"8679\" class=\"nq nr fo os b ia pa ox l iq oy\" data-selectable-paragraph=\"\"><em class=\"oz\">plt.imshow(resized2,cmap='gray')<\/em><\/span><\/pre>\n<figure class=\"nd ne nf ng nh ni na nb paragraph-image\">\n<figure><img loading=\"lazy\" decoding=\"async\" class=\"bg nj nk c\" role=\"presentation\" src=\"https:\/\/miro.medium.com\/v2\/resize:fit:374\/1*883pycRTcQNOKWUo_TFs7w.png\" alt=\"\" width=\"374\" height=\"463\"><\/figure><div class=\"na nb pb\"><picture><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/format:webp\/1*883pycRTcQNOKWUo_TFs7w.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/format:webp\/1*883pycRTcQNOKWUo_TFs7w.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/format:webp\/1*883pycRTcQNOKWUo_TFs7w.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/format:webp\/1*883pycRTcQNOKWUo_TFs7w.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/format:webp\/1*883pycRTcQNOKWUo_TFs7w.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/format:webp\/1*883pycRTcQNOKWUo_TFs7w.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:748\/format:webp\/1*883pycRTcQNOKWUo_TFs7w.png 748w\" type=\"image\/webp\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 374px\"><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/1*883pycRTcQNOKWUo_TFs7w.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/1*883pycRTcQNOKWUo_TFs7w.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/1*883pycRTcQNOKWUo_TFs7w.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/1*883pycRTcQNOKWUo_TFs7w.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/1*883pycRTcQNOKWUo_TFs7w.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/1*883pycRTcQNOKWUo_TFs7w.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:748\/1*883pycRTcQNOKWUo_TFs7w.png 748w\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 374px\" data-testid=\"og\"><\/picture><\/div>\n<figcaption class=\"nl nm nn na nb no np be b bf z dv\" data-selectable-paragraph=\"\">Grayscale image output<\/figcaption>\n<\/figure>\n<h2 id=\"c403\" class=\"nq nr fo be ns nt nu nv nw nx ny nz oa mn ob oc od mr oe of og mv oh oi oj ok bj\" data-selectable-paragraph=\"\"><strong class=\"al\">Smoothing the Grayscale Image<\/strong><\/h2>\n<p id=\"b39b\" class=\"pw-post-body-paragraph mf mg fo be b gm ol mi mj gp om ml mm mn on mp mq mr oo mt mu mv op mx my mz fh bj\" data-selectable-paragraph=\"\">We apply the blur effect using the medianBlur() function to smooth the image. The center pixel is assigned a mean value of all the pixels which in turn creates a blurring effect.<\/p>\n<pre class=\"nd ne nf ng nh or os ot ou ax ov bj\"><span id=\"a450\" class=\"nq nr fo os b ia ow ox l iq oy\" data-selectable-paragraph=\"\"><em class=\"oz\">#apply median blur to smoothen an image<\/em><\/span><span id=\"6c78\" class=\"nq nr fo os b ia pa ox l iq oy\" data-selectable-paragraph=\"\"><em class=\"oz\">smooth_grayscale=cv2.medianBlur(grayscale_image,5)<\/em><\/span><span id=\"68cd\" class=\"nq nr fo os b ia pa ox l iq oy\" data-selectable-paragraph=\"\"><em class=\"oz\">resized3=cv2.resize(smooth_grayscale,(960,840))<\/em><\/span><span id=\"615b\" class=\"nq nr fo os b ia pa ox l iq oy\" data-selectable-paragraph=\"\"><em class=\"oz\">plt.imshow(resized3,cmap='gray')<\/em><\/span><\/pre>\n<figure class=\"nd ne nf ng nh ni na nb paragraph-image\">\n<figure><img loading=\"lazy\" decoding=\"async\" class=\"bg nj nk c\" role=\"presentation\" src=\"https:\/\/miro.medium.com\/v2\/resize:fit:373\/1*PLfOl19zvRnK_2WtwN1J5A.png\" alt=\"\" width=\"373\" height=\"465\"><\/figure><div class=\"na nb pg\"><picture><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/format:webp\/1*PLfOl19zvRnK_2WtwN1J5A.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/format:webp\/1*PLfOl19zvRnK_2WtwN1J5A.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/format:webp\/1*PLfOl19zvRnK_2WtwN1J5A.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/format:webp\/1*PLfOl19zvRnK_2WtwN1J5A.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/format:webp\/1*PLfOl19zvRnK_2WtwN1J5A.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/format:webp\/1*PLfOl19zvRnK_2WtwN1J5A.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:746\/format:webp\/1*PLfOl19zvRnK_2WtwN1J5A.png 746w\" type=\"image\/webp\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 373px\"><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/1*PLfOl19zvRnK_2WtwN1J5A.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/1*PLfOl19zvRnK_2WtwN1J5A.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/1*PLfOl19zvRnK_2WtwN1J5A.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/1*PLfOl19zvRnK_2WtwN1J5A.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/1*PLfOl19zvRnK_2WtwN1J5A.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/1*PLfOl19zvRnK_2WtwN1J5A.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:746\/1*PLfOl19zvRnK_2WtwN1J5A.png 746w\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 373px\" data-testid=\"og\"><\/picture><\/div>\n<figcaption class=\"nl nm nn na nb no np be b bf z dv\" data-selectable-paragraph=\"\">Smoothed grayscale image<\/figcaption>\n<\/figure>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n<div class=\"fh fi fj fk fl\">\n<div class=\"ab ca\">\n<div class=\"ch bg et eu ev ew\">\n<blockquote class=\"pp\"><p id=\"b445\" class=\"pq pr fo be ps pt pu pv pw px py mz dv\" data-selectable-paragraph=\"\">Introducing the Comet AI art gallery \u2014 a public forum to log experiments, test different parameters, and share your AI-generated art! <a class=\"af oq\" href=\"https:\/\/www.comet.com\/site\/clipdraw-gallery-ai-art-powered-by-comet-and-gradio\/\" target=\"_blank\" rel=\"noopener ugc nofollow\">Learn more about our integration with Gradio to create this one-of-a-kind space<\/a>.<\/p><\/blockquote>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n<div class=\"fh fi fj fk fl\">\n<div class=\"ab ca\">\n<div class=\"ch bg et eu ev ew\">\n<h2 id=\"fd66\" class=\"nq nr fo be ns nt nu nv nw nx ny nz oa mn ob oc od mr oe of og mv oh oi oj ok bj\" data-selectable-paragraph=\"\"><strong class=\"al\">Detect and Enhance the Image Edges<\/strong><\/h2>\n<p id=\"4d68\" class=\"pw-post-body-paragraph mf mg fo be b gm ol mi mj gp om ml mm mn on mp mq mr oo mt mu mv op mx my mz fh bj\" data-selectable-paragraph=\"\">Cartooning an image is more about detecting the image\u2019s edges and highlighting them. In this step, we detect and enhance the edges of the image by the thresholding technique. The threshold value is the mean of the neighborhood pixel values area minus constant C. Thresh_binary is the type of threshold applied and (9, 9) the block size.<\/p>\n<pre class=\"nd ne nf ng nh or os ot ou ax ov bj\"><span id=\"e191\" class=\"nq nr fo os b ia ow ox l iq oy\" data-selectable-paragraph=\"\"><em class=\"oz\">#retrieve the edges for cartoon effect using threshold effect<\/em><\/span><span id=\"3e13\" class=\"nq nr fo os b ia pa ox l iq oy\" data-selectable-paragraph=\"\"><em class=\"oz\">image_edge=cv2.adaptiveThreshold(smooth_grayscale,255,cv2.ADAPTIVE_THRESH_MEAN_C,cv2.THRESH_BINARY,9,9)<\/em><\/span><span id=\"2334\" class=\"nq nr fo os b ia pa ox l iq oy\" data-selectable-paragraph=\"\"><em class=\"oz\">resized4=cv2.resize(image_edge,(960,840))<\/em><\/span><span id=\"e90a\" class=\"nq nr fo os b ia pa ox l iq oy\" data-selectable-paragraph=\"\"><em class=\"oz\">plt.imshow(resized4,cmap='gray')<\/em><\/span><\/pre>\n<figure class=\"nd ne nf ng nh ni na nb paragraph-image\">\n<figure><img loading=\"lazy\" decoding=\"async\" class=\"bg nj nk c\" role=\"presentation\" src=\"https:\/\/miro.medium.com\/v2\/resize:fit:374\/1*JTWUpmlbP_HXUIuCHr57mA.png\" alt=\"\" width=\"374\" height=\"464\"><\/figure><div class=\"na nb pb\"><picture><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/format:webp\/1*JTWUpmlbP_HXUIuCHr57mA.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/format:webp\/1*JTWUpmlbP_HXUIuCHr57mA.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/format:webp\/1*JTWUpmlbP_HXUIuCHr57mA.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/format:webp\/1*JTWUpmlbP_HXUIuCHr57mA.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/format:webp\/1*JTWUpmlbP_HXUIuCHr57mA.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/format:webp\/1*JTWUpmlbP_HXUIuCHr57mA.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:748\/format:webp\/1*JTWUpmlbP_HXUIuCHr57mA.png 748w\" type=\"image\/webp\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 374px\"><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/1*JTWUpmlbP_HXUIuCHr57mA.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/1*JTWUpmlbP_HXUIuCHr57mA.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/1*JTWUpmlbP_HXUIuCHr57mA.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/1*JTWUpmlbP_HXUIuCHr57mA.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/1*JTWUpmlbP_HXUIuCHr57mA.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/1*JTWUpmlbP_HXUIuCHr57mA.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:748\/1*JTWUpmlbP_HXUIuCHr57mA.png 748w\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 374px\" data-testid=\"og\"><\/picture><\/div>\n<figcaption class=\"nl nm nn na nb no np be b bf z dv\" data-selectable-paragraph=\"\">Image with enhanced edges<\/figcaption>\n<\/figure>\n<h2 id=\"5d39\" class=\"nq nr fo be ns nt nu nv nw nx ny nz oa mn ob oc od mr oe of og mv oh oi oj ok bj\" data-selectable-paragraph=\"\"><strong class=\"al\">Creating a Mask Image<\/strong><\/h2>\n<p id=\"04bf\" class=\"pw-post-body-paragraph mf mg fo be b gm ol mi mj gp om ml mm mn on mp mq mr oo mt mu mv op mx my mz fh bj\" data-selectable-paragraph=\"\">The bilateralFilter() function enables us to keep the image edges sharp and textures smooth. The second value (9) is the diameter of the pixel neighborhood i.e. the number of pixels around a certain pixel that determines its value. The third and fourth values (350, 350) determine the sigmaColor and sigmaSpace. These values give the sigma effect i.e. the image looks sharp with smooth textures. We can change the value of sigmaColor and sigmaSpace to see the change in the output of the image.<\/p>\n<pre class=\"nd ne nf ng nh or os ot ou ax ov bj\"><span id=\"43cb\" class=\"nq nr fo os b ia ow ox l iq oy\" data-selectable-paragraph=\"\"><em class=\"oz\">#using bilateral filter to remove noise and keep edge sharp<\/em><\/span><span id=\"abb6\" class=\"nq nr fo os b ia pa ox l iq oy\" data-selectable-paragraph=\"\"><em class=\"oz\">colored_image=cv2.bilateralFilter(original_image,9,350,350)<\/em><\/span><span id=\"adbe\" class=\"nq nr fo os b ia pa ox l iq oy\" data-selectable-paragraph=\"\"><em class=\"oz\">resized5=cv2.resize(colored_image,(960,840))<\/em><\/span><span id=\"630f\" class=\"nq nr fo os b ia pa ox l iq oy\" data-selectable-paragraph=\"\"><em class=\"oz\">plt.imshow(resized5,cmap='gray')<\/em><\/span><\/pre>\n<figure class=\"nd ne nf ng nh ni na nb paragraph-image\">\n<figure><img loading=\"lazy\" decoding=\"async\" class=\"bg nj nk c\" role=\"presentation\" src=\"https:\/\/miro.medium.com\/v2\/resize:fit:376\/1*98UK6w9vu9m1dGg-6FAhsg.png\" alt=\"\" width=\"376\" height=\"465\"><\/figure><div class=\"na nb pz\"><picture><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/format:webp\/1*98UK6w9vu9m1dGg-6FAhsg.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/format:webp\/1*98UK6w9vu9m1dGg-6FAhsg.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/format:webp\/1*98UK6w9vu9m1dGg-6FAhsg.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/format:webp\/1*98UK6w9vu9m1dGg-6FAhsg.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/format:webp\/1*98UK6w9vu9m1dGg-6FAhsg.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/format:webp\/1*98UK6w9vu9m1dGg-6FAhsg.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:752\/format:webp\/1*98UK6w9vu9m1dGg-6FAhsg.png 752w\" type=\"image\/webp\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 376px\"><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/1*98UK6w9vu9m1dGg-6FAhsg.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/1*98UK6w9vu9m1dGg-6FAhsg.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/1*98UK6w9vu9m1dGg-6FAhsg.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/1*98UK6w9vu9m1dGg-6FAhsg.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/1*98UK6w9vu9m1dGg-6FAhsg.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/1*98UK6w9vu9m1dGg-6FAhsg.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:752\/1*98UK6w9vu9m1dGg-6FAhsg.png 752w\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 376px\" data-testid=\"og\"><\/picture><\/div>\n<figcaption class=\"nl nm nn na nb no np be b bf z dv\" data-selectable-paragraph=\"\">Masking image<\/figcaption>\n<\/figure>\n<h2 id=\"239c\" class=\"nq nr fo be ns nt nu nv nw nx ny nz oa mn ob oc od mr oe of og mv oh oi oj ok bj\" data-selectable-paragraph=\"\"><strong class=\"al\">Cartoonify the Image<\/strong><\/h2>\n<p id=\"928b\" class=\"pw-post-body-paragraph mf mg fo be b gm ol mi mj gp om ml mm mn on mp mq mr oo mt mu mv op mx my mz fh bj\" data-selectable-paragraph=\"\">We will now combine the image outputs through masking. The CV2 bitwise function enables us to mask the images and give a cartoon effect to the image output with thicker lines and blurred colors.<\/p>\n<pre class=\"nd ne nf ng nh or os ot ou ax ov bj\"><span id=\"a351\" class=\"nq nr fo os b ia ow ox l iq oy\" data-selectable-paragraph=\"\"><em class=\"oz\">#cartooning the image<\/em><\/span><span id=\"ee17\" class=\"nq nr fo os b ia pa ox l iq oy\" data-selectable-paragraph=\"\"><em class=\"oz\">cartoon_image=cv2.bitwise_and(colored_image,colored_image,mask=image_edge)<\/em><\/span><span id=\"1188\" class=\"nq nr fo os b ia pa ox l iq oy\" data-selectable-paragraph=\"\"><em class=\"oz\">resized6=cv2.resize(cartoon_image,(960,840))<\/em><\/span><span id=\"dbd8\" class=\"nq nr fo os b ia pa ox l iq oy\" data-selectable-paragraph=\"\"><em class=\"oz\">plt.imshow(resized6,cmap='gray')<\/em><\/span><\/pre>\n<figure class=\"nd ne nf ng nh ni na nb paragraph-image\">\n<div class=\"pc pd eb pe bg pf\" tabindex=\"0\" role=\"button\">\n<figure><img loading=\"lazy\" decoding=\"async\" class=\"bg nj nk c\" role=\"presentation\" src=\"https:\/\/miro.medium.com\/v2\/resize:fit:374\/1*j1gvLZX67sdLr4ce2MKIqQ.png\" alt=\"\" width=\"374\" height=\"466\"><\/figure><div class=\"na nb pb\"><picture><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/format:webp\/1*j1gvLZX67sdLr4ce2MKIqQ.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/format:webp\/1*j1gvLZX67sdLr4ce2MKIqQ.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/format:webp\/1*j1gvLZX67sdLr4ce2MKIqQ.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/format:webp\/1*j1gvLZX67sdLr4ce2MKIqQ.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/format:webp\/1*j1gvLZX67sdLr4ce2MKIqQ.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/format:webp\/1*j1gvLZX67sdLr4ce2MKIqQ.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:748\/format:webp\/1*j1gvLZX67sdLr4ce2MKIqQ.png 748w\" type=\"image\/webp\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 374px\"><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/1*j1gvLZX67sdLr4ce2MKIqQ.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/1*j1gvLZX67sdLr4ce2MKIqQ.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/1*j1gvLZX67sdLr4ce2MKIqQ.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/1*j1gvLZX67sdLr4ce2MKIqQ.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/1*j1gvLZX67sdLr4ce2MKIqQ.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/1*j1gvLZX67sdLr4ce2MKIqQ.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:748\/1*j1gvLZX67sdLr4ce2MKIqQ.png 748w\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 374px\" data-testid=\"og\"><\/picture><\/div>\n<\/div>\n<figcaption class=\"nl nm nn na nb no np be b bf z dv\" data-selectable-paragraph=\"\">Cartoon image<\/figcaption>\n<\/figure>\n<h2 id=\"7a62\" class=\"nq nr fo be ns nt nu nv nw nx ny nz oa mn ob oc od mr oe of og mv oh oi oj ok bj\" data-selectable-paragraph=\"\"><strong class=\"al\">Plotting all Transitions<\/strong><\/h2>\n<p id=\"af56\" class=\"pw-post-body-paragraph mf mg fo be b gm ol mi mj gp om ml mm mn on mp mq mr oo mt mu mv op mx my mz fh bj\" data-selectable-paragraph=\"\">We will first make a list of all image outputs. The image list contains all the resized images. The output plot displays the image transitions from the original to the cartoon image.<\/p>\n<pre class=\"nd ne nf ng nh or os ot ou ax ov bj\"><span id=\"4cad\" class=\"nq nr fo os b ia ow ox l iq oy\" data-selectable-paragraph=\"\"><em class=\"oz\">#plotting all transitions<\/em><\/span><span id=\"1cf8\" class=\"nq nr fo os b ia pa ox l iq oy\" data-selectable-paragraph=\"\"><em class=\"oz\">image_list=[resized1,resized2,resized3,resized4,resized5,resized6]<\/em><\/span><span id=\"1e6b\" class=\"nq nr fo os b ia pa ox l iq oy\" data-selectable-paragraph=\"\"><em class=\"oz\">fig, axes=plt.subplots(2,3, figsize=(18,8),subplot_kw={'xticks':[],'yticks':[]},gridspec_kw=dict(hspace=0.1,wspace=0.1))<\/em><\/span><span id=\"a9c8\" class=\"nq nr fo os b ia pa ox l iq oy\" data-selectable-paragraph=\"\"><em class=\"oz\">for i, ax in enumerate (axes.flat):<\/em><\/span><span id=\"3488\" class=\"nq nr fo os b ia pa ox l iq oy\" data-selectable-paragraph=\"\"><em class=\"oz\">ax.imshow(image_list[i],cmap='gray')<\/em><\/span><span id=\"469f\" class=\"nq nr fo os b ia pa ox l iq oy\" data-selectable-paragraph=\"\"><em class=\"oz\">plt.show()<\/em><\/span><\/pre>\n<figure class=\"nd ne nf ng nh ni na nb paragraph-image\">\n<div class=\"pc pd eb pe bg pf\" tabindex=\"0\" role=\"button\">\n<figure><img loading=\"lazy\" decoding=\"async\" class=\"bg nj nk c\" role=\"presentation\" src=\"https:\/\/miro.medium.com\/v2\/resize:fit:700\/1*FWcsLfQnU8A72atcP396tw.png\" alt=\"\" width=\"700\" height=\"332\"><\/figure><div class=\"na nb qa\"><picture><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/format:webp\/1*FWcsLfQnU8A72atcP396tw.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/format:webp\/1*FWcsLfQnU8A72atcP396tw.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/format:webp\/1*FWcsLfQnU8A72atcP396tw.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/format:webp\/1*FWcsLfQnU8A72atcP396tw.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/format:webp\/1*FWcsLfQnU8A72atcP396tw.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/format:webp\/1*FWcsLfQnU8A72atcP396tw.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:1400\/format:webp\/1*FWcsLfQnU8A72atcP396tw.png 1400w\" type=\"image\/webp\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 700px\"><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/1*FWcsLfQnU8A72atcP396tw.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/1*FWcsLfQnU8A72atcP396tw.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/1*FWcsLfQnU8A72atcP396tw.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/1*FWcsLfQnU8A72atcP396tw.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/1*FWcsLfQnU8A72atcP396tw.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/1*FWcsLfQnU8A72atcP396tw.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:1400\/1*FWcsLfQnU8A72atcP396tw.png 1400w\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 700px\" data-testid=\"og\"><\/picture><\/div>\n<\/div>\n<figcaption class=\"nl nm nn na nb no np be b bf z dv\" data-selectable-paragraph=\"\">Image transformations<\/figcaption>\n<\/figure>\n<h2 id=\"c17b\" class=\"nq nr fo be ns nt nu nv nw nx ny nz oa mn ob oc od mr oe of og mv oh oi oj ok bj\" data-selectable-paragraph=\"\"><strong class=\"al\">Other Image Transformations<\/strong><\/h2>\n<p id=\"229f\" class=\"pw-post-body-paragraph mf mg fo be b gm ol mi mj gp om ml mm mn on mp mq mr oo mt mu mv op mx my mz fh bj\" data-selectable-paragraph=\"\"><strong class=\"be qb\">Stylization: <\/strong>In this transformation, we use the stylization technique to create a cartoon of the image. We can edit the sigma color and radius to get a better output.<\/p>\n<pre class=\"nd ne nf ng nh or os ot ou ax ov bj\"><span id=\"b314\" class=\"nq nr fo os b ia ow ox l iq oy\" data-selectable-paragraph=\"\"><em class=\"oz\">#stylization technique<\/em><\/span><span id=\"639b\" class=\"nq nr fo os b ia pa ox l iq oy\" data-selectable-paragraph=\"\"><em class=\"oz\">stylization_image=cv2.stylization(original_image,sigma_s=100,sigma_r=0.1)<\/em><\/span><span id=\"a385\" class=\"nq nr fo os b ia pa ox l iq oy\" data-selectable-paragraph=\"\"><em class=\"oz\">plt.figure(figsize=(18,8))<\/em><\/span><span id=\"bd96\" class=\"nq nr fo os b ia pa ox l iq oy\" data-selectable-paragraph=\"\"><em class=\"oz\">plt.imshow(stylization_image,cmap='gray')<\/em><\/span><\/pre>\n<figure class=\"nd ne nf ng nh ni na nb paragraph-image\">\n<div class=\"pc pd eb pe bg pf\" tabindex=\"0\" role=\"button\">\n<figure><img loading=\"lazy\" decoding=\"async\" class=\"bg nj nk c\" role=\"presentation\" src=\"https:\/\/miro.medium.com\/v2\/resize:fit:376\/1*RebxD3AZECDlYYQc8Tj6cw.png\" alt=\"\" width=\"376\" height=\"463\"><\/figure><div class=\"na nb pz\"><picture><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/format:webp\/1*RebxD3AZECDlYYQc8Tj6cw.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/format:webp\/1*RebxD3AZECDlYYQc8Tj6cw.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/format:webp\/1*RebxD3AZECDlYYQc8Tj6cw.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/format:webp\/1*RebxD3AZECDlYYQc8Tj6cw.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/format:webp\/1*RebxD3AZECDlYYQc8Tj6cw.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/format:webp\/1*RebxD3AZECDlYYQc8Tj6cw.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:752\/format:webp\/1*RebxD3AZECDlYYQc8Tj6cw.png 752w\" type=\"image\/webp\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 376px\"><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/1*RebxD3AZECDlYYQc8Tj6cw.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/1*RebxD3AZECDlYYQc8Tj6cw.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/1*RebxD3AZECDlYYQc8Tj6cw.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/1*RebxD3AZECDlYYQc8Tj6cw.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/1*RebxD3AZECDlYYQc8Tj6cw.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/1*RebxD3AZECDlYYQc8Tj6cw.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:752\/1*RebxD3AZECDlYYQc8Tj6cw.png 752w\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 376px\" data-testid=\"og\"><\/picture><\/div>\n<\/div>\n<figcaption class=\"nl nm nn na nb no np be b bf z dv\" data-selectable-paragraph=\"\">Stylized image<\/figcaption>\n<\/figure>\n<p id=\"2764\" class=\"pw-post-body-paragraph mf mg fo be b gm mh mi mj gp mk ml mm mn mo mp mq mr ms mt mu mv mw mx my mz fh bj\" data-selectable-paragraph=\"\"><strong class=\"be qb\">Pencil Sketch: <\/strong>We will implement the pencil sketch to create a cartoon image in this transformation. The <em class=\"oz\">cv2.pencilSketch() <\/em>function automatically applies the dodging and burning effects to the original image. These techniques were commonly used in traditional photography. Dodging lightens an image, whereas burning darkens it.<\/p>\n<pre class=\"nd ne nf ng nh or os ot ou ax ov bj\"><span id=\"ac58\" class=\"nq nr fo os b ia ow ox l iq oy\" data-selectable-paragraph=\"\"><em class=\"oz\">#pencil sketch technique<\/em><\/span><span id=\"822c\" class=\"nq nr fo os b ia pa ox l iq oy\" data-selectable-paragraph=\"\"><em class=\"oz\">pencilsketch_image1,pencilsketch_image2=cv2.pencilSketch(original_image,sigma_s=50,sigma_r=0.3,shade_factor=0.02)<\/em><\/span><span id=\"bd03\" class=\"nq nr fo os b ia pa ox l iq oy\" data-selectable-paragraph=\"\"><em class=\"oz\">plt.figure(figsize=(18,8))<\/em><\/span><span id=\"50f3\" class=\"nq nr fo os b ia pa ox l iq oy\" data-selectable-paragraph=\"\"><em class=\"oz\">plt.imshow(pencilsketch_image1,cmap='gray')<\/em><\/span><\/pre>\n<figure class=\"nd ne nf ng nh ni na nb paragraph-image\">\n<figure><img loading=\"lazy\" decoding=\"async\" class=\"bg nj nk c\" role=\"presentation\" src=\"https:\/\/miro.medium.com\/v2\/resize:fit:375\/1*wFsZesJ4TmETtWgoibfYww.png\" alt=\"\" width=\"375\" height=\"463\"><\/figure><div class=\"na nb qc\"><picture><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/format:webp\/1*wFsZesJ4TmETtWgoibfYww.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/format:webp\/1*wFsZesJ4TmETtWgoibfYww.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/format:webp\/1*wFsZesJ4TmETtWgoibfYww.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/format:webp\/1*wFsZesJ4TmETtWgoibfYww.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/format:webp\/1*wFsZesJ4TmETtWgoibfYww.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/format:webp\/1*wFsZesJ4TmETtWgoibfYww.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/format:webp\/1*wFsZesJ4TmETtWgoibfYww.png 750w\" type=\"image\/webp\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 375px\"><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/1*wFsZesJ4TmETtWgoibfYww.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/1*wFsZesJ4TmETtWgoibfYww.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/1*wFsZesJ4TmETtWgoibfYww.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/1*wFsZesJ4TmETtWgoibfYww.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/1*wFsZesJ4TmETtWgoibfYww.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/1*wFsZesJ4TmETtWgoibfYww.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/1*wFsZesJ4TmETtWgoibfYww.png 750w\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 375px\" data-testid=\"og\"><\/picture><\/div>\n<figcaption class=\"nl nm nn na nb no np be b bf z dv\" data-selectable-paragraph=\"\">Pencil sketch image<\/figcaption>\n<\/figure>\n<h2 id=\"e51c\" class=\"nq nr fo be ns nt nu nv nw nx ny nz oa mn ob oc od mr oe of og mv oh oi oj ok bj\" data-selectable-paragraph=\"\"><strong class=\"al\">Conclusion<\/strong><\/h2>\n<p id=\"0742\" class=\"pw-post-body-paragraph mf mg fo be b gm ol mi mj gp om ml mm mn on mp mq mr oo mt mu mv op mx my mz fh bj\" data-selectable-paragraph=\"\">In this article, we have demonstrated how we can use OpenCV in Python to create different image transformations. Feel free to try these transformations on your own. In case of any questions, comments you can get in touch via my <a class=\"af oq\" href=\"https:\/\/www.linkedin.com\/in\/brianmwangi\/\" target=\"_blank\" rel=\"noopener ugc nofollow\">Linkedln<\/a> profile. Thanks for reading!<\/p>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Image transformations such as cartooning images are a common hobby for many people. Cartoons were a great source of entertainment during our childhood and image cartooning has been trending for a while and people use different applications to transform their images into cartoon images. In this article, we are interested in the process involved in [&hellip;]<\/p>\n","protected":false},"author":71,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"customer_name":"","customer_description":"","customer_industry":"","customer_technologies":"","customer_logo":"","footnotes":""},"categories":[6,7],"tags":[],"coauthors":[169],"class_list":["post-7463","post","type-post","status-publish","format-standard","hentry","category-machine-learning","category-tutorials"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.9 (Yoast SEO v25.9) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Image Transformations Using OpenCV in Python - Comet<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.comet.com\/site\/blog\/image-transformations-using-opencv-in-python\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Image Transformations Using OpenCV in Python\" \/>\n<meta property=\"og:description\" content=\"Image transformations such as cartooning images are a common hobby for many people. Cartoons were a great source of entertainment during our childhood and image cartooning has been trending for a while and people use different applications to transform their images into cartoon images. In this article, we are interested in the process involved in [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.comet.com\/site\/blog\/image-transformations-using-opencv-in-python\/\" \/>\n<meta property=\"og:site_name\" content=\"Comet\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/cometdotml\" \/>\n<meta property=\"article:published_time\" content=\"2023-09-13T00:07:35+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-04-24T17:14:09+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/miro.medium.com\/v2\/resize:fit:400\/1*gVIPxVakNUTDTvyNwC5jDA.png\" \/>\n<meta name=\"author\" content=\"Brian Mwangi\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@Cometml\" \/>\n<meta name=\"twitter:site\" content=\"@Cometml\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Brian Mwangi\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Image Transformations Using OpenCV in Python - Comet","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.comet.com\/site\/blog\/image-transformations-using-opencv-in-python\/","og_locale":"en_US","og_type":"article","og_title":"Image Transformations Using OpenCV in Python","og_description":"Image transformations such as cartooning images are a common hobby for many people. Cartoons were a great source of entertainment during our childhood and image cartooning has been trending for a while and people use different applications to transform their images into cartoon images. In this article, we are interested in the process involved in [&hellip;]","og_url":"https:\/\/www.comet.com\/site\/blog\/image-transformations-using-opencv-in-python\/","og_site_name":"Comet","article_publisher":"https:\/\/www.facebook.com\/cometdotml","article_published_time":"2023-09-13T00:07:35+00:00","article_modified_time":"2025-04-24T17:14:09+00:00","og_image":[{"url":"https:\/\/miro.medium.com\/v2\/resize:fit:400\/1*gVIPxVakNUTDTvyNwC5jDA.png","type":"","width":"","height":""}],"author":"Brian Mwangi","twitter_card":"summary_large_image","twitter_creator":"@Cometml","twitter_site":"@Cometml","twitter_misc":{"Written by":"Brian Mwangi","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.comet.com\/site\/blog\/image-transformations-using-opencv-in-python\/#article","isPartOf":{"@id":"https:\/\/www.comet.com\/site\/blog\/image-transformations-using-opencv-in-python\/"},"author":{"name":"Brian Mwangi","@id":"https:\/\/www.comet.com\/site\/#\/schema\/person\/11e566851d7c80669e55ab10e6191a68"},"headline":"Image Transformations Using OpenCV in Python","datePublished":"2023-09-13T00:07:35+00:00","dateModified":"2025-04-24T17:14:09+00:00","mainEntityOfPage":{"@id":"https:\/\/www.comet.com\/site\/blog\/image-transformations-using-opencv-in-python\/"},"wordCount":824,"publisher":{"@id":"https:\/\/www.comet.com\/site\/#organization"},"image":{"@id":"https:\/\/www.comet.com\/site\/blog\/image-transformations-using-opencv-in-python\/#primaryimage"},"thumbnailUrl":"https:\/\/miro.medium.com\/v2\/resize:fit:400\/1*gVIPxVakNUTDTvyNwC5jDA.png","articleSection":["Machine Learning","Tutorials"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.comet.com\/site\/blog\/image-transformations-using-opencv-in-python\/","url":"https:\/\/www.comet.com\/site\/blog\/image-transformations-using-opencv-in-python\/","name":"Image Transformations Using OpenCV in Python - Comet","isPartOf":{"@id":"https:\/\/www.comet.com\/site\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.comet.com\/site\/blog\/image-transformations-using-opencv-in-python\/#primaryimage"},"image":{"@id":"https:\/\/www.comet.com\/site\/blog\/image-transformations-using-opencv-in-python\/#primaryimage"},"thumbnailUrl":"https:\/\/miro.medium.com\/v2\/resize:fit:400\/1*gVIPxVakNUTDTvyNwC5jDA.png","datePublished":"2023-09-13T00:07:35+00:00","dateModified":"2025-04-24T17:14:09+00:00","breadcrumb":{"@id":"https:\/\/www.comet.com\/site\/blog\/image-transformations-using-opencv-in-python\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.comet.com\/site\/blog\/image-transformations-using-opencv-in-python\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.comet.com\/site\/blog\/image-transformations-using-opencv-in-python\/#primaryimage","url":"https:\/\/miro.medium.com\/v2\/resize:fit:400\/1*gVIPxVakNUTDTvyNwC5jDA.png","contentUrl":"https:\/\/miro.medium.com\/v2\/resize:fit:400\/1*gVIPxVakNUTDTvyNwC5jDA.png"},{"@type":"BreadcrumbList","@id":"https:\/\/www.comet.com\/site\/blog\/image-transformations-using-opencv-in-python\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.comet.com\/site\/"},{"@type":"ListItem","position":2,"name":"Image Transformations Using OpenCV in Python"}]},{"@type":"WebSite","@id":"https:\/\/www.comet.com\/site\/#website","url":"https:\/\/www.comet.com\/site\/","name":"Comet","description":"Build Better Models Faster","publisher":{"@id":"https:\/\/www.comet.com\/site\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.comet.com\/site\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.comet.com\/site\/#organization","name":"Comet ML, Inc.","alternateName":"Comet","url":"https:\/\/www.comet.com\/site\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.comet.com\/site\/#\/schema\/logo\/image\/","url":"https:\/\/www.comet.com\/site\/wp-content\/uploads\/2025\/01\/logo_comet_square.png","contentUrl":"https:\/\/www.comet.com\/site\/wp-content\/uploads\/2025\/01\/logo_comet_square.png","width":310,"height":310,"caption":"Comet ML, Inc."},"image":{"@id":"https:\/\/www.comet.com\/site\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/cometdotml","https:\/\/x.com\/Cometml","https:\/\/www.youtube.com\/channel\/UCmN63HKvfXSCS-UwVwmK8Hw"]},{"@type":"Person","@id":"https:\/\/www.comet.com\/site\/#\/schema\/person\/11e566851d7c80669e55ab10e6191a68","name":"Brian Mwangi","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.comet.com\/site\/#\/schema\/person\/image\/d5b4daae2a6d50ff0f7f08cf468e8eec","url":"https:\/\/www.comet.com\/site\/wp-content\/uploads\/2023\/08\/1632239369714-96x96.jpg","contentUrl":"https:\/\/www.comet.com\/site\/wp-content\/uploads\/2023\/08\/1632239369714-96x96.jpg","caption":"Brian Mwangi"},"url":"https:\/\/www.comet.com\/site\/blog\/author\/brynmwangygmail-com\/"}]}},"_links":{"self":[{"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/posts\/7463","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/users\/71"}],"replies":[{"embeddable":true,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/comments?post=7463"}],"version-history":[{"count":1,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/posts\/7463\/revisions"}],"predecessor-version":[{"id":15546,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/posts\/7463\/revisions\/15546"}],"wp:attachment":[{"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/media?parent=7463"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/categories?post=7463"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/tags?post=7463"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/coauthors?post=7463"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}