views:

340

answers:

2

Could somebody get me started with the following idea:

I want to load an image into my java (java swing) application (a floor plan or blue print). Let's say the floor plan image has a white background with 3 shapes on it (a rectangle, a triangle and a circle). The shapes have a black border.

The program should detect these shapes and draw the 3 shapes on top of it.

For example: it detects the rectangle and a new rectangle will be drawn on top of that rectangle from the image. When that extra rectangle is drawn, the user should be able to modify that rectangle and do extra things with it like filling the rectangle, changing the border style, ...

For example: in this case little points or squares on the corners should be visible so that we can drag/resize/move the rectangle. A bit like this screenshot from visual studio: http://farm1.static.flickr.com/49/132219212_061a1300af_o.png

Does anybody have tutorials for this? Am I missing some very useful java algorithms? etc...? All suggestions or help is welcome

Tnx in advance

+1  A: 

Well, one brute force method of doing this would be to go through the pixels in the image, see api for BufferedImage, and detect the shapes by consecutive pixels of a certain color. I am sure there is a much more efficient way of doing this though.

broschb
Well I had this also in mind but this would only work for horizontal/vertical lines. What about an ellipse?
juFo
You would need to find some heuristic that would approximate a sphere or circular shape, and look for this when scanning the pixels. I still think there is a better way to accomplish this, but can't think of anything right now. There are several papers such as this(http://www.umiacs.umd.edu/~hankyu/shape_html/) that discuss such problems.
broschb
That looks a bit complex (for a beginner like me) broschb but thnx anyway. Did you find a better way? I found things about canny edge detection but I don't know if that is easy to implement.
juFo
+1  A: 

Correctly detecting shapes in scanned picture which could suffer from all sorts of issues (color, dpi, rotation, shear). Even a non-scanned picture could be very difficult. You may want to look into using OpenCV in Java.

basszero