Ask Your Question

sn4k3's profile - activity

2020-10-18 13:25:08 -0600 marked best answer Detect all black pixels inside a surrounded closed white area

How can i detect black pixels surrounded by closed white pixels? Background outside shapes should not be considered.

See next two images: First image i would like to extract all black pixels inside the hallow shape because it's traped/surrounded by white, but image 2 have a opeing and in that case i don't need the pixels. Image 3 shows the desired capture area in red

close open

Image 3: Desired capture area from image1 in red. Same pass on image 2 should return 0 pixels (No area detected) capture area

Another example:

Input: ex2_input

Needed area in red: ex2_output

EDIT 1:

                Image<Gray, byte> grayscale = ActualLayerImage.ToEmguImage();
                VectorOfVectorOfPoint contours = new VectorOfVectorOfPoint();
                Mat external = new Mat();

                CvInvoke.FindContours(grayscale, contours, external, RetrType.Ccomp, ChainApproxMethod.ChainApproxSimple);

                var arr = external.GetData();
                for (int i = 0; i < contours.Size; i++)
                {
                    if((int)arr.GetValue(0, i, 2) != -1) continue;
                    var r = CvInvoke.BoundingRectangle(contours[i]);
                    CvInvoke.Rectangle(grayscale, r, new MCvScalar(125), 10);
                }

Code on different inputs:

Image 4: OK ex3

Image 5: OK ex4

Image 6: Not OK! ex4

How to discard image6 cases?

EDIT 2: The solution:

                 Image<Gray, byte> grayscale = ActualLayerImage.ToEmguImage();

                VectorOfVectorOfPoint contours = new VectorOfVectorOfPoint();
                Mat external = new Mat();

                CvInvoke.FindContours(grayscale, contours, external, RetrType.Ccomp, ChainApproxMethod.ChainApproxSimple);

                var arr = external.GetData();

                /*
                 * hierarchy[i][0]: the index of the next contour of the same level
                 * hierarchy[i][1]: the index of the previous contour of the same level
                 * hierarchy[i][2]: the index of the first child
                 * hierarchy[i][3]: the index of the parent
                 */
                for (int i = 0; i < contours.Size; i++)
                {
                    if ((int)arr.GetValue(0, i, 2) != -1 || (int)arr.GetValue(0, i, 3) == -1) continue;
                    var r = CvInvoke.BoundingRectangle(contours[i]);
                    CvInvoke.Rectangle(grayscale, r, new MCvScalar(125), 5);
                }
2020-10-18 13:25:06 -0600 received badge  Self-Learner (source)
2020-10-18 13:22:40 -0600 received badge  Student (source)
2020-07-27 00:01:47 -0600 commented answer Join floating white pixels to the nearest island without closing morph?

I will try your way, seens the way to go

2020-07-25 19:38:56 -0600 edited question Join floating white pixels to the nearest island without closing morph?

Join floating white pixels to the nearest island without closing morph? Currently using Closing to gap closing and mergi

2020-07-25 19:37:56 -0600 edited question Join floating white pixels to the nearest island without closing morph?

Join floating white pixels to the nearest island without closing morph? Currently using Closing to gap closing and mergi

2020-07-25 19:36:52 -0600 edited question Join floating white pixels to the nearest island without closing morph?

Join floating white pixels to the nearest island without closing morph? Currently using Closing to gap closing and mergi

2020-07-25 19:35:29 -0600 edited question Join floating white pixels to the nearest island without closing morph?

Join floating white pixels to the nearest island without closing morph? Currently using Closing to gap closing and mergi

2020-07-25 19:34:35 -0600 asked a question Join floating white pixels to the nearest island without closing morph?

Join floating white pixels to the nearest island without closing morph? Currently using Closing to gap closing and mergi

2020-07-11 22:55:05 -0600 answered a question Transform gray image to create a pattern effect on while pixels given a mask

Find a solution, don't know if is the best aproach but this work perfectly CvInvoke.Erode(dst, erode, kernel, anchor, b

2020-07-10 20:04:16 -0600 commented question Transform gray image to create a pattern effect on while pixels given a mask

But how to create that pattern on image? EDIT: Was able to find a solution, will post it tomorrow

2020-07-10 10:20:48 -0600 commented question Transform gray image to create a pattern effect on while pixels given a mask

But how to create that pattern on image?

2020-07-09 22:23:18 -0600 edited question Transform gray image to create a pattern effect on while pixels given a mask

Transform gray image to create a pattern effect on while pixels given a mask I need to create a pattern on white pixels

2020-07-09 22:20:42 -0600 asked a question Transform gray image to create a pattern effect on while pixels given a mask

Transform gray image to create a pattern effect on while pixels given a mask I need to create a pattern on white pixels

2020-06-19 21:40:36 -0600 received badge  Enthusiast
2020-06-17 15:49:53 -0600 commented question Best way to gather all pixels location (XY) inside a closed contour?

Ok it seens my search lot faster: RectSearch: 1ms FindNonZero: 27ms RectSearch: 0ms (When empty) FindNonZero: 2ms (

2020-06-17 15:49:44 -0600 commented question Best way to gather all pixels location (XY) inside a closed contour?

Ok it seens my search lot faster: RectSearch: 1ms FindNonZero: 27ms RectSearch: 0ms (When empty) FindNonZero: 2ms (

2020-06-17 15:48:29 -0600 commented question Best way to gather all pixels location (XY) inside a closed contour?

Ok it seens my search lot faster: RectSearch: 1ms FindNonZero: 27ms RectSearch: 0ms (When empty) FindNonZero: 2ms (

2020-06-17 15:48:15 -0600 commented question Best way to gather all pixels location (XY) inside a closed contour?

Ok it seens my search lot faster: RectSearch: 1ms FindNonZero: 27ms RectSearch: 0ms (When empty) FindNonZero: 2ms (W

2020-06-17 15:47:53 -0600 commented question Best way to gather all pixels location (XY) inside a closed contour?

Ok it seens my search lot faster: RectSearch: 1ms FindNonZero: 27ms RectSearch: 0ms (When empty) FindNonZero: 2ms (Whe

2020-06-17 09:55:49 -0600 commented question Best way to gather all pixels location (XY) inside a closed contour?

Language: C# with EmguCV. Will take a look at both, i also updated the code so i search only inside the contour rectangl

2020-06-17 09:55:31 -0600 commented question Best way to gather all pixels location (XY) inside a closed contour?

Language: C# with EmguCV Will take a look at both, i also updated the code so i search only inside the contour rectangle

2020-06-16 23:12:44 -0600 edited question Best way to gather all pixels location (XY) inside a closed contour?

Best way to gather all pixels location (XY) inside a closed contour? Currently i have a black&white 3D model sliced

2020-06-16 23:08:35 -0600 edited question Best way to gather all pixels location (XY) inside a closed contour?

Best way to gather all pixels location (XY) inside a closed contour? Currently i have a black&white 3D model sliced

2020-06-16 23:06:05 -0600 edited question Best way to gather all pixels location (XY) inside a closed contour?

Best way to gather all pixels location (XY) inside a closed contour? Currently i have a black&white 3D model sliced

2020-06-16 23:02:28 -0600 edited question Best way to gather all pixels location (XY) inside a closed contour?

Best way to gather all pixels location (XY) inside a closed contour? Currently i have a black&white 3D model sliced

2020-06-16 23:02:23 -0600 edited question Best way to gather all pixels location (XY) inside a closed contour?

Best way to gather all pixels inside a closed contour? Currently i have a black&white 3D model sliced in 2D images (

2020-06-16 23:01:53 -0600 asked a question Best way to gather all pixels location (XY) inside a closed contour?

Best way to gather all pixels inside a closed contour? Currently i have a black&white 3D model sliced in 2D images (

2020-06-14 11:26:45 -0600 edited question Detect all black pixels inside a surrounded closed white area

Detect all black pixels inside a surrounded closed white area How can i detect black pixels surrounded by closed white p

2020-06-14 11:26:03 -0600 edited question Detect all black pixels inside a surrounded closed white area

Detect all black pixels inside a surrounded closed white area How can i detect black pixels surrounded by closed white p

2020-06-14 11:21:10 -0600 commented question Detect all black pixels inside a surrounded closed white area

Thank you! if ((int)arr.GetValue(0, i, 2) != -1 || (int)arr.GetValue(0, i, 3) == -1) continue; // Solved my problem :)

2020-06-14 11:20:45 -0600 commented question Detect all black pixels inside a surrounded closed white area

Thank you! if ((int)arr.GetValue(0, i, 2) != -1 || (int)arr.GetValue(0, i, 3) == -1) continue; // Solved my problem :)

2020-06-14 11:19:04 -0600 commented question Detect all black pixels inside a surrounded closed white area

Thank you! if ((int)arr.GetValue(0, i, 2) != -1 || (int)arr.GetValue(0, i, 3) == -1) continue; // Solved my problem :)

2020-06-14 11:16:38 -0600 commented question Detect all black pixels inside a surrounded closed white area

Thank you! if ((int)arr.GetValue(0, i, 2) != -1 || (int)arr.GetValue(0, i, 3) == -1) continue; // Solved my problem :)

2020-06-13 23:30:21 -0600 edited question Detect all black pixels inside a surrounded closed white area

Detect all black pixels inside a surrounded closed white area How can i detect black pixels surrounded by closed white p

2020-06-13 23:28:00 -0600 commented question Detect all black pixels inside a surrounded closed white area

That almost solved the problem, but when shape is all solid it get returned. I have edited my post to show the problem.

2020-06-13 23:26:53 -0600 edited question Detect all black pixels inside a surrounded closed white area

Detect all black pixels inside a surrounded closed white area How can i detect black pixels surrounded by closed white p

2020-06-13 11:07:36 -0600 edited question Detect all black pixels inside a surrounded closed white area

Detect all black pixels inside a surrounded closed white area How can i detect black pixels surrounded by closed white p

2020-06-13 11:06:53 -0600 edited question Detect all black pixels inside a surrounded closed white area

Detect all black pixels inside a surrounded closed white area How can i detect black pixels surrounded by closed white p

2020-06-13 11:02:35 -0600 edited question Detect all black pixels inside a surrounded closed white area

Detect all black pixels inside a surrounded closed white area How can i detect black pixels surrounded by closed white p

2020-06-13 11:00:15 -0600 commented answer Detect all black pixels inside a surrounded closed white area

No, i've add the desired capture area on main post. Also the shape is an example, but they can by any shape and odd form

2020-06-13 10:59:40 -0600 edited question Detect all black pixels inside a surrounded closed white area

Detect all black pixels inside a surrounded closed white area How can i detect black pixels surrounded by closed white p

2020-06-13 10:51:33 -0600 commented answer Detect all black pixels inside a surrounded closed white area

No, i've add the desired capture area on main post. Also the shape is an example, but they can by any shape and odd form

2020-06-13 10:51:12 -0600 commented answer Detect all black pixels inside a surrounded closed white area

No, i've add the desired capture area on main post. Also the shape is an example, they can have any shape and odd forms

2020-06-13 08:26:35 -0600 edited question Detect all black pixels inside a surrounded closed white area

Detect all black pixels inside a surrounded closed white area How can i detect black pixels surrounded by closed white p

2020-06-13 08:26:06 -0600 edited question Detect all black pixels inside a surrounded closed white area

Detect all black pixels inside a surrounded closed white area How can i detect black pixels surrounded by closed white p

2020-06-13 08:25:14 -0600 commented answer Detect all black pixels inside a surrounded closed white area

No, i've add the desired capture area on main post.

2020-06-13 08:24:07 -0600 received badge  Editor (source)
2020-06-13 08:24:07 -0600 edited question Detect all black pixels inside a surrounded closed white area

Detect all black pixels inside a surrounded closed white area How can i detect black pixels surrounded by closed white p

2020-06-13 01:27:04 -0600 asked a question Detect all black pixels inside a surrounded closed white area

Detect all black pixels inside a surrounded closed white area How can i detect black pixels surrounded by closed white p