Using OpenCV in Python, how can I create a new RGB image? I don’t want to load the image from a file, just create an empty image ready to work with.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The new
cv2interface for Python integrates numpy arrays into the OpenCV framework, which makes operations much simpler as they are represented with simple multidimensional arrays. For example, your question would be answered with:This initialises an RGB-image that is just black. Now, for example, if you wanted to set the left half of the image to blue and the right half to green , you could do so easily:
If you want to save yourself a lot of trouble in future, as well as having to ask questions such as this one, I would strongly recommend using the
cv2interface rather than the oldercvone. I made the change recently and have never looked back. You can read more aboutcv2at the OpenCV Change Logs.