Ask Your Question
0

Compare segmentation result to ground truth

asked 2019-08-07 10:08:34 -0600

Jérémy K gravatar image

updated 2019-08-09 05:17:22 -0600

I have some contours which represent certain objects found with cv2.findContours() in a segmentation result. On the other hand, I also have the ground truth data in the same format (polygon points in [x, y]). I'm now looking for the best way to measure the intersection/overlap of both polygons to measure how well the segmentation performed.

Thank you in advance!

-- Update --

To add in some context, here's for example the data from one contour found with cv2.findContours():

[[[1086  603]],[[1085  605]],[[1078  605]],[[1076  606]],[[1073  606]],[[1071  608]],[[1068  608]],[[1066  610]],[[1065  610]],[[1061  6,3]],[[1060  613]],[[1060  615]],[[1058  616]],[[1058  625]],[[1060  626]],[[1060  636]],[[1061  638]],[[1061  650]],[[1063  651]],[[1063  658]],[[1061  660]],[[1063  661]],[[1063  671]],[[1065  673]],[[1065  676]],[[1066  678]],[[1066  681]],[[1068  683]],[[1068  701]],[[1070  703]],[[1070  713]],[[1075  718]],[[1078  718]],[[1080  720]],[[1101  720]],[[1103  718]],[[1106  718]],[[1110  715]],[[1111  715]],[[1115  711]],[[1116  711]],[[1118  710]],[[1118  708]],[[1120  706]],[[1120  703]],[[1121  701]],[[1121  683]],[[1123  681]],[[1123  670]],[[1121  668]],[[1121  615]],[[1120  613]],[[1120  611]],[[1118  610]],[[1113  610]],[[1111  608]],[[1108  608]],[[1106  606]],[[1103  606]],[[1101  605]],[[1088  605]]]

And this is the ground truth data:

[[1054, 625], [1070, 719], [1084, 726], [1112, 724], [1125, 716], [1126, 631], [1128, 619], [1132, 610], [1127, 603], [1118, 602], [1107, 600], [1090, 600], [1074, 603], [1059, 607], [1049, 614], [1051, 620]]

(Ignore the mismatch of arrays between the contours data and ground truth, this is just an example.)

edit retag flag offensive close merge delete

Comments

1

Look at the literature. There should be some defined metrics for segmentation benchmarks and probably some code available on these sites.

Off the top of my head, fill the contours (look at drawContours) and perform intersection over union metric (count the number of pixels that overlap over the sum of all the pixels minus the intersection).

Eduardo gravatar imageEduardo ( 2019-08-09 08:38:06 -0600 )edit
1

Well you need some metric like this https://www.pyimagesearch.com/2016/11...

holger gravatar imageholger ( 2019-08-09 15:38:31 -0600 )edit

1 answer

Sort by » oldest newest most voted
0

answered 2019-08-09 16:04:16 -0600

Jérémy K gravatar image

Interesection over Union seems to be what I need indeed. I'll take a deeper look into it. Thanks a lot for your help @Eduardo & @holger !

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2019-08-07 10:08:34 -0600

Seen: 954 times

Last updated: Aug 09 '19