Ask Your Question

Josef's profile - activity

2020-10-23 10:10:08 -0600 received badge  Student (source)
2014-06-18 07:31:45 -0600 received badge  Supporter (source)
2014-06-18 07:31:18 -0600 commented answer Android: cannot draw the interior of contours

I know that the background is brighter than the foreground. Hm I am starting to get the feeling that you are right with your advice of using thresholding :-) Until now i have used global thresholding with Otsu's method and adaptive thresholding, but the results were never satisfying. Maybe I will try image partitioning or watersheds. Thanks again you helped a lot.

2014-06-18 05:05:22 -0600 commented answer Android: cannot draw the interior of contours

I have tried thresholding before, but it failed due to bad lighting. I also tried and probably will continue to use image enhancement methods in a preprocessing step, or use different thresholding methods. The idea with contours is to binarize the image even if the lighting is bad which should work pretty well as the basic structure of my input images is known.

2014-06-18 03:42:10 -0600 commented answer Android: cannot draw the interior of contours

Hello,

thank you very much for you quick answer. Drawing the contours in a loop works but the result is not exactly what I need to achieve. I should have stated my goal more precisely. With interior of the contours, I meant the pixels corresponding to the green and red lines of the input image.

This is the reason why I used RETR_CCOMP as contour retrieval mode. Maybe I have to analyze the hierarchy more thoroughly.

Again thanks for your helpful answer.

2014-06-17 09:10:39 -0600 asked a question Android: cannot draw the interior of contours

Hello,

I don't know if this is a bug or a mistake by me but i cannot draw the interior of the contours of an image. My input image is this:

image description

I am using the Android version of OpenCv and the following code snippet for contour detection:

Mat canny = new Mat();
Imgproc.Canny(in_grayImg, canny, 100, 200);

List<MatOfPoint> contours = new LinkedList<MatOfPoint>();
Mat hierarchy = new Mat();
Imgproc.findContours(canny, contours, hierarchy, Imgproc.RETR_CCOMP,
            Imgproc.CHAIN_APPROX_SIMPLE);

These are the detected contours drawn with

Imgproc.drawContours(canny, contours, -1, new Scalar(255));

image description

According to the API using the drawContours with a negative thickness value draws the interior of the contours. However the following code to draw the contours results in the same image as before:

Imgproc.drawContours(canny, contours, -1, new Scalar(255), -1);

image description

I also tried using the detected hierarchy but the result is unchanged:

Imgproc.drawContours(canny, contours, -1, new Scalar(255), -1, 8, hierarchy, 2, new Point(0, 0));

image description

I really don't know what I am doing wrong and it seems to me that a negative thickness value is simply ignored.

Thanks in advance and best regards,

Josef