I want to know how to make a empty grayscale image in OpenCV.
First, I know how to make a empty 'color image' like this.
import cv2
import numpy as np
blank_image = np.zeros((height,width,3), dtype = np.uint8)
Then, how can I make a empty 'grayscale' image with specific height and width?
I want to know how to make a empty grayscale image in OpenCV.
First, I know how to make a empty 'color image' like this.
import cv2
import numpy as np
blank_image = np.zeros((height,width,3), dtype = np.uint8)
Then, how can I make a empty 'grayscale' image with specific height and width?
I want to know how to make a empty grayscale image in OpenCV.
First, I know how to make a empty 'color image' like this.
import cv2
import numpy as np
blank_image = np.zeros((height,width,3), dtype = np.uint8)
Then, how can I make a empty 'grayscale' image with specific height and width?
Can i ask then, how do you save it as a greyscale png file? When i compile i get an error
import cv2'
import numpy as np' height = 121'
width = 121' grey_Value = 16
greyimage = np.full(height, width), grey_Value, np.uint16'
cv2.imwrite('e:\\Cutfill\\test.png',greyimage)'
cv2.imwrite('e:\\Cutfill\\test.png',greyimage) cv2.error: OpenCV(4.5.4) :-1: error: (-5:Bad argument) in function 'imwrite'
Overload resolution failed:
- img is not a numerical tuple
- Expected Ptr<cv::UMat> for argument 'img'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.