Ask Your Question
0

Why does number of contours differ on picture resolution

asked 2016-01-28 10:40:00 -0600

Polyquin gravatar image

updated 2020-10-10 14:47:12 -0600

Hi all,

Quick question on findContours. I ran findContours on a picture with resolution of 640 x 960 and findContours returned more contours. I resized the same picture to 320x480 and it returned lesser contours.

I'm not sure why is this happening. I would have thought that the resolution is immaterial to findContour.

Any ideas?

edit retag flag offensive close merge delete

Comments

2

it depends on the object & the noise in the image & how you are applying threshold. Can you show us your code & results?

Balaji R gravatar imageBalaji R ( 2016-01-28 11:17:26 -0600 )edit

You can use drawContours to see which contours are found. Often, when you look at the results the source of the problem becomes obvious. guy

Guyygarty gravatar imageGuyygarty ( 2016-01-28 13:31:35 -0600 )edit

Ok, I'll show the code and results shortly.

Polyquin gravatar imagePolyquin ( 2016-01-28 21:17:15 -0600 )edit

you must show your code and the image.

sturkmen gravatar imagesturkmen ( 2016-02-01 15:55:43 -0600 )edit

1 answer

Sort by » oldest newest most voted
1

answered 2016-02-01 15:20:16 -0600

Polyquin gravatar image

Hi all,

I've figured out why the contours decrease when the image resolution is reduced. The reason is due to image interpolation.

If cv2.resize was used, there is a argument for the type of interpolation to be used:

interpolation method:

  • INTER_NEAREST - a nearest-neighbor interpolation
  • INTER_LINEAR - a bilinear interpolation (used by default)
  • INTER_AREA - resampling using pixel area relation. It may be a preferred method for image decimation, as it gives moire’-free results. But when the image is zoomed, it is similar to the INTER_NEAREST method.
  • INTER_CUBIC - a bicubic interpolation over 4x4 pixel neighborhood
  • INTER_LANCZOS4 - a Lanczos interpolation over 8x8 pixel neighborhood
edit flag offensive delete link more

Comments

why you did not post the code and the image you tried?

sturkmen gravatar imagesturkmen ( 2016-02-01 15:55:12 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-01-28 10:40:00 -0600

Seen: 306 times

Last updated: Feb 01 '16