1.完整项目描述和程序获取
>面包多安全交易平台:https://mbd.pub/o/bread/Y52bkpls
>如果链接失效,可以直接打开本站店铺搜索相关店铺:
>如果链接失效,程序调试报错或者项目合作也可以加微信或者QQ联系。
2.部分仿真图预览
3.算法概述
这个课题适用于“完美迷宫”。 不使用搜索或优化方法,仅使用形态学和标准图像处理方法。 仅针对彩色和单色图像进行了测试。 包括演示迷宫,但您可以指定自己的迷宫图像。 迷宫图像应该在浅色背景上有深色墙壁。 迷宫可能会被白色包围,或者直接走到图像的边缘,并将外墙作为图像的外边界。
4.部分源码
[labeledImage numberOfWalls] = bwlabel(binaryImage, 4); % Label each blob so we can make measurements of it
coloredLabels = label2rgb (labeledImage, 'hsv', 'k', 'shuffle'); % pseudo random color labels
% Display the results of this step.
subplot(2, 2, 3);
imshow(coloredLabels);
caption = sprintf('Labeled image of the %d walls, each a different color', numberOfWalls);
title(caption, 'FontSize', fontSize);
if numberOfWalls ~= 2
message = sprintf('This is not a "perfect maze" with just 2 walls.\nThis maze appears to have %d walls,\nso you may get unexpected results.', numberOfWalls);
uiwait(msgbox(message));
end
binaryImage2 = (labeledImage == 1);
% Display the results of this step.
subplot(2, 2, 4);
imshow(binaryImage2, []);
title('One of the walls', 'FontSize', fontSize);
% Dilate the walls by a few pixels
dilationAmount = 7; % Number of pixels to dilate and erode.
dilatedImage = imdilate(binaryImage2, ones(dilationAmount));
figure; % Create another, new figure window.
set(gcf, 'Position', get(0,'Screensize')); % Maximize figure.
% Display the results of this step.
subplot(2, 2, 1);
imshow(dilatedImage, []);
title('Dilation of one wall', 'FontSize', fontSize);
filledImage = imfill(dilatedImage, 'holes');
% Display the results of this step.
subplot(2, 2, 2);
imshow(filledImage, []);
title('Now filled to get rid of holes', 'FontSize', fontSize);
%A161