Maze Image Manipulation, Trimming whitespace

maze http://i60.tinypic.com/1491gzn.jpg

The problem i am having is the 2 pixel width pathways (the white parts).

In the top-left of the image (the darker black part) i have manually gone over the white parts that were 2 pixels in width/height;

there are two solutions (that i can think of).

  • to programmatically edit it so that pathways are 1x1;
  • to find a way of dealing with paths that are larger than 1x1.
  • any suggestions, the maze-solving algorithm (tremaux) i have implemented works for 1x1 pathways but i am trying to adapt it to this larger maze.

    preferably looking for a solution that is adaptable to a maze where the pathway widths can be any size as i have already written a tool where i can take an image and turn it into a monochrome int[][] array for maze solving.

    Just looking for hints/steps in the right direction since I'm not sure if I'm looking at this correctly or if I'm heading down the correct path (no pun intended).

    Thanks


    So your grid is effectively repeating (1,2) = 3 pixels, 1 wall 2 paths. Just remove every 3th row. Then remove every 3th column.


    Think of the image as being divided up into 3x3 blocks, with the top-left corner being always wall, the top row and left column being the optional walls and the rest being path, like this:

    W w w
    w P P
    w P P
    
    W = always wall
    w = possible wall
    P = always path
    

    You need to convert each of those 3x3 blocks into a 2x2 block like this:

    W w
    w P
    
    链接地址: http://www.djcxy.com/p/79624.html

    上一篇: 将ASCII迷宫转录成图形

    下一篇: 迷宫图像操作,修剪空白