Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

findContours gives me the border of the image

Hello, I'm working with OpenCv on Android and have a problem with the findContours function because it gives me the border of the image.

Here is an example (source image will always be a thresholded image) :

pic1 pic2

As you can see, I do have the contour of the blob, but I don't want to get the contour of the picture...

Actually, I need to find the biggest blob, so what I do is to find every contour, and then find the one with the biggest area, but to do this, I have to save the biggest area (which will be the contour of the image) and the second biggest (which will be the true biggest blob)... I think it's pretty ugly and a waste...

Is it a normal behaviour ? And Is there a way of getting rid of this ?

findContours gives me the border of the image

Hello, I'm working with OpenCv on Android and have a problem with the findContours function because it gives me the border of the image.

Here is an example (source image will always be a thresholded image) :

pic1 pic2

As you can see, I do have the contour of the blob, but I don't want to get the contour of the picture...

Actually, I need to find the biggest blob, so what I do is to find every contour, and then find the one with the biggest area, but to do this, I have to save the biggest area (which will be the contour of the image) and the second biggest (which will be the true biggest blob)... I think it's pretty ugly and a waste...

Is it a normal behaviour ? And Is there a way of getting rid of this ?

EDIT : here is the code i'm using Mat eyeMat = faceMat.submat(eyesArray[j]); //This is a gray image Imgproc.GaussianBlur(eyeMat, eyeMat, new Size(9, 9), 2, 2); Imgproc.threshold(eyeMat, eyeMat, 30, 255, Imgproc.THRESH_BINARY);

List<matofpoint> contours = new ArrayList<matofpoint>(); Mat hierarchy = new Mat(); Imgproc.findContours(eyeMat, contours, hierarchy, Imgproc.RETR_LIST, Imgproc.CHAIN_APPROX_NONE);

findContours gives me the border of the image

Hello, I'm working with OpenCv on Android and have a problem with the findContours function because it gives me the border of the image.

Here is an example (source image will always be a thresholded image) :

pic1 pic2

As you can see, I do have the contour of the blob, but I don't want to get the contour of the picture...

Actually, I need to find the biggest blob, so what I do is to find every contour, and then find the one with the biggest area, but to do this, I have to save the biggest area (which will be the contour of the image) and the second biggest (which will be the true biggest blob)... I think it's pretty ugly and a waste...

Is it a normal behaviour ? And Is there a way of getting rid of this ?

EDIT : here is the code i'm using using

Mat eyeMat = faceMat.submat(eyesArray[j]); //This is a gray image Imgproc.GaussianBlur(eyeMat, eyeMat, new Size(9, 9), 2, 2); Imgproc.threshold(eyeMat, eyeMat, 30, 255, Imgproc.THRESH_BINARY);

List<matofpoint> contours = new ArrayList<matofpoint>(); Mat hierarchy = new Mat(); Imgproc.findContours(eyeMat, contours, hierarchy, Imgproc.RETR_LIST, Imgproc.CHAIN_APPROX_NONE);

findContours gives me the border of the image

Hello, I'm working with OpenCv on Android and have a problem with the findContours function because it gives me the border of the image.

Here is an example (source image will always be a thresholded image) :

pic1 pic2

As you can see, I do have the contour of the blob, but I don't want to get the contour of the picture...

Actually, I need to find the biggest blob, so what I do is to find every contour, and then find the one with the biggest area, but to do this, I have to save the biggest area (which will be the contour of the image) and the second biggest (which will be the true biggest blob)... I think it's pretty ugly and a waste...

Is it a normal behaviour ? And Is there a way of getting rid of this ?

EDIT : here is the code i'm using

Mat eyeMat = faceMat.submat(eyesArray[j]); //This is a gray image
 Imgproc.GaussianBlur(eyeMat, eyeMat, new Size(9, 9), 2, 2);
 Imgproc.threshold(eyeMat, eyeMat, 30, 255, Imgproc.THRESH_BINARY);

