Ask Your Question
0

The hausdorff distance is not zero even when 2 same images are passed

asked 2017-06-02 00:57:27 -0600

lohachan0108 gravatar image

updated 2017-06-02 03:56:01 -0600

I am passing 2 same images in hausdorff and shapeContextDistanceExtractor to calculate distance. We are expecting the answer to be zero since the images are same but we are getting a non-zero value. Can somebody please explain why.

            // Hausdorff Distant Extractor

            Ptr<HausdorffDistanceExtractor> model = createHausdorffDistanceExtractor();

            dist = model->computeDistance(c1, c2);

I am passing 2 images and extracting the points using samplecounters. Here c1 and c2 are the vector of countour points which are passed to the computeDistance function. The 2 images that I pass are same yet the distance I am getting in dist is non-zero. Please help.

edit retag flag offensive close merge delete

Comments

this means, your contours are not identical.

please check. (e.g. cerr << Mat(c1) << endl << Mat(c2) << endl;)

are you using jpg images ? (lossy compression, just don't)

berak gravatar imageberak ( 2017-06-02 01:16:07 -0600 )edit

Yes. I am using jpg images. If not jpg, what images should I use?

lohachan0108 gravatar imagelohachan0108 ( 2017-06-07 23:20:08 -0600 )edit

png, bmp, any non-lossy format

berak gravatar imageberak ( 2017-06-07 23:21:24 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-06-07 05:11:45 -0600

lohachan0108 gravatar image

The hausdorff considers the worst matchin pairs in the two images. Hence it never returns a zero value. Whereas the shapeContextDistanceExtractor returns a zero value when 2 same images are passed.

edit flag offensive delete link more

Comments

this is not really true. the hausdorff distance will return 0 , given identical contours.

berak gravatar imageberak ( 2017-06-07 23:01:18 -0600 )edit

No. I have done it in openCV. The value is less, say a single digit, but is never zero.

lohachan0108 gravatar imagelohachan0108 ( 2017-06-07 23:18:48 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2017-06-02 00:57:27 -0600

Seen: 506 times

Last updated: Jun 07 '17