image-processing - 如何从 3D 图像中去除小物体?

标签 image-processing scikit-image d3dimage

3D image 你看到了吗?大脑下方散布着一些小物体。我想移除它们以获得一个完整的干净大脑。

在 Numpy 中,3D 图像可以表示为 3D 数组。

下面是一种去除二维图像中小物体的方法。

from skimage import morphology
img_size = img.shape[0] * img.shape[1]
new_img = morphology.remove_small_objects(img, img_size*0.1)

最佳答案

这是我的解决方案:


from skimage import morphology

    def remove_small_objects(img):
        binary = copy.copy(img)
        binary[binary>0] = 1
        labels = morphology.label(binary)
        labels_num = [len(labels[labels==each]) for each in np.unique(labels)]
        rank = np.argsort(np.argsort(labels_num))
        index = list(rank).index(len(rank)-2)
        new_img = copy.copy(img)
        new_img[labels!=index] = 0
        return new_img

关于image-processing - 如何从 3D 图像中去除小物体?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56938207/

相关文章:

python - 处理视频时如何使用 matplotlib 随时间绘制每秒帧数 (fps)?

Python 版本变化

python - ValueError : Image is not numeric, 但 ndarray

c - 基于星/点的图像配准

python - 从多个拆分单个

Python:查找二维图像直方图的外部峰值

wpf - 具有 D3DImage 共享资源的 DirectX11/DirectX10 多重采样 (MSAA)

c++ - DirectX 9 引擎 Z 缓冲区不适用于 D3DImage

iphone - UIImage 调整大小而不损失质量