List<matofpoint> Imgproc.THRESH_BINARY); List<MatOfPoint> contours = new ArrayList<matofpoint>(); ArrayList<MatOfPoint>(); Mat hierarchy = new Mat(); Imgproc.findContours(eyeMat, contours, hierarchy, Imgproc.RETR_LIST, Imgproc.CHAIN_APPROX_NONE);

Imgproc.CHAIN_APPROX_NONE);

findContours gives me the border of the image

Hello, I'm working with OpenCv on Android and have a problem with the findContours function because it gives me the border of the image.

Here is an example (source image will always be a thresholded image) :

pic1 pic2

As you can see, I do have the contour of the blob, but I don't want to get the contour of the picture...

Actually, I need to find the biggest blob, so what I do is to find every contour, and then find the one with the biggest area, but to do this, I have to save the biggest area (which will be the contour of the image) and the second biggest (which will be the true biggest blob)... I think it's pretty ugly and a waste...

Is it a normal behaviour ? And Is there a way of getting rid of this ?

EDIT : here is the code i'm using

Mat eyeMat = faceMat.submat(eyesArray[j]); //This is a gray image
image    
Imgproc.GaussianBlur(eyeMat, eyeMat, new Size(9, 9), 2, 2);
2);    
Imgproc.threshold(eyeMat, eyeMat, 30, 255, Imgproc.THRESH_BINARY);
Imgproc.THRESH_BINARY);    
List<MatOfPoint> contours = new ArrayList<MatOfPoint>();
Mat hierarchy = new Mat();
Imgproc.findContours(eyeMat, contours, hierarchy, Imgproc.RETR_LIST, Imgproc.CHAIN_APPROX_NONE);

findContours gives me the border of the image

Hello, I'm working with OpenCv on Android and have a problem with the findContours function because it gives me the border of the image.

Here is an example (source image will always be a thresholded image) :

pic1 pic2

As you can see, I do have the contour of the blob, but I don't want to get the contour of the picture...

Actually, I need to find the biggest blob, so what I do is to find every contour, and then find the one with the biggest area, but to do this, I have to save the biggest area (which will be the contour of the image) and the second biggest (which will be the true biggest blob)... I think it's pretty ugly and a waste...

Is it a normal behaviour ? And Is there a way of getting rid of this ?

EDIT : here is the code i'm using

Mat eyeMat = faceMat.submat(eyesArray[j]); //This is a gray image    
Imgproc.GaussianBlur(eyeMat, eyeMat, new Size(9, 9), 2, 2);    
Imgproc.threshold(eyeMat, eyeMat, 30, 255, Imgproc.THRESH_BINARY);    
List<MatOfPoint> contours = new ArrayList<MatOfPoint>();
Mat hierarchy = new Mat();
Imgproc.findContours(eyeMat, contours, hierarchy, Imgproc.RETR_LIST, Imgproc.CHAIN_APPROX_NONE);

findContours gives me the border of the image

Hello, I'm working with OpenCv on Android and have a problem with the findContours function because it gives me the border of the image.

Here is an example (source image will always be a thresholded image) :

pic1 pic2

As you can see, I do have the contour of the blob, but I don't want to get the contour of the picture...

Actually, I need to find the biggest blob, so what I do is to find every contour, and then find the one with the biggest area, but to do this, I have to save the biggest area (which will be the contour of the image) and the second biggest (which will be the true biggest blob)... I think it's pretty ugly and a waste...

Is it a normal behaviour ? And Is there a way of getting rid of this ?

EDIT : here is the code i'm using

Mat eyeMat = faceMat.submat(eyesArray[j]); //This is a gray image    
Imgproc.GaussianBlur(eyeMat, eyeMat, new Size(9, 9), 2, 2);    
Imgproc.threshold(eyeMat, eyeMat, 30, 255, Imgproc.THRESH_BINARY);    
List<MatOfPoint> contours = new ArrayList<MatOfPoint>();
Mat hierarchy = new Mat();
Imgproc.findContours(eyeMat, contours, hierarchy, Imgproc.RETR_LIST, Imgproc.CHAIN_APPROX_NONE);