I am making a small indoor navigation application for my project. The main Idea behind my application is that i will be given a .pdf file or Autocad file(floor plan) for some Area. I have to parse or get data from that image to find out open path in a floor plan. For Determining open Path from an image i have to map image content or data in some Data Structure also, so that i can apply some path finding algorithms on it. My problem is that i don't know how can i break my image into pixels or any other form to get data from it in my initial phase. Do i need to apply some image processing using Matlab or it could be achieved by Java Or Python Libraries?
-
http://stackoverflow.com/questions/19532473/floor-plan-edge-detection-image-processing – Prune Sep 15 '15 at 21:32
1 Answers
This is a rather broad question, so i can only give hints on some of the relevant points.
How to read single pixels from an Image in java:
BufferedImage bi = ImageIO.read(new File("pathToYourImage")); bi.getRGB(0 , 0);
This way you can load an image in java and get the values of a single pixel ((0,0) in the example).
Datastructure: The most common way of representing a floorplan or any other kind of collection of paths is a graph. There are several good libraries on the net for graphs, or you can implement it on your own.
ImageProcessing: Since the image won't be b/w (i guess), you'll have to transform it in order to preform the transformation into a graph - though the conversion to a graph wouldn't even be necessary. The most common way would be to simply convert the graph into a b/w image where black pixels are walls. Since the color of pixels representing the floor might not be perfectly the same color equal, i added some imprecision (
delta
) to the comparison://comparison function boolean isMatch(Color inp , Color toMatch) { final int delta = 25; return (Math.abs(inp.getRed() - toMatch.getRed()) <= delta && Math.abs(inp.getBlue() - toMatch.getBlue()) <= delta && Math.abs(inp.getGreen() - toMatch.getGreen()) <= delta); } //color of pixels that don't represent obstacles Color floor = getFloorColor(); //create a copy of the image for the transformation BufferedImage floorPlan = new BufferedImage(getFloorPlan().getWidth() , getFloorPlan().getHeight() , BufferedImage.TYPE_INT_RGB); floorPlan.getGraphics().drawImage(getFloorPlan() , floorPlan.getWidth() , floorPlan.getHeight() , null); //color pixels that aren't walls or other obstacles white and obstacles/walls black for(int i = 0 ; i < floorPlan.getWidth() ; i++) for(int j = 0 ; j < floorPlan.getHeight() ; j++) if(isMatch(new Color(floorPlan.getRGB(i , j)) , floor) floorPlan.setRGB(Color.WHITE.getRGB()); else floorPlan.setRGB(Color.BLACK.getRGB());
This image can now easily be either transformed into a graph, or used directly as representation of the graph.