plt.figure() plt.imshow(src,vmin=0,vmax=255) plt.axis("off") plt.figure() plt.imshow(dst,vmin=0,vmax=255) plt.axis("off") plt.show()
时间: 2024-04-25 20:24:49 浏览: 196
这段代码是将两个图像在两个不同的图形窗口中显示出来,并且关闭了坐标轴的显示。首先使用plt.figure()创建第一个图形窗口,然后使用plt.imshow()显示第一个图像src,并通过vmin和vmax参数设置图像的颜色范围。接着使用plt.axis("off")关闭了坐标轴的显示。然后再创建一个新的图形窗口,显示第二个图像dst,同样也关闭了坐标轴的显示。最后使用plt.show()将两个图像窗口显示出来。
相关问题
fig = plt.figure(figsize=(10, 10), dpi=300, facecolor="white") plt.rcParams['font.family'] = 'Times New Roman' plt.rcParams['font.size'] = 28 plt.rcParams['font.weight'] = 'bold' norm = matplotlib.colors.Normalize(vmin=-0.4, vmax=0.4) # SLA norm locator = matplotlib.ticker.MultipleLocator(0.2) h1 = plt.imshow(sla, cmap='seismic', interpolation='bicubic', norm=norm) plt.margins(0, 0) # plt.axis('off') # 画图无边框,解开此行,以下注释,pad_inches改为0.0 fc = plt.colorbar(h1, ticks=locator, fraction=0.046, pad=0.04) ax1 = fc.ax ax1.set_title('m', fontsize=28, font='Times New Roman') x = [0, 16, 32, 48, 63.5] # ? y = [0, 16, 32, 48, 63.5]
您好!根据您提供的代码,这段代码是用于创建一个大小为10x10英,分辨率为300的图形,并设置背景颜色为白色。接下来的几行代码用于设置字体样式和大小。然后,使用se颜色映射和双三次插值绘制一个名为"h1"的图像。接着,设置图像的边距和添加一个colorbar,并设置colorbar的标签和刻度。最后,定义了一个包含x和y坐标的列表。
不过,您在注释中提到了一个问号,我不是很明白您在问什么问题。请问您需要对x和y坐标列表进行什么操作吗?
此代码问题import cv2 import numpy as np import matplotlib.pyplot as plt img = cv2.imread(r'E:\\postgraduate\\three\\DIP3E_Original_Images_CH03\\3.14.tif',0) def bit_plane_slicing(src,z,n): height, width= src.shape dst = np.zeros((height, width), np.uint8) for i in range(0, height): for j in range(0, width): pixel = format(src[i,j], '08b') if pixel[8-z] == '0': dst[i, j] = 0 else: dst[i, j] = 255 dst = np.bitwise_and(dst, n) return dst image1 = bit_plane_slicing(img,8,7) image2 = bit_plane_slicing(image1,8,6) image3 = bit_plane_slicing(image2,8,5) plt.figure(figsize=(100,100)) plt.subplot(131) plt.imshow(image1,cmap='gray') plt.axis('off') plt.subplot(132) plt.imshow(image2,cmap='gray') plt.axis('off') plt.subplot(133) plt.imshow(image3,cmap='gray') plt.axis('off') plt.show()
这段代码的问题是:在 `bit_plane_slicing` 函数中,`dst = np.bitwise_and(dst, n)` 的位置不正确,应该放在第二个 `for` 循环的外面。另外,建议在 `imshow` 函数中添加 `vmin=0, vmax=255` 参数。
修改后的代码如下:
```
import cv2
import numpy as np
import matplotlib.pyplot as plt
img = cv2.imread(r'E:\\postgraduate\\three\\DIP3E_Original_Images_CH03\\3.14.tif',0)
def bit_plane_slicing(src,z,n):
height, width = src.shape
dst = np.zeros((height, width), np.uint8)
for i in range(0, height):
for j in range(0, width):
pixel = format(src[i,j], '08b')
if pixel[8-z] == '0':
dst[i, j] = 0
else:
dst[i, j] = 255
dst = np.bitwise_and(dst, n)
return dst
image1 = bit_plane_slicing(img,8,7)
image2 = bit_plane_slicing(image1,8,6)
image3 = bit_plane_slicing(image2,8,5)
plt.figure(figsize=(100,100))
plt.subplot(131)
plt.imshow(image1,cmap='gray', vmin=0, vmax=255)
plt.axis('off')
plt.subplot(132)
plt.imshow(image2,cmap='gray', vmin=0, vmax=255)
plt.axis('off')
plt.subplot(133)
plt.imshow(image3,cmap='gray', vmin=0, vmax=255)
plt.axis('off')
plt.show()
```
这样修改后,就可以正确地显示三个子图了。
阅读全文
相关推荐
















