# contourArea meaning and arclength

Hi, I'm playing with the moment coding and i'm confuse with the result. What I understand is the contourarea and the moment code will give the same result. 1) Contour area - is it means the area inside a close loop? Must it close contour? 2) what is the unit of the contour? I obtained result as 1, 7.5 and etc and confuse. 3) arclength is measuring the countour in pixel?

Anyone can help?

edit retag close merge delete

1

( 2015-07-29 09:08:00 -0500 )edit

Sort by ยป oldest newest most voted

I suppose that you are playing with this, so

1. contourArea is returning the area inside a contour (ofcourse, it should be closed, otherwise, it will consider it closed, so if it is a line it will consider the area inside the contour defined by the line if the first point and the last point are linked).
2. As mentioned in the docs, the unit is pixel. If you want to get more deeper in the theory, then see Green's theorem; but for a better understanding, if the contour is a triangle, then ofcourse its area is very probably not an integer number.
3. arcLength is measuring the length of a contour in pixels, ofcourse. Think that the contour is composed of points, so between each 2 points, there is a line, so that segment's length can be computed if the coordinates of the 2 points are known; and the coordinates are in pixels (with (0, 0) in top left corner of the image).

Q1. the function arcLength has a parameter closed that let you choose the case (read the docs...)

Q2. Well, that I cannot prove, because I have not the image you have. Hint: display the thresholded image to see the area. You can also draw the contour on another image to see exact what contour is it using.

more

@thdrksdfthmn, it is a details explaination!! :). Yes i'm playing with the code just for a bit and additional question.

Q1: if the contour is the line, so the length would be from the start to the end of the line? i.e. open loop? Q2: For moment or contourarea, let say if 7 means 7 pixels right ? I'm quite confuse because the area I look on the image should be more than 7 pixels after the thresholding as I'm using 268X206 image area.

Q3: In general, how moment can be used for the pattern recognition? I had listened few lectures in the youtube, but I could not find the relationship on how the moment can be used to do the pattern recognition process. Tried Hu's Moments and after rotate the image, it returns diff value. Should it be always the same? TQ

( 2015-07-29 21:39:50 -0500 )edit

@thdrksdfthmn, I tried to check using and a very simple image ( inside the image there is a square black and white). The dimension of the image is 100X100 pixel. The square point coordinate in the image are (11,11),(84,11),(11,84),(84,84). With the size of the square should be at 73 square = 5329 pixels. But running the moment code return me moment & area size = 5843 which is different. I didn't do blur in the image. With this thread I could not send the image. Only if I do a new thread I can share the image. Do I still have the wrong coding?

( 2015-08-03 06:14:52 -0500 )edit
1

Ok, supposing that this question is answered, you can create the thread you are talking about, adding: the code, the image and the question

( 2015-08-03 07:08:41 -0500 )edit

@thdrksdfthmn When we have detected a broken contour which is not closed. What would the contourArea return? Does it find the shortest path between the first and the last point, then give the area under that closed contour?

( 2017-11-10 23:01:59 -0500 )edit

Official site

GitHub

Wiki

Documentation