#!/usr/bin/env python # coding: utf-8 # In[1]: import cv2 as cv import numpy as np # In[2]: img = cv.imread('reflections.jpg') # In[3]: type(img) # In[15]: img.shape # In[5]: img.size # In[6]: 320*900*3 # In[7]: img.dtype # In[8]: img[100,100] # In[9]: img[100,100,0] # In[10]: cv.imshow('image', img) cv.waitKey(0) cv.destroyAllWindows() # In[11]: for r in range(100): for c in range(100): img[r,c] = np.array([5,50,180]) # In[12]: cv.imshow('altered image', img) cv.waitKey(0) cv.destroyAllWindows() # In[13]: img[100:200,100:200] = np.array([5,50,180]) # In[14]: cv.imshow('altered image', img) cv.waitKey(0) cv.destroyAllWindows() # In[16]: img.shape[0] # In[17]: img.shape[1] # In[18]: img.shape[2] # In[19]: img[200:300,200:300,2] = 128 # In[20]: cv.imshow('altered image', img) cv.waitKey(0) cv.destroyAllWindows() # In[21]: cv.imwrite('alteredreflections.jpg', img) # In[22]: squarechunk = img[200:300, 600:700] # In[23]: cv.imshow('altered image', squarechunk) cv.waitKey(0) cv.destroyAllWindows() # In[ ]: