numpy 图片填充_使用numpy和scipy填充图像上的空白

本文介绍如何使用numpy和scipy处理含有np.nan值的图像,特别是通过填充算法来填补图像中的空白区域。建议使用scikit-learn的Imputer进行均值填充,而非简单的最近邻值填充,以获得更干净的处理结果。
摘要由CSDN通过智能技术生成

The image (test.tif) is attached.

The np.nan values are the whitest region.

How to fill those whitest region using some gap filling algorithms that uses values from the neighbours?

import scipy.ndimage

data = ndimage.imread('test.tif')

解决方案

I think viena's question is more related to an inpainting problem.

Here are some ideas:

In order to fill the gaps in B/W images you can use some filling algorithm like scipy.ndimage.morphology.binary_fill_holes. But you have a gray level image, so you can't use it.

I suppose that you don't want to use a complex inpainting algorithm. My first suggestion is: Don't try to use Nearest gray value (you don't know the real value of the NaN pixels). Using the NEarest value will generate a dirty algorithm. Instead, I would

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值