Hello Guys,
In this article, I will discuss about how to write images in OpenCV.
For writing images, Opencv has the function named “imwrite“. This function takes two arguments.
1. Image name with extension
2. Image object
This function returns a boolean. If it writes the file successfully then it returns True, otherwise False.
# Import cv2 moduleimport cv2 as cv#reading an using imread function without passing any parameter# By default it loads the image in color formatcolored_image= cv.imread("nature.jpg") #imwrite returns True if it writes the file successfully otherwise #returns Falseresult = cv.imwrite("nature.png",colored_image)if result: png_img = cv.imread("nature.png") cv.imshow("Png Image",png_img) cv.waitKey(0) cv.destroyAllWindows()else: print("Error in writing file")
Also don’t forget to check my previous OpenCV tutorials.
http://techievaibhav.in/category/programming/opencv/
Comments
Post a Comment