问题描述
基本上,我有一个 JPG 图像,我需要通过使用三个 RGB 通道上的阈值对其进行分割。
这是我的代码:
img = cv2.imread('sample.jpg')
img = np.asarray(img)
img = img[:,:,0:3]
plt.imshow(img)
plt.show()
img_gray = rgb2gray(img)
img_gray = np.around(img_gray)
img_gray = img_gray.astype(int)
img_gray
histogram2,bins2 = np.histogram(img_gray,bins=range(255))
plt.bar(bins2[1:],histogram2)
plt.show()
img_select = np.where((img_gray[:,0]<150) & (img_gray[:,1]>70) & (img_gray[:,2]<90),1,0)
plt.imshow(img_select,cmap = 'gray')
plt.show()
“数组索引过多”
有人可以帮我解决这个问题吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)