Mahotas – 过滤区域
在本文中,我们将了解如何在 mahotas 中过滤区域。为此,我们将使用来自核分割基准的荧光显微镜图像。我们可以在下面给出的命令的帮助下获取图像 -
mhotas.demos.nuclear_image()
下面是nuclear_image
为了过滤这个图像,我们将获取图像对象 numpy.ndarray 并在索引的帮助下过滤它,下面是执行此操作的命令
nuclear = nuclear[:, :, 0]
示例 1:
# importing required libraries
import mahotas as mh
import mahotas.demos
import numpy as np
from pylab import imshow, show
# getting nuclear image
nuclear = mh.demos.nuclear_image()
print("Original Image i.e without filter")
# show the original image
imshow(nuclear)
show()
# filtering the image
nuclear = nuclear[:, :, 0]
print("Image with filter")
# showing the image
imshow(nuclear)
show()
输出 :
示例 2:
# importing required libraries
import mahotas as mh
import mahotas.demos
import numpy as np
from pylab import imshow, show
# getting nuclear image
nuclear = mh.demos.nuclear_image()
print("Original Image i.e without filter")
# show the original image
imshow(nuclear)
show()
# filtering the image
nuclear = nuclear[500:, 500:, :]
print("Image with filter")
# showing the image
imshow(nuclear)
show()
输出 :