import cv2 import numpy as np import matplotlib.pyplot as plt image_path = './Lenna.jpg' image = cv2.imread(image_path) num_row, num_col, num_ch = image.shape # image channels are in BGR B = image[:, :, 0] G = image[:, :, 1] R = image[:, :, 2] # Display the point cloud of the pixels in the coordinate system with RGB as the axis # Construct X # CODE HERE # Decomment the following lines # fig = plt.figure('point cloud of the pixels in the RGB coordinate system', figsize=(5.5, 4.5)) # ax = fig.add_subplot(111, projection='3d') # ax.plot3D(X[0, :], X[1, :], X[2, :], '.') # ax.set_xlabel('R') # ax.set_ylabel('G') # ax.set_zlabel('B') # ax.axis('equal') # plt.show() # Decentralization # CODE HERE # Diagonalization # CODE HERE # Sort the eigen values with the eigen vectors # CODE HERE # Construct the projection to the new basis with the eigen vectors and perform the projection # CODE HERE # Display the color image with the 3 principle conponents in 2 lines and 2 columns # Decommen
时间: 2024-01-18 19:05:16 浏览: 208
t the following lines
```
# fig, axs = plt.subplots(nrows=2, ncols=2, figsize=(8, 8))
# for i, ax in enumerate(axs.flat):
# ax.imshow(X_reconstructed[:, :, i])
# ax.set_title('PC ' + str(i+1))
# ax.axis('off')
# plt.show()
```
阅读全文