简体   繁体   English

为图像形态学创建结构元素 Python

[英]Create Structuring Element for Image Morphology Python

I am working with morphological operations.I have a Matlab script which generate the Structuring Element using the function strel('form', w) where the form of the SE can be a line , disk , diamond , square , or other form (I need at least the function to be able to generate this 4 forms), and w is the size of the matrix (w*w) generated for the SE.我正在处理形态学操作。我有一个 Matlab 脚本,它使用 function strel strel('form', w)生成结构元素,其中 SE 的形式可以是linediskdiamondsquare或其他形式(I至少需要 function 才能生成这 4 种形式), w是为 SE 生成的矩阵的大小(w*w)。 I want to know if there is a function in Python similar to Matlab "strel()" that automatically generates the Structuring Element.我想知道Python中是否有类似于自动生成结构元素的Matlab“strel()”的function。 I´ve search for this kind of function, but none of them seems to be able to generate all this 4 different Structuring Element forms.我已经搜索过这种 function,但似乎没有一个能够生成所有这 4 种不同的结构元素 forms。

Scikit-image has functions to generate square, rectangle, disk, diamond, octagon and star shaped structuring elements. Scikit-image具有生成正方形、矩形、圆盘、菱形、八边形和星形结构元素的功能。

They are separate functions, not a single function, but I can't imagine that being a problem.它们是独立的功能,而不是单个 function,但我无法想象这是一个问题。

Call them as skimage.morphology.<shape>() .称它们为skimage.morphology.<shape>() See this documentation page for demos.有关演示,请参阅此文档页面

Horizontal and vertical lines are rectangle shapes, of course.当然,水平线和垂直线是矩形。 Lines at arbitrary angles can be generated by drawing a line in an all-zeros array with skimage.draw.line .可以通过使用skimage.draw.line在全零数组中绘制一条线来生成任意角度的线。

Unfortunately the built-in OpenCV functions appear to provide only rectangles, ellipses, and crosses.不幸的是,内置的 OpenCV 函数似乎只提供矩形、椭圆和十字。 So you'll have to write your own function for that.因此,您必须为此编写自己的 function。

Alternatively, you could try to get MATLAB and python to interact with each other, and call MATLAB from python.或者,您可以尝试让 MATLAB 和 python 相互交互,并从 Z23EEEB4347BDD7556BFC6B7EE9DBDZA 调用 MATLAB。 Refer to the various documentation pages on how to do this:请参阅有关如何执行此操作的各种文档页面:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM