主要内容

雪花的颗粒法

This example shows how to calculate the size distribution of snowflakes in an image by using granulometry. Granulometry determines the size distribution of objects in an image without explicitly segmenting (detecting) each object first.

阅读图像

Read in thesnowflakes.pngimage, which is a photograph of snowflakes.

I = imread("snowflakes.png"); imshow(I)

图包含一个轴对象。The axes object contains an object of type image.

Enhance Contrast

您的第一步是最大化图像中的强度对比度。您可以使用Adapthisteqfunction, which performs contrast-limited adaptive histogram equalization. Rescale the image intensity using theimadjustfunction so that it fills the data type's entire dynamic range.

clahei = Adapthisteq(i,“ numtiles”,[10 10]); claheI = imadjust(claheI); imshow(claheI)

图包含一个轴对象。The axes object contains an object of type image.

在增强图像中确定图像表面下的体积

Granulometry is analogous to sifting stones through screens of increasing size and collecting what remains after each pass. Granulometry applies a series of morphological openings of increasing size, and the sum of image pixel values is computed after each opening. For grayscale images, this sum corresponds to the volume under the surface whose height is determined by the pixel intensity values. The volume is reduced after each opening as larger objects are eliminated by increasingly large structuring elements.

可选地,您可以绘制雪花图像的强度表面以概念化表面体积。调整垂直纵横比以使整个表面可见。表面峰对应于原始2-D图像中的明亮区域。

figure surf(claheI, EdgeColor=“没有任何”) colormap("gray") 标题(“雪花像素强度表面”)达spect([1 1 15]);

图包含一个轴对象。The axes object with title Snowflakes Pixel Intensity Surface contains an object of type surface.

选择一个计数器限制,以便在增加结构元素的大小时,强度表面体积为零。为了显示目的,将第一个条目留在表面积阵列中。

radius_range = 0:22; intensity_volume = zeros(size(radius_range));forcounter = radius_range remain = imopen(claheI, strel("disk", counter)); intensity_volume(counter + 1) = sum(remain(:));end图图(intense_volume,"m - *") gridtitle("Sum of Pixel Values in Opened Image Versus Radius")xlabel("Radius of Opening Structuring Element (pixels)")ylabel("Sum of Pixel Values in Opened Image (intensity)")

图包含一个轴对象。带有标题的轴对象打开的图像中的像素值与半径为类型行的对象。

Estimate Derivative of Distribution

A significant drop in intensity surface volume between two consecutive openings indicates that the image contains objects of comparable size to the smaller opening. This is equivalent to the derivative of the intensity surface volume with respect to radius, which contains the size distribution of the snowflakes in the image. Estimate the derivative by using thedifffunction.

intense_volume_prime = diff(intense_volume);图图(intense_volume_prime,"m - *") gridtitle("Granulometry (Size Distribution) of Snowflakes")ax = gca;ax.xtick = [0 2 4 6 8 10 12 14 16 18 20 22];Xlabel("Radius of Snowflakes (pixels)")ylabel("Derivative of Sum of Pixel Values (intensity/pixel)")

图包含一个轴对象。The axes object with title Granulometry (Size Distribution) of Snowflakes contains an object of type line.

Emphasize Snowflakes Having a Particular Radius

Notice the minima and the radii where they occur in the graph. The minima tell you that snowflakes in the image have those radii. The more negative the minimum point, the higher the snowflakes' cumulative intensity at that radius. For example, the most negative minimum point occurs at the 5 pixel radius mark. You can emphasize the snowflakes having a 5 pixel radius with the following steps.

open5 = imopen(claheI,strel("disk",5));Open6 = iMopen(Clahei,Strel(Strel)("disk",6)); rad5 = open5 - open6; imshow(rad5,[])

图包含一个轴对象。The axes object contains an object of type image.

See Also

|||