-
-
-
-
-
-
-In [1]:
-
-
-
-
-
-pip install opencv-python
-
-
-
-
-
-
-
-
-
-
-
-Requirement already satisfied: opencv-python in c:\users\laksh\anaconda3\lib\site-packages (4.10.0.84) -Requirement already satisfied: numpy>=1.21.2 in c:\users\laksh\anaconda3\lib\site-packages (from opencv-python) (1.26.4) -Note: you may need to restart the kernel to use updated packages. --
-
-
-
-
-
-
-
-In [3]:
-
-
-
-
-
-import cv2
-print(cv2.__version__) # This will display the installed OpenCV version
-
-
-
-
-
-
-
-
-
-
-
-4.10.0 --
-
-
-
-
-
-
-
-
-Reading and Converting Image to array using imread()¶
-
-
-
-
-
-
-
-In [28]:
-
-
-
-
-
-img = cv2.imread(r"C:\Users\laksh\Downloads\mickey_mouse.jpeg") # by default it will give 3d-array
-
-
-
-
-
-
-
-In [30]:
-
-
-
-
-
-img
-
-
-
-
-
-
-
-
-Out[30]:
-
-
-array([[[221, 210, 206], - [255, 255, 251], - [253, 255, 254], - ..., - [252, 255, 251], - [255, 255, 249], - [219, 209, 215]], - - [[219, 212, 209], - [254, 252, 251], - [247, 255, 255], - ..., - [251, 255, 255], - [255, 253, 248], - [215, 208, 211]], - - [[211, 213, 213], - [245, 252, 255], - [239, 254, 255], - ..., - [244, 255, 255], - [252, 255, 253], - [213, 208, 210]], - - ..., - - [[207, 211, 200], - [252, 255, 250], - [248, 255, 255], - ..., - [245, 254, 255], - [247, 254, 251], - [212, 214, 214]], - - [[219, 220, 216], - [243, 246, 244], - [248, 254, 253], - ..., - [251, 255, 255], - [245, 249, 244], - [214, 216, 216]], - - [[238, 239, 237], - [232, 235, 233], - [224, 228, 229], - ..., - [227, 228, 226], - [233, 234, 230], - [244, 246, 246]]], dtype=uint8)-
-
-
-
-
-
-
-In [32]:
-
-
-
-
-
-img.shape
-
-
-
-
-
-
-
-
-Out[32]:
-
-
-(732, 551, 3)-
-
-
-
-
-
-
-In [34]:
-
-
-
-
-
-img.dtype
-
-
-
-
-
-
-
-
-Out[34]:
-
-
-dtype('uint8')
-
-
-
-
-
-
-
-In [36]:
-
-
-
-
-
-img1 = cv2.imread(r"P:\IMG_5723.JPG",flags = 0) # using flags = 0 we can convert it into 2d-array
-
-
-
-
-
-
-
-In [38]:
-
-
-
-
-
-img1.shape
-
-
-
-
-
-
-
-
-Out[38]:
-
-
-(4032, 3024)-
-
-
-
-
-
-
-In [40]:
-
-
-
-
-
-img1
-
-
-
-
-
-
-
-
-Out[40]:
-
-
-array([[183, 183, 182, ..., 186, 186, 186], - [182, 182, 182, ..., 186, 186, 186], - [181, 181, 181, ..., 185, 185, 185], - ..., - [ 54, 57, 59, ..., 104, 96, 92], - [ 56, 60, 63, ..., 109, 104, 99], - [ 53, 58, 64, ..., 114, 109, 102]], dtype=uint8)-
-
-
-
-
-
-
-In [42]:
-
-
-
-
-
-### Displaying the Images
-
-
-
-
-
-
-
-
-In [44]:
-
-
-
-
-
-cv2.imshow("White",img)
-
-cv2.waitKey(0) # 0 and no values means infinite delay to close X button
-
-cv2.destroyAllWindows()
-
-
-
-
-
-
-
-
-
-Saving an Image¶
-
-
-
-
-
-
-
-In [47]:
-
-
-
-
-
-cv2.imwrite(r"H:\innomatics\ML\ML Class\white_Img.jpg",img)
-
-
-
-
-
-
-
-
-Out[47]:
-
-
-True-
-
-
-
-
-
-
-
-In [ ]:
-
-
-
-
-
-
-