Skip to content
Advertisement

How to expand / dilate a numpy array?

I’m performing a image analysis and generated seeds in the form of a boolean array :

JavaScript

As I want to do a subsequent analysis on the area surrounding the True value, I want to expand it (by a certain number, say pixels). This would result in the following:

JavaScript

Is there any function or simple way of solving my ‘radial expansion’ problem?

Thanks in advance, BBQuercus

Advertisement

Answer

Solution with scipy.signal.convolve2d:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement