OpenCV Q&A Forum - RSS feedhttp://answers.opencv.org/questions/OpenCV answersenCopyright <a href="http://www.opencv.org">OpenCV foundation</a>, 2012-2018.Wed, 15 Apr 2015 02:10:05 -0500Percentage of overlaphttp://answers.opencv.org/question/59544/percentage-of-overlap/ Hi all, how can I calculate the percentage of 2 overlapping images? If the result is 100 the 2 images are completely overlapped, if 0 they're completely disjoined.
PS: Because I'm doing stitch of images, I'm calculating the orb features,I don't know if it helps!Sat, 11 Apr 2015 04:32:30 -0500http://answers.opencv.org/question/59544/percentage-of-overlap/Answer by Eduardo for <p>Hi all, how can I calculate the percentage of 2 overlapping images? If the result is 100 the 2 images are completely overlapped, if 0 they're completely disjoined.</p>
<p>PS: Because I'm doing stitch of images, I'm calculating the orb features,I don't know if it helps!</p>
http://answers.opencv.org/question/59544/percentage-of-overlap/?answer=59574#post-id-59574 Hi.
The percentage of overlapping is: area_of_intersection / area_of_union * 100.
To get the intersection rectangle and thus the area of intersection (from this [link](http://stackoverflow.com/a/4549594)) with an origin point at the top left:
> left = max(r1.left, r2.left)
> right = min(r1.right, r2.right)
> bottom = min(r1.bottom, r2.bottom)
> top = max(r1.top, r2.top)
Verify that the intersection is not empty:
> left < right && bottom > top
A picture to show the problem:
![image description](/upfiles/1428780115365622.png)Sat, 11 Apr 2015 14:22:21 -0500http://answers.opencv.org/question/59544/percentage-of-overlap/?answer=59574#post-id-59574Comment by Eduardo for <p>Hi.</p>
<p>The percentage of overlapping is: area_of_intersection / area_of_union * 100.</p>
<p>To get the intersection rectangle and thus the area of intersection (from this <a href="http://stackoverflow.com/a/4549594">link</a>) with an origin point at the top left:</p>
<blockquote>
<pre><code>left = max(r1.left, r2.left)
right = min(r1.right, r2.right)
bottom = min(r1.bottom, r2.bottom)
top = max(r1.top, r2.top)
</code></pre>
</blockquote>
<p>Verify that the intersection is not empty:</p>
<blockquote>
<pre><code>left < right && bottom > top
</code></pre>
</blockquote>
<p>A picture to show the problem:
<img alt="image description" src="/upfiles/1428780115365622.png"/></p>
http://answers.opencv.org/question/59544/percentage-of-overlap/?comment=59788#post-id-59788Maybe you check could this [link](http://docs.opencv.org/doc/tutorials/highgui/video-input-psnr-ssim/video-input-psnr-ssim.html#videoinputpsnrmssim).Tue, 14 Apr 2015 13:09:57 -0500http://answers.opencv.org/question/59544/percentage-of-overlap/?comment=59788#post-id-59788Comment by bjorn89 for <p>Hi.</p>
<p>The percentage of overlapping is: area_of_intersection / area_of_union * 100.</p>
<p>To get the intersection rectangle and thus the area of intersection (from this <a href="http://stackoverflow.com/a/4549594">link</a>) with an origin point at the top left:</p>
<blockquote>
<pre><code>left = max(r1.left, r2.left)
right = min(r1.right, r2.right)
bottom = min(r1.bottom, r2.bottom)
top = max(r1.top, r2.top)
</code></pre>
</blockquote>
<p>Verify that the intersection is not empty:</p>
<blockquote>
<pre><code>left < right && bottom > top
</code></pre>
</blockquote>
<p>A picture to show the problem:
<img alt="image description" src="/upfiles/1428780115365622.png"/></p>
http://answers.opencv.org/question/59544/percentage-of-overlap/?comment=59718#post-id-59718Thanks for the answer, I misunderstood the problem. I need to check the percentage of similarity between two images. How can I proceed? For now I'm extracting features with orb!Tue, 14 Apr 2015 02:31:15 -0500http://answers.opencv.org/question/59544/percentage-of-overlap/?comment=59718#post-id-59718Comment by bjorn89 for <p>Hi.</p>
<p>The percentage of overlapping is: area_of_intersection / area_of_union * 100.</p>
<p>To get the intersection rectangle and thus the area of intersection (from this <a href="http://stackoverflow.com/a/4549594">link</a>) with an origin point at the top left:</p>
<blockquote>
<pre><code>left = max(r1.left, r2.left)
right = min(r1.right, r2.right)
bottom = min(r1.bottom, r2.bottom)
top = max(r1.top, r2.top)
</code></pre>
</blockquote>
<p>Verify that the intersection is not empty:</p>
<blockquote>
<pre><code>left < right && bottom > top
</code></pre>
</blockquote>
<p>A picture to show the problem:
<img alt="image description" src="/upfiles/1428780115365622.png"/></p>
http://answers.opencv.org/question/59544/percentage-of-overlap/?comment=59829#post-id-59829thanks man,I'll give a try and let you know!Wed, 15 Apr 2015 02:10:05 -0500http://answers.opencv.org/question/59544/percentage-of-overlap/?comment=59829#post-id-59829