sckimage.draw.ELIPLIZE中的draw.ELLPOID和ELIPLIZE_统计信息如何与栅格间距配合使用?

2024-06-28 18:55:59 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在调查https://scikit-image.org/docs/dev/api/skimage.draw.html#skimage.draw.ellipse 和{}我引用

Calculates analytical surface area and volume for ellipsoid with semimajor axes aligned with grid dimensions of specified spacing.

但是查看他们的代码,并没有关于引入间距的信息。也许我错过了什么

我的问题是: -在知道半径a, b, c和栅格间距的情况下,如何计算椭球体的体积?我正在使用具有不同间距的DICOM CT卷

def ellipsoid_stats(a, b, c):
    """
    Calculates analytical surface area and volume for ellipsoid with
    semimajor axes aligned with grid dimensions of specified `spacing`.
    Parameters
    ----------
    a : float
        Length of semimajor axis aligned with x-axis.
    b : float
        Length of semimajor axis aligned with y-axis.
    c : float
        Length of semimajor axis aligned with z-axis.
    Returns
    -------
    vol : float
        Calculated volume of ellipsoid.
    surf : float
        Calculated surface area of ellipsoid.
    """
    if (a <= 0) or (b <= 0) or (c <= 0):
        raise ValueError('Parameters a, b, and c must all be > 0')

    # Calculate volume & surface area
    # Surface calculation requires a >= b >= c and a != c.
    abc = [a, b, c]
    abc.sort(reverse=True)
    a = abc[0]
    b = abc[1]
    c = abc[2]

    # Volume
    vol = 4 / 3. * np.pi * a * b * c

    # Analytical ellipsoid surface area
    phi = np.arcsin((1. - (c ** 2 / (a ** 2.))) ** 0.5)
    d = float((a ** 2 - c ** 2) ** 0.5)
    m = (a ** 2 * (b ** 2 - c ** 2) /
         float(b ** 2 * (a ** 2 - c ** 2)))
    F = ellip_F(phi, m)
    E = ellip_E(phi, m)

    surf = 2 * np.pi * (c ** 2 +
                        b * c ** 2 / d * F +
                        b * d * E)

    return vol, surf

Tags: andofwithareafloatsurfacelengthabc
1条回答
网友
1楼 · 发布于 2024-06-28 18:55:59

scikit函数提供以像素为单位的结果-因此,表面积以像素为单位(如果您有2D图像),体积以像素^2为单位

对于图像,若要将其转换为mm和mm^2,则需要查找PixelSpacing标记以获得每个像素的大小(单位为mm),并使用该值转换单位

如果您使用的是pydicom,则可以使用.pixelspacking[0]。PixelSpacing是一个2元素列表,但我知道的所有CT都具有相同的行/列像素间距,因此仅使用列表PixelSpacing[0]中的第一个元素就足够了

相关问题 更多 >