Make black and white pixel image of a grid

1 次查看(过去 30 天)
I have this function which generates a 12x12 maze with lines as borders of the maze. I need to convert it into a monochromatic image of 25x25 with each black pixel being boundary and each white pixel being the available path.
As maze is generated randomly, I need to update the monochromatic image maze with the original maze.
Actual maze (randomly generated from code) is attached.
Kindly help me out in this regard.
function show_maze(row, col, rr, cc, ptr_left, ptr_up, ptr_right, ptr_down,h)
figure(h)
line([.5,col+.5],[.5,.5]) % draw top border
line([.5,col+.5],[row+.5,row+.5]) % draw bottom border
line([.5,.5],[1.5,row+.5]) % draw left border
line([col+.5,col+.5],[.5,row-.5]) % draw right border
for ii=1:length(ptr_right)
if ptr_right(ii)>0 % right passage blocked
line([cc(ii)+.5,cc(ii)+.5],[rr(ii)-.5,rr(ii)+.5]);
hold on
end
if ptr_down(ii)>0 % down passage blocked
line([cc(ii)-.5,cc(ii)+.5],[rr(ii)+.5,rr(ii)+.5]);
hold on
end
end
axis equal
axis([.5,col+.5,.5,row+.5])
axis off
set(gca,'YDir','reverse')
return

回答(1 个)

Walter Roberson
Walter Roberson 2017-5-29
If you have the Computer Vision toolbox, then: https://www.mathworks.com/help/vision/ref/insertshape.html

类别

Help CenterFile Exchange 中查找有关 Labyrinth problems 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by