鹅妹子的skimage.measure.regionprops

参考:https://scikit-image.org/docs/dev/api/skimage.measure.html#skimage.measure.regionprops

skimage的强大无需多言,但是木有想到厉害成这个亚子!简直是宝藏函数!
今天简单记录skimage.measure使用中遇到的惊喜。

一、汇总

函数 功能
skimage.measure.find_contours(array, level) Find iso-valued contours in a 2D array for a given level value.
skimage.measure.regionprops(label_image[, …]) Measure properties of labeled image regions.
skimage.measure.regionprops_table(label_image) Find image properties and convert them into a dictionary
skimage.measure.perimeter(image[, neighbourhood]) Calculate total perimeter of all objects in binary image.
skimage.measure.approximate_polygon(coords, …) Approximate a polygonal chain with the specified tolerance.
skimage.measure.subdivide_polygon(coords[, …]) Subdivision of polygonal curves using B-Splines.
skimage.measure.ransac(data, model_class, …) Fit a model to data with the RANSAC (random sample consensus) algorithm.
skimage.measure.block_reduce(image, block_size) Down-sample image by applying function to local blocks.
skimage.measure.moments(image[, order]) Calculate all raw image moments up to a certain order.
skimage.measure.moments_central(image[, …]) Calculate all central image moments up to a certain order.
skimage.measure.moments_coords(coords[, order]) Calculate all raw image moments up to a certain order.
skimage.measure.moments_coords_central(coords) Calculate all central image moments up to a certain order.
skimage.measure.moments_normalized(mu[, order]) Calculate all normalized central image moments up to a certain order.
skimage.measure.moments_hu(nu) Calculate Hu’s set of image moments (2D-only).
skimage.measure.marching_cubes_lewiner(volume) Lewiner marching cubes algorithm to find surfaces in 3d volumetric data.
skimage.measure.marching_cubes_classic(volume) Classic marching cubes algorithm to find surfaces in 3d volumetric data.
skimage.measure.mesh_surface_area(verts, faces) Compute surface area, given vertices & triangular faces
skimage.measure.profile_line(image, src, dst) Return the intensity profile of an image measured along a scan line.
skimage.measure.label(input[, neighbors, …]) Label connected regions of an integer array.
skimage.measure.points_in_poly(points, verts) Test whether points lie inside a polygon.
skimage.measure.grid_points_in_poly(shape, verts) Test whether points on a specified grid are inside a polygon.
skimage.measure.compare_ssim(X, Y[, …]) Compute the mean structural similarity index between two images.
skimage.measure.compare_mse(im1, im2) Compute the mean-squared error between two images.
skimage.measure.compare_nrmse(im_true, im_test) Compute the normalized root mean-squared error (NRMSE) between two images.
skimage.measure.compare_psnr(im_true, im_test) Compute the peak signal to noise ratio (PSNR) for an image.
skimage.measure.shannon_entropy(image[, base]) Calculate the Shannon entropy of an image.
skimage.measure.LineModelND() Total least squares estimator for N-dimensional lines.
skimage.measure.CircleModel() Total least squares estimator for 2D circles.
skimage.measure.EllipseModel() Total least squares estimator for 2D ellipses.

下面捡两个自己用的比较多的函数记录一下,后续用到其他会继续更新。

二、skimage.measure.find_contours

对于给定的水平值,在二维数组中找到等值的轮廓,可以用来检测二值图像的边缘轮廓。

skimage.measure.find_contours(array, level, fully_connected='low', positive_orientation='low')

参数
数组:2D输入数据的二维图像,用于查找轮廓。
level:其中查找数组中的轮廓的值。
fully_connected:str,{‘low’,‘high’}指示给定级别值以下的数组元素是否被视为完全连接(并且因此值之上的元素将仅面向连接),反之亦然。(详情请参见下面的注释。)
positive_orientation:‘low’或’high’表示输出轮廓是否会在低或高值元素的岛周围产生正向多边形。如果’低’,那么等高线将围绕低于等值的元素逆时针旋转。或者,这意味着低值元素总是在轮廓的左侧。

返回
轮廓:(n,2)列表的列表每个轮廓都是形状(n,2)的状态,由沿着轮廓的n(行,列)坐标组成。 |

三、skimage.measure.regionprops

skimage.measure.regionprops(label_image, intensity_image=None, cache=True)

测量标记的图像区域的属性。

参数
label_image:(N,M)ndarray标记的输入图像。值为0的标签将被忽略。intensity_image:(N,M)ndarray,可选强度(即输入)与标记图像大小相同的图像。缺省值是None。
cache:bool,可选确定是否缓存计算的属性。缓存属性的计算速度要快得多,而内存消耗增加。

返回
属性:RegionProperties列表每个项目描述一个带标签的区域,并且可以使用下面列出的属性进行访问。

以下是可以访问的属性

area : int
区域的像素数
bbox : tuple
Bounding box (min_row, min_col, max_row, max_col).
Pixels belonging to the bounding box are in the half-open interval
[min_row; max_row) and [min_col; max_col).
bbox_area : int
Number of pixels of bounding box.
centroid : array
质心坐标 tuple (row, col).
convex_area : int
凸包图像的像素数
convex_image : (H, J) ndarray
Binary convex hull image which has the same size as bounding box.
coords : (N, 2) ndarray
Coordinate list (row, col) of the region.
eccentricity : float
Eccentricity of the ellipse that has the same second-moments as the
region. The eccentricity is the ratio of the focal distance
(distance between focal points) over the major axis length.
The value is in the interval [0, 1).
When it is 0, the ellipse becomes a circle.
equivalent_diameter : float
The diameter of a circle with the same area as the region.
euler_number : int
Euler characteristic of region. Computed as number of objects (= 1)
subtracted by number of holes (8-connectivity).
extent : float
Ratio of pixels in the region to pixels in the total bounding box.
Computed as area / (rows * cols)
filled_area : int
Number of pixels of filled region.
filled_image : (H, J) ndarray
Binary region image with filled holes which has the same size as
bounding box.
image : (H, J) ndarray
Sliced binary region image which has the same size as bounding box.
inertia_tensor : (2, 2) ndarray
Inertia tensor of the region for the rotation around its mass.
inertia_tensor_eigvals : tuple
The two eigen values of the inertia tensor in decreasing order.
intensity_image : ndarray
Image inside region bounding box.
label : int
The label in the labeled input image.
local_centroid : array
Centroid coordinate tuple (row, col), relative to region bounding
box.
major_axis_length : float
The length of the major axis of the ellipse that has the same
normalized second central moments as the region.
max_intensity : float
Value with the greatest intensity in the region.
mean_intensity : float
Value with the mean intensity in the region.
min_intensity : float
Value with the least intensity in the region.
minor_axis_length : float
The length of the minor axis of the ellipse that has the same
normalized second central moments as the region.
moments : (3, 3) ndarray
Spatial moments up to 3rd order::

        m_ji = sum{ array(x, y) * x^j * y^i }

    where the sum is over the `x`, `y` coordinates of the region.
**moments_central** : (3, 3) ndarray
    Central moments (translation invariant) up to 3rd order::

        mu_ji = sum{ array(x, y) * (x - x_c)^j * (y - y_c)^i }

    where the sum is over the `x`, `y` coordinates of the region,
    and `x_c` and `y_c` are the coordinates of the region's centroid.
**moments_hu** : tuple
    Hu moments (translation, scale and rotation invariant).
**moments_normalized** : (3, 3) ndarray
    Normalized moments (translation and scale invariant) up to 3rd order::

        nu_ji = mu_ji / m_00^[(i+j)/2 + 1]

    where `m_00` is the zeroth spatial moment.
**orientation** : float
    与该区域具有相同二阶矩的椭圆的x轴与主轴之间的夹角。
    Angle between the X-axis and the major axis of the ellipse that has
    the same second-moments as the region. Ranging from `-pi/2` to
    `pi/2` in counter-clockwise direction.
**perimeter** : float
    Perimeter of object which approximates the contour as a line
    through the centers of border pixels using a 4-connectivity.
**solidity** : float
    Ratio of pixels in the region to pixels of the convex hull image.
**weighted_centroid** : array
    Centroid coordinate tuple ``(row, col)`` weighted with intensity
    image.
**weighted_local_centroid** : array
    Centroid coordinate tuple ``(row, col)``, relative to region bounding
    box, weighted with intensity image.
**weighted_moments** : (3, 3) ndarray
    Spatial moments of intensity image up to 3rd order::

        wm_ji = sum{ array(x, y) * x^j * y^i }

    where the sum is over the `x`, `y` coordinates of the region.
**weighted_moments_central** : (3, 3) ndarray
    Central moments (translation invariant) of intensity image up to
    3rd order::

        wmu_ji = sum{ array(x, y) * (x - x_c)^j * (y - y_c)^i }

    where the sum is over the `x`, `y` coordinates of the region,
    and `x_c` and `y_c` are the coordinates of the region's weighted
    centroid.
**weighted_moments_hu** : tuple
    Hu moments (translation, scale and rotation invariant) of intensity
    image.
**weighted_moments_normalized** : (3, 3) ndarray
    Normalized moments (translation and scale invariant) of intensity
    image up to 3rd order::

        wnu_ji = wmu_ji / wm_00^[(i+j)/2 + 1]

    where ``wm_00`` is the zeroth spatial moment (intensity-weighted area).

你可能感兴趣的:(python)