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
댓글 수: 0
답변 (1개)
Walter Roberson
2017년 5월 29일
If you have the Computer Vision toolbox, then: https://www.mathworks.com/help/vision/ref/insertshape.html
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Labyrinth problems에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!