❌

Normal view

There are new articles available, click to refresh the page.
Yesterday β€” 11 March 2025Main stream

open-cv write image

By: krishna
10 March 2025 at 13:30

Explore the OpenCV imwrite function used to write an image.

Source Code

import cv2

image = cv2.imread("./data/openCV_logo.jpg",cv2.IMREAD_GRAYSCALE)
image = cv2.resize(image,(600,600))
cv2.imwrite("./data/openCV_logo_grayscale.jpg",image)

Image

Function

imwrite()

Explain Code

Import the OpenCV library import cv2.

The imread function reads an image. Since I need a grayscale image, I set the flag value as cv2.IMREAD_GRAYSCALE.

Resize the image using the resize() function.

imwrite

The imwrite function is used to save an image. It takes two arguments:

  1. Image path – Set the image path and name.
  2. Image – The image as a NumPy array.

Additional Link

github code

❌
❌