

{"id":117654,"date":"2024-02-29T18:00:30","date_gmt":"2024-02-29T12:30:30","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=117654"},"modified":"2024-02-29T18:14:17","modified_gmt":"2024-02-29T12:44:17","slug":"working-with-images-in-opencv","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/working-with-images-in-opencv\/","title":{"rendered":"Working with Images in OpenCV"},"content":{"rendered":"<p>Hey there! If you&#8217;re fascinated by the incredible world of computer vision and image processing, then working with images in OpenCV is going to be right up your alley. Images are the heart and soul of so many captivating applications, from identifying objects to analyzing videos. Lucky for us, OpenCV, a fantastic open-source computer vision library, is here to help us make magic happen with those images.<\/p>\n<p>In this article, we&#8217;ll embark on a journey together, exploring the ins and outs of working with images in OpenCV. Whether you&#8217;re just starting out or a seasoned developer, this guide will be your trusty companion, unleashing the full potential of OpenCV for all your image-related tasks.<\/p>\n<h2>Image file types where deployment of OpenCV is possible :<\/h2>\n<ul>\n<li>OpenCV supports a wide range of image file types, making it a versatile library for image-processing tasks.<\/li>\n<li>Common image file formats supported by OpenCV include JPEG (JPG), PNG (Portable Network Graphics), BMP (Bitmap), GIF (Graphics Interchange Format), TIFF (Tagged Image File Format), and PBM\/PGM\/PPM (Portable Bitmap\/Graymap\/Pixmap).<\/li>\n<li>Additionally, OpenCV can handle various raw image formats and camera-specific formats, making it highly adaptable to different data sources.<\/li>\n<li>The extensive file format support of OpenCV enables seamless image loading, processing, and saving, catering to diverse image processing applications with ease and efficiency.<\/li>\n<\/ul>\n<p><strong>To read an image from a file using OpenCV, you need to have the following prerequisites:<\/strong><\/p>\n<p><strong>1. Python and OpenCV Installed:<\/strong> Ensure you have Python installed on your system. Additionally, you must have OpenCV installed. You can install OpenCV using pip by running the following command:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">pip install opencv-python\r\n<\/pre>\n<p><strong>2. Image File:<\/strong> You should have the image file (e.g., JPEG, PNG, etc.) you want to read using OpenCV. Make sure you know the file&#8217;s path or place it in the same directory as your Python script.<\/p>\n<p><strong>3. Working IDE or Code Editor:<\/strong> You need a working integrated development environment (IDE) or a code editor where you can write and execute your Python code. Popular choices include Anaconda, Jupyter Notebook, PyCharm, Visual Studio Code, or any other Python-supported IDE.<\/p>\n<p>Once you have Python, OpenCV installed, and an image file available, you are ready to read the image using OpenCV. Use the cv2.imread() function, passing the path to your image file as an argument. This will return the image data as a NumPy array, which you can further process or display as needed.<\/p>\n<h3>How to read an image from a file using OpenCV?<\/h3>\n<p>Ah, reading an image from a file is one of the fundamental steps in working with images in OpenCV. Let&#8217;s explore how you can do that!<\/p>\n<p><strong>To read an image from a file using OpenCV, you&#8217;ll need to follow these steps:<\/strong><\/p>\n<h4>1. Import the necessary OpenCV library:<\/h4>\n<p>Before diving into reading images, make sure you have OpenCV installed and imported into your project.<\/p>\n<p><strong>You can typically import it with the following line of code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">Import cv2\r\n<\/pre>\n<h4>2. Provide the path to the image file:<\/h4>\n<p>You&#8217;ll need to specify the path to the image file you want to read. It could be a relative or absolute path, depending on where the image is located on your system. Make sure to include the file extension (e.g., .jpg, .png, etc.). Think of it as giving OpenCV the directions to find the image in your computer&#8217;s vast storage.<\/p>\n<h4>3. Read the image using OpenCV&#8217;s `imread()` function:<\/h4>\n<p>OpenCV provides the `imread()` function, which allows you to read the image file. It outputs a NumPy array that represents the image after receiving the file location as input. It&#8217;s like opening a treasure chest filled with pixel values and colours.<\/p>\n<p><strong>Here&#8217;s an example of how to use it:<\/strong><\/p>\n<p>We are going to read an image of a Tiger from a file,<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">image = cv2.imread(r\"C:\\Users\\sanji\\Desktop\\DataFlair\\Working With Images in OpenCV\\wildlife-tiger.jpg\")\r\n<\/pre>\n<h4>4. Check if the image was successfully read:<\/h4>\n<p>It&#8217;s essential to verify if the image was successfully read from the file. You can check if the `image` variable is `None` or has a valid value. If it&#8217;s `None`, it means there was an error while reading the image. It&#8217;s like checking if your friend successfully picked up the image without any mishaps.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">import cv2\r\nimage = cv2.imread(r\"C:\\Users\\sanji\\Desktop\\DataFlair\\Working With Images in OpenCV\\wildlife-tiger.jpg\")\r\n\r\ncv2.imshow('DataFlair @satchit', image)\r\n\r\n\r\ncv2.waitKey(0)\r\ncv2.destroyAllWindows()\r\n<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/11\/the-image-was-successfully-read.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-125823 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/11\/the-image-was-successfully-read.webp\" alt=\" the image was successfully read\" width=\"1920\" height=\"1024\" \/><\/a><\/p>\n<h3>Various forms of cv2.imread()<\/h3>\n<h4>1. Reading an image as a color image: Using cv2.IMREAD_COLOUR<\/h4>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">import cv2\r\n\r\ncolor_image = cv2.imread(r\"C:\\Users\\sanji\\Desktop\\DataFlair\\Working With Images in OpenCV\\wildlife-tiger.jpg\", cv2.IMREAD_COLOR)\r\n<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/11\/Reading-an-image-as-a-color-image.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-125824 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/11\/Reading-an-image-as-a-color-image.webp\" alt=\"Reading an image as a color image\" width=\"1920\" height=\"1024\" \/><\/a><\/p>\n<p>This method reads the image in the BGR color format (default) and preserves the color information. Each pixel is represented by three color channels: Blue, Green, and Red.<\/p>\n<h4>2. Reading an image as a grayscale image: Using cv2.IMREAD_GRAYSCALE<\/h4>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">import cv2\r\nimage = cv2.imread(r\"C:\\Users\\sanji\\Desktop\\DataFlair\\Working With Images in OpenCV\\wildlife-tiger.jpg\",cv2.IMREAD_GRAYSCALE)\r\ncv2.imshow('DataFlair @satchit', image)\r\ncv2.waitKey(0)\r\ncv2.destroyAllWindows()\r\n<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/11\/grayscale-image.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-125825 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/11\/grayscale-image.webp\" alt=\"grayscale image\" width=\"1920\" height=\"1029\" \/><\/a><\/p>\n<p>In this case, the image is read in grayscale mode, where each pixel value represents the intensity of the grey colour. This is useful when color information is not necessary for your image-processing tasks.<\/p>\n<h4>3. Reading an image as-is with alpha channel (including transparency): Using cv2.IMREAD_UNCHANGED<\/h4>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">import cv2\r\nimage = cv2.imread(r\"C:\\Users\\sanji\\Desktop\\DataFlair\\Working With Images in OpenCV\\wildlife-tiger.jpg\",cv2.IMREAD_UNCHANGED)\r\ncv2.imshow('DataFlair @satchit', image)\r\ncv2.waitKey(0)\r\ncv2.destroyAllWindows()\r\n<\/pre>\n<p>This method allows you to read images that have an alpha channel, which represents transparency. It retains all color channels and additional alpha channel information<\/p>\n<h3>Let&#8217;s use cv2.imshow() to unveil a piece of art to the world!<\/h3>\n<ul>\n<li>Displaying an image in OpenCV using `cv2.imshow()` brings visuals to life with just one line of code.<\/li>\n<li>It allows you to unveil your favorite memories or creative masterpieces on the screen effortlessly.<\/li>\n<li>With a personalized title, you can add your own touch to the displayed image.<\/li>\n<li>The `cv2.imshow()` function immerses you in the beauty of your images, whether it&#8217;s a breathtaking landscape or a cute pet portrait.<\/li>\n<\/ul>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">import cv2\r\nimage = cv2.imread(r\"C:\\Users\\sanji\\Desktop\\DataFlair\\Working With Images in OpenCV\\wildlife-tiger.jpg\")\r\ncv2.imshow('DataFlair @satchit', image)\r\ncv2.waitKey(0)\r\ncv2.destroyAllWindows()\r\n<\/pre>\n<ul>\n<li>OpenCV&#8217;s enchanting display capabilities let your image-processing skills shine through as you showcase your cherished memories and artistic brilliance to the world.<\/li>\n<\/ul>\n<h3>Let\u2019s modify the pixel values of an image. Shall we?<\/h3>\n<p>Modifying pixel values in an image is a fundamental technique in image processing, allowing us to enhance, manipulate, or apply various effects to an image. With OpenCV, a popular computer vision library in Python, this process becomes seamless and efficient.<\/p>\n<ul>\n<li>Modifying pixel values in an image is a fundamental technique in image processing, enabling enhancements, filters, and artistic effects.<\/li>\n<li>OpenCV, a Python library, simplifies pixel manipulation with an intuitive interface.<\/li>\n<li>Accessing individual pixel coordinates and adjusting their RGB values achieves stunning visual transformations.<\/li>\n<li>OpenCV&#8217;s versatility allows for color changes, filters, contrast adjustments, and more.<\/li>\n<li>The code example below demonstrates inverting image colors using OpenCV:<\/li>\n<\/ul>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">import cv2\r\nimage = cv2.imread(r\"C:\\Users\\sanji\\Desktop\\DataFlair\\Working With Images in OpenCV\\wildlife-tiger.jpg\")\r\nif image is not None:\r\n    inverted_image = 255 - image\r\n     cv2.imshow('DataFlair OG @satchit', image)\r\n    cv2.imshow('DataFlair INT @satchit', inverted_image)\r\n     cv2.waitKey(0)\r\n    cv2.destroyAllWindows()\r\nelse:\r\n    print(\"Failed to load the image.\")\r\n<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/11\/the-pixel-values-of-an-image.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-125826 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/11\/the-pixel-values-of-an-image.webp\" alt=\"pixel values of an image\" width=\"1920\" height=\"1025\" \/><\/a><\/p>\n<ul>\n<li>In this example, we load an image using cv2.imread() and then create an inverted version of it by subtracting the RGB values from 255.<\/li>\n<li>The result is displayed alongside the original image using cv2.imshow().<\/li>\n<li>Running this code will show the original and inverted images side by side, demonstrating a basic image modification using OpenCV.<\/li>\n<\/ul>\n<h3>Here\u2019s an easy code to know about the dimensions of the image!<\/h3>\n<ul>\n<li>Determining image dimensions is a crucial first step in image processing, providing valuable insights for further manipulations.<\/li>\n<li>OpenCV&#8217;s simple Python code allows us to uncover the width and height of an image effortlessly.<\/li>\n<li>By using cv2.imread() to load the image and `image.shape`, we can access its dimensions.<\/li>\n<li>The first element of the shape represents the height, while the second element indicates the width.<\/li>\n<li>Understanding image dimensions empowers us to optimize memory usage, perform accurate resizing, and ensure compatibility with computer vision tasks.<\/li>\n<\/ul>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">import cv2\r\nimage = cv2.imread(r\"C:\\Users\\sanji\\Desktop\\DataFlair\\Working With Images in OpenCV\\wildlife-tiger.jpg\")\r\nif image is not None:\r\n     height, width, channels = image.shape\r\n  print(f\"Image Dimensions: {width}x{height}\")\r\nelse:\r\n    print(\"Failed to load the image.\")\r\n<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/11\/dimensions-of-the-image.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-125827 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/11\/dimensions-of-the-image.webp\" alt=\"dimensions of the image\" width=\"1920\" height=\"1028\" \/><\/a><\/p>\n<h3>Do you want to add a border or your own sketch to the image? Let\u2019s start!<\/h3>\n<ul>\n<li>Editing images with different borders or self-made drawings using OpenCV provides endless artistic possibilities.<\/li>\n<li>With a variety of tools and functions, you can add personalized touches to visuals and create captivating artwork.<\/li>\n<li>OpenCV allows you to frame images with colorful borders or sketch intricate drawings, turning ordinary visuals into extraordinary pieces.<\/li>\n<li>Utilizing geometric shapes, lines, and colors, you can craft unique overlays and artistic flair.<\/li>\n<li>Customizations, filters, and border additions can be easily applied to images to showcase your creative vision.<\/li>\n<li>The code example below demonstrates adding a colored border to an image using OpenCV:<\/li>\n<\/ul>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">import cv2\r\nimage = cv2.imread(r\"C:\\Users\\sanji\\Desktop\\DataFlair\\Working With Images in OpenCV\\wildlife-tiger.jpg\")\r\nif image is not None:\r\n     border_color = (0, 255, 0)  # Green color\r\n     border_width = 20\r\nbordered_image = cv2.copyMakeBorder(image, border_width, border_width, border_width, border_width, cv2.BORDER_CONSTANT, value=border_color)\r\ncv2.imshow('Original Image', image)\r\n    cv2.imshow('Bordered Image', bordered_image)\r\n cv2.waitKey(0)\r\n    cv2.destroyAllWindows()\r\nelse:\r\n    print(\"Failed to load the image.\")\r\n<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/11\/own-sketch-to-the-image.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-125828 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/11\/own-sketch-to-the-image.webp\" alt=\"own sketch to the image\" width=\"1920\" height=\"1022\" \/><\/a><\/p>\n<ul>\n<li>OpenCV becomes your canvas as you unleash your creativity and experiment with various edits, transforming images into captivating masterpieces. Let your imagination run wild and explore the boundless possibilities of image editing with OpenCV!<\/li>\n<\/ul>\n<h3>How to write and store an image from one file to another using OpenCV?<\/h3>\n<p>The cv2.imwrite() function in OpenCV is used to write\/save an image to disk in a specified file format. It allows you to store the results of your image processing or analysis or simply save an image for later use or sharing.<\/p>\n<p>Here are the key details you should know about cv2.imwrite():<\/p>\n<p><strong>1. Output filename:<\/strong> Specify the path and filename where you want to save the image. Make sure to include the appropriate file extension (e.g., `.jpg`, `.png`) to indicate the desired file format.<\/p>\n<p><strong>2. Image data:<\/strong> Pass the image you want to save to the function. It should be in the expected format for the chosen file format. For example, if you&#8217;re saving a color image, ensure the color channels are in the correct order (BGR).<\/p>\n<p>Here&#8217;s an example of how to use cv2.imwrite() :<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">import cv2\r\n\r\n\r\nimage = cv2.imread(r\"C:\\Users\\sanji\\Desktop\\DataFlair\\Working With Images in OpenCV\\wildlife-tiger.jpg\")\r\n\r\n\r\nimport cv2\r\n\r\n\r\noutput_path = r\"C:\\Users\\sanji\\Desktop\\DataFlair\/wildlife-tiger.jpg\"\r\n\r\n\r\ncv2.imwrite(output_path, image)\r\n\r\n<\/pre>\n<p>In this example, we load an image using `cv2.imread()` and store it in the `image` variable. Then, we specify the path and filename for the output image using `cv2.imwrite()`. By calling this function, the image is saved to the specified location with the provided filename.<\/p>\n<p>Make sure to provide the correct output path and filename to ensure the successful saving of the image. One can Perform any desired image processing or analysis between the cv2.imread() and cv2.imwrite() functions.<\/p>\n<h3>Summary<\/h3>\n<p>In the captivating world of computer vision and image processing, the ability to store images for future use is essential. With OpenCV&#8217;s remarkable `cv2.imwrite()` function, preserving your visual treasures has never been easier.<\/p>\n<p>This article serves as your guide, walking you through the process of writing and storing images using OpenCV. From importing the necessary library to specifying output paths and filenames, you&#8217;ll learn the art of image preservation with a few lines of code. Unleash your creativity, secure your hard work, and unlock the power of preservation with OpenCV&#8217;s image-storing capabilities. Let&#8217;s embark on this exciting journey together!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hey there! If you&#8217;re fascinated by the incredible world of computer vision and image processing, then working with images in OpenCV is going to be right up your alley. Images are the heart and&#46;&#46;&#46;<\/p>\n","protected":false},"author":86671,"featured_media":131880,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27755],"tags":[30002,9267,29991,30001],"class_list":["post-117654","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-opencv-tutorials","tag-image-processing-in-opencv","tag-opencv","tag-opencv-tutorials","tag-working-with-images-in-opencv"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Working with Images in OpenCV - DataFlair<\/title>\n<meta name=\"description\" content=\"This article serves as your guide, walking you through the process of writing and storing images using OpenCV.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/working-with-images-in-opencv\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Working with Images in OpenCV - DataFlair\" \/>\n<meta property=\"og:description\" content=\"This article serves as your guide, walking you through the process of writing and storing images using OpenCV.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/working-with-images-in-opencv\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2024-02-29T12:30:30+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-02-29T12:44:17+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/11\/working-with-images-in-opencv.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"TechVidvan Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"TechVidvan Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Working with Images in OpenCV - DataFlair","description":"This article serves as your guide, walking you through the process of writing and storing images using OpenCV.","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:\/\/data-flair.training\/blogs\/working-with-images-in-opencv\/","og_locale":"en_US","og_type":"article","og_title":"Working with Images in OpenCV - DataFlair","og_description":"This article serves as your guide, walking you through the process of writing and storing images using OpenCV.","og_url":"https:\/\/data-flair.training\/blogs\/working-with-images-in-opencv\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2024-02-29T12:30:30+00:00","article_modified_time":"2024-02-29T12:44:17+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/11\/working-with-images-in-opencv.webp","type":"image\/webp"}],"author":"TechVidvan Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"TechVidvan Team","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/working-with-images-in-opencv\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/working-with-images-in-opencv\/"},"author":{"name":"TechVidvan Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/0e594f928e31fc96628ac40f6ae74f49"},"headline":"Working with Images in OpenCV","datePublished":"2024-02-29T12:30:30+00:00","dateModified":"2024-02-29T12:44:17+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/working-with-images-in-opencv\/"},"wordCount":1682,"commentCount":0,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/working-with-images-in-opencv\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/11\/working-with-images-in-opencv.webp","keywords":["image processing in opencv","opencv","opencv tutorials","working with images in opencv"],"articleSection":["OpenCV Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/working-with-images-in-opencv\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/working-with-images-in-opencv\/","url":"https:\/\/data-flair.training\/blogs\/working-with-images-in-opencv\/","name":"Working with Images in OpenCV - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/working-with-images-in-opencv\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/working-with-images-in-opencv\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/11\/working-with-images-in-opencv.webp","datePublished":"2024-02-29T12:30:30+00:00","dateModified":"2024-02-29T12:44:17+00:00","description":"This article serves as your guide, walking you through the process of writing and storing images using OpenCV.","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/working-with-images-in-opencv\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/working-with-images-in-opencv\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/working-with-images-in-opencv\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/11\/working-with-images-in-opencv.webp","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/11\/working-with-images-in-opencv.webp","width":1200,"height":628,"caption":"working with images in opencv"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/working-with-images-in-opencv\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"OpenCV Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/opencv-tutorials\/"},{"@type":"ListItem","position":3,"name":"Working with Images in OpenCV"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/0e594f928e31fc96628ac40f6ae74f49","name":"TechVidvan Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/c89190da3d4010c71ba476b618ab10fdc2335c82cdfa0ad5002d98d0f2473444?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/c89190da3d4010c71ba476b618ab10fdc2335c82cdfa0ad5002d98d0f2473444?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c89190da3d4010c71ba476b618ab10fdc2335c82cdfa0ad5002d98d0f2473444?s=96&d=mm&r=g","caption":"TechVidvan Team"},"description":"TechVidvan Team provides high-quality content &amp; courses on AI, ML, Data Science, Data Engineering, Data Analytics, programming, Python, DSA, Android, Flutter, full stack web dev, MERN, and many latest technology.","url":"https:\/\/data-flair.training\/blogs\/author\/test001\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/117654","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/86671"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=117654"}],"version-history":[{"count":4,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/117654\/revisions"}],"predecessor-version":[{"id":131879,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/117654\/revisions\/131879"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/131880"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=117654"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=117654"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=117654"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}