使用 MATLAB 测量微观粒子的 Feret 直径
Measure Feret diameter of microscopic particles using MATLAB
我正在尝试使用 MATLAB 测量微观粒子的 Feret 直径。我附上了下面的代码,在实施 MaxFeretProperties
时遇到问题。请建议我如何执行以获得粒度分布?下面附上代码:
clc
clear all;
img = imread('image.tif');
imshow(img);
img_gray = rgb2gray(img);
imshow(img_gray, [0 150]);
cropped = imcrop(img_gray,[1 1 2040 1418]);%select the top left and bottom right of the rectangle
imshow(cropped);
threshold = 150;
[r,c] = size(cropped);
for i=1:r
for j=1:c
if cropped(i,j)<150
im(i,j)=1;
end
end
end
imshow(im);
bw = imbinarize(im,'adaptive');
bw = imfill(bw,'holes');
cc = bwconncomp(bw);
[L,N] = bwlabel(bw);
%blobs = regionprops(L,'BoundingBox')
stats = regionprops('table', bw, 'Centroid','MajorAxisLength','MinorAxisLength');
ft = regionprops( bw, 'MaxFeretProperties');
这个程序的输出如下:
Error using regionprops>getPropsFromInput (line 1279)
Expected input number 1, PROPERTIES, to match one of these strings:
'Area', 'Centroid', 'BoundingBox', 'SubarrayIdx', 'MajorAxisLength', 'MinorAxisLength', 'Eccentricity',
'Orientation', 'ConvexHull', 'ConvexImage', 'ConvexArea', 'Image', 'FilledImage', 'FilledArea',
'EulerNumber', 'Extrema', 'EquivDiameter', 'Solidity', 'Extent', 'PixelIdxList', 'PixelList',
'Perimeter', 'PerimeterOld', 'PixelValues', 'WeightedCentroid', 'MeanIntensity', 'MinIntensity',
'MaxIntensity'
The input, 'MaxFeretProperties', did not match any of the valid strings.
Error in regionprops>ParseInputs (line 1244)
reqStats = getPropsFromInput(startIdxForProp, ...
Error in regionprops (line 205)
[I,requestedStats,officialStats] = ParseInputs(imageSize, argOffset, varargin{:});
Error in feret (line 25)
ft = regionprops( bw, 'MaxFeretProperties');
我能够获得 MajorAxisLength
和 MinorAxisLength
。
错误消息显示“输入 'MaxFeretProperties' 与任何有效字符串都不匹配。”这非常清楚地表明出了什么问题:您正在请求 regionprops
函数不知道的功能。
请注意,'MaxFeretProperties' 最近作为一项功能引入 regionprops
。您可能拥有此更改之前的 MATLAB 版本。您需要升级您的 MATLAB 版本才能使用此功能。
我正在尝试使用 MATLAB 测量微观粒子的 Feret 直径。我附上了下面的代码,在实施 MaxFeretProperties
时遇到问题。请建议我如何执行以获得粒度分布?下面附上代码:
clc
clear all;
img = imread('image.tif');
imshow(img);
img_gray = rgb2gray(img);
imshow(img_gray, [0 150]);
cropped = imcrop(img_gray,[1 1 2040 1418]);%select the top left and bottom right of the rectangle
imshow(cropped);
threshold = 150;
[r,c] = size(cropped);
for i=1:r
for j=1:c
if cropped(i,j)<150
im(i,j)=1;
end
end
end
imshow(im);
bw = imbinarize(im,'adaptive');
bw = imfill(bw,'holes');
cc = bwconncomp(bw);
[L,N] = bwlabel(bw);
%blobs = regionprops(L,'BoundingBox')
stats = regionprops('table', bw, 'Centroid','MajorAxisLength','MinorAxisLength');
ft = regionprops( bw, 'MaxFeretProperties');
这个程序的输出如下:
Error using regionprops>getPropsFromInput (line 1279)
Expected input number 1, PROPERTIES, to match one of these strings:
'Area', 'Centroid', 'BoundingBox', 'SubarrayIdx', 'MajorAxisLength', 'MinorAxisLength', 'Eccentricity',
'Orientation', 'ConvexHull', 'ConvexImage', 'ConvexArea', 'Image', 'FilledImage', 'FilledArea',
'EulerNumber', 'Extrema', 'EquivDiameter', 'Solidity', 'Extent', 'PixelIdxList', 'PixelList',
'Perimeter', 'PerimeterOld', 'PixelValues', 'WeightedCentroid', 'MeanIntensity', 'MinIntensity',
'MaxIntensity'
The input, 'MaxFeretProperties', did not match any of the valid strings.
Error in regionprops>ParseInputs (line 1244)
reqStats = getPropsFromInput(startIdxForProp, ...
Error in regionprops (line 205)
[I,requestedStats,officialStats] = ParseInputs(imageSize, argOffset, varargin{:});
Error in feret (line 25)
ft = regionprops( bw, 'MaxFeretProperties');
我能够获得 MajorAxisLength
和 MinorAxisLength
。
错误消息显示“输入 'MaxFeretProperties' 与任何有效字符串都不匹配。”这非常清楚地表明出了什么问题:您正在请求 regionprops
函数不知道的功能。
请注意,'MaxFeretProperties' 最近作为一项功能引入 regionprops
。您可能拥有此更改之前的 MATLAB 版本。您需要升级您的 MATLAB 版本才能使用此功能。