Block 111: Images as Arrays
Understand how images are represented as NumPy arrays.
Concepts
- pip install opencv-python
- cv2.imread(), cv2.imshow(), cv2.waitKey()
- Image shape: (height, width, channels)
- BGR vs RGB color ordering in OpenCV
- Displaying inline in Jupyter with plt.imshow(cv2.cvtColor)
Code Examples
See exercise below.
Exercise
Load an image, print shape, dtype. Display it in Jupyter correctly (BGR→RGB). Access pixel value at position (100,100). Change it to red.
Homework
Why does OpenCV use BGR instead of RGB? What common mistake does this cause?