Ask Your Question
2

Information extraction from image

asked 2016-01-21 11:08:06 -0600

Dr Dre gravatar image

updated 2017-08-25 14:28:19 -0600

Hi guys

I am working on a line follower robot which finds the shortest path and travels it. This robot is given an input image (which is the image of the area the robot should travel) as shown below

Input Image

For understanding purpose let me assume the red circle to be nodes and the line joining this circle as links.

There are two types of links horizontal link (denoted by green line) and vertical link (denoted by blue line) as shown below.

image description

I want to whether link is present between two nodes and store the result in an array ( using numpy).

In order to do this what image processing operation should i do on this input image so that i may know that link is present ?

I am using pyhton 2.7 and open cv2

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2016-01-21 16:26:37 -0600

Tetragramm gravatar image

updated 2016-01-22 07:01:25 -0600

If the mazes are all this regular and all this nicely binarized, you should just check single pixels in the center of the lane, in the center of each segment (like the image). If it's black, there's a segment, if it's white, there's no segment.

image description

EDIT:

image = imread("C:\\Users\\Tetragramm\\Downloads\\pre-corners.jpg");
cvtColor(image, trueGray, COLOR_BGR2GRAY);
threshold(trueGray, trueGray, 128, 255, THRESH_BINARY);
copyMakeBorder(trueGray, gray, 10, 10, 10, 10, BORDER_CONSTANT, 255);
cornerHarris(gray, output, 1, 1, 1);
double min, max;
minMaxIdx(output, &min, &max);
cv::threshold(output, output, min + (max - min) / 100.0, 255, THRESH_BINARY_INV);
cv::imshow("output", output);
waitKey();

image description

edit flag offensive delete link more

Comments

Thank U Tetragramm .. This method is good if nodes which are placed at equal distance. If the nodes are placed at unequal distance what method should i follow ?

Dr Dre gravatar imageDr Dre ( 2016-01-21 20:55:28 -0600 )edit

Replicate the border as white so you have edges at the edge of the image. Do a corner detector, like Harris, then there should be sets of 2 or 4 corners. 2 Corners has 4 options, with two or three paths coming out. You can check each direction to see where the paths go. 4 corners is only one option, a four way intersection.

Be wary about the 2 corners 3 paths case. The corners do not average to the center of the intersection, so you have to offset differently when checking.

Tetragramm gravatar imageTetragramm ( 2016-01-21 21:43:07 -0600 )edit

Sorry Sir I do not understand what u have said above. Can u please simplify and tell.

Dr Dre gravatar imageDr Dre ( 2016-01-21 22:05:02 -0600 )edit
1

Use copyMakeBorder so the black doesn't go right up to the edge of the image. Use cornerHarris to find the corners. Do some logic to figure out which corners are together and which way the paths go from those corners.

I edited the answer with sample code and the image from doing it on this sample.

Tetragramm gravatar imageTetragramm ( 2016-01-22 06:59:54 -0600 )edit

Thank U Tetragramm

Dr Dre gravatar imageDr Dre ( 2016-01-22 07:22:52 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-01-21 11:08:06 -0600

Seen: 522 times

Last updated: Jan 22 '16