Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一张我使用打开的图像,我LoadImageM使用 put 获取像素数据Get2D我似乎找不到任何内置函数来更改像素值。我尝试使用从Rectangleto的多种东西,CV_RGB但没有成功的结果。
LoadImageM
Get2D
Rectangle
CV_RGB
考虑查看新版本的 opencv 库。
你导入它
import cv2
它直接返回numpy数组。
例如,如果你这样做
image_array = cv2.imread('image.png')
那么您可以通过简单的操作来访问和更改像素值image_array:
image_array
image_array[0,0] = 100
将左上角像素的值设置为 100。
根据您的安装,您可能已经拥有cv2绑定,因此请检查是否import cv2有效。
cv2
否则只需安装opencv,numpy你就可以开始了。
opencv
numpy