国外做螺栓比较好的网站,唐山做网站建设公司,广州市建设注册中心网站,关键词排名目录灰度级分层灰度级分层 二值图像 将感兴趣范围内的所有灰显示为一个值#xff08;白色#xff09;#xff0c;而将其它灰度值显示为另一个值#xff08;黑色#xff09; 其他灰度级不变 使期望的灰度范围变量#xff08;或变暗#xff09;#xff0c;但保持图像中…
目录灰度级分层灰度级分层 二值图像 将感兴趣范围内的所有灰显示为一个值白色而将其它灰度值显示为另一个值黑色 其他灰度级不变 使期望的灰度范围变量或变暗但保持图像中的其它灰度级不变
x np.arange(0, 256)
y_1 np.where(x, x 100, 0)
y_1 np.where(y_1, x 200, 0) * 150a 70
b 150
y_2 np.zeros_like(x)
for i in range(len(x)):if a x[i] b:y_2[i] 220else:y_2[i] x[i]plt.figure(figsize(10, 5))
plt.subplot(121), plt.plot(x, y_1), plt.ylim([-1, 255]), plt.xlim([0, 255])
plt.subplot(122), plt.plot(x, y_2), plt.ylim([1, 255]), plt.xlim([0, 255])
plt.show()# 灰度分层
img cv2.imread(DIP_Figures/DIP3E_Original_Images_CH03/Fig0312(a)(kidney).tif)a 155# binary image
img_transform img.copy()
img_transform[img_transform a] 0
img_transform[img_transform a] 255# grayscale image
img_transform_2 img.copy()
img_transform_2[img_transform_2 a] 0.plt.figure(figsize(18, 15))
plt.subplot(1, 3, 1), plt.imshow(img, cmapgray), plt.title(Original)
plt.subplot(1, 3, 2), plt.imshow(img_transform, cmapgray), plt.title(fBinary Image)
plt.subplot(1, 3, 3), plt.imshow(img_transform_2, cmapgray), plt.title(fGrayscale Image)
plt.tight_layout()
plt.show()