该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
1. Step 1语句作用什么?
filename = 'coins.png';
coinsImg = imread(filename);
答:读取一张图片并显示出来。
2. Step 2语句作用什么?
[rows, cols, chans] = size(coinsImg);
if chans > 1
coinsImg = rgb2gray(coinsImg);
End
答:
3. Step 3语句作用是什么?
[pixelCount, grayLevels] = imhist(coinsImg);
bar(pixelCount);
4. Step 4语句中的阈值100是如何确定的?
threshold = 100;
5. Step 5语句作用是什么?显示bwImg的图像。
bwImg = coinsImg > threshold;
6. Step 6语句作用是什么?显示bwImg的图像。
bwImg = imfill(bwImg, 'holes');
7. Step 7语句作用什么?labeledImg图像的内容是什么?
labeledImg = bwlabel(bwImg, 8);
8. Step 8语句作用什么?显示coloredLabelsImg图像。
coloredLabelsImg = label2rgb(labeledImg, 'hsv', 'k', 'shuffle');
9. Step 9语句作用是什么?
blobMeasurements = regionprops(bwImg, 'all');
numberOfBlobs = size(blobMeasurements, 1);
10. Step 10语句作用什么?boundaries里面存放的内容是什么?
boundaries = bwboundaries(bwImg);
numberOfBoundaries = size(boundaries, 1);
11. Step 11语句作用什么?
for k = 1:numberOfBoundaries
thisBoundary = boundaries{k};
plot(thisBoundary(:,2), thisBoundary(:,1), 'g', 'LineWidth', 2);
end
12. Step 12语句作用是什么?语句中的2000是如何确定的?
allBlobAreas = [blobMeasurements.Area];
allowableAreaIndexes = allBlobAreas < 2000;
13. Step 13语句作用是什么?
keeperIndexes = find(allowableAreaIndexes);
14. Step 14语句作用是什么?keeperBlobsImg里面的内容是什么?
keeperBlobsImg = ismember(labeledImg, keeperIndexes);
15. Step 15语句作用什么?
labeledDimeImg = bwlabel(keeperBlobsImg, 8);