import cv2 import matplotlib.pyplot as plt img=cv2.imread('D:/computer view/R-C.png')patch_img=img[20:150,-180:-50] cv2.imshow(patch_img)
时间: 2024-04-29 18:23:29 浏览: 119
As an AI language model, I cannot display images directly. However, I can suggest some modifications to your code to display the image using matplotlib.
Here's an updated version of your code:
```
import cv2
import matplotlib.pyplot as plt
# Read image
img = cv2.imread('D:/computer view/R-C.png')
# Extract patch
patch_img = img[20:150, -180:-50]
# Display image using matplotlib
plt.imshow(cv2.cvtColor(patch_img, cv2.COLOR_BGR2RGB))
plt.show()
```
This code will display the extracted patch using the `imshow` function of matplotlib. Note that we also need to convert the color space from BGR to RGB using the `cv2.cvtColor` function, as matplotlib expects RGB images.
阅读全文