# Revision history [back]

### background color affecting contour detection

I have been successful in detecting contours and drawing those back on the original image.

Here is my original image:

Portion of Python script where I detect contours:

image = cv2.imread("/Users/donaldkeidel/Downloads/input_template_masked.jpg")
# grayscale the image
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
# apply a Gaussian blur
blur = cv2.GaussianBlur(gray, (3, 3), 0)
# threshold the image
(t, binary) = cv2.threshold(blur, 100, 255, cv2.THRESH_BINARY)
# find contours
(_, contours, _) = cv2.findContours(binary, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
image_cropped_contoured_drawn = cv2.drawContours(image.copy(), contours, -1, (0, 255, 0), 3)


Here is the output image:

As you can see in the image, almost all the contours were captured where the background color is a lighter gray. However, where the background is an almost black in the middle of the image, less contours were detected.

Is there some techniques that can be applied to detect more of these contours? I played with the threshold value and found that 100 works the best. I also used a few other values for the parameters in the GaussianBlur method.

Thank you.

### background color affecting contour detection

I have been successful in detecting contours and drawing those back on the original image.

Here is my original image:

Portion of Python script where I detect contours:

image = cv2.imread("/Users/donaldkeidel/Downloads/input_template_masked.jpg")
# grayscale the image
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
# apply a Gaussian blur
blur = cv2.GaussianBlur(gray, (3, 3), 0)
# threshold the image
(t, binary) = cv2.threshold(blur, 100, 255, cv2.THRESH_BINARY)
# find contours
(_, contours, _) = cv2.findContours(binary, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
image_cropped_contoured_drawn = cv2.drawContours(image.copy(), contours, -1, (0, 255, 0), 3)


Here is the output image:

As you can see in the image, almost all the contours were captured where the background color is a lighter gray. However, where the background is an almost black in the middle of the image, less contours were detected.

Is there some techniques that can be applied to detect more of these contours? I played with the threshold value and found that 100 works the best. I also used a few other values for the parameters in the GaussianBlur method.

I could not get my images into this document so I uploaded them and provided links.

Thank you.

### background color affecting contour detection

I have been successful in detecting contours and drawing those back on the original image.

Here is my original image:

Portion of Python script where I detect contours:

image = cv2.imread("/Users/donaldkeidel/Downloads/input_template_masked.jpg")
# grayscale the image
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
# apply a Gaussian blur
blur = cv2.GaussianBlur(gray, (3, 3), 0)
# threshold the image
(t, binary) = cv2.threshold(blur, 100, 255, cv2.THRESH_BINARY)
# find contours
(_, contours, _) = cv2.findContours(binary, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
image_cropped_contoured_drawn = cv2.drawContours(image.copy(), contours, -1, (0, 255, 0), 3)


Here is the output image:

As you can see in the image, almost all the contours were captured where the background color is a lighter gray. However, where the background is an almost black in the middle of the image, less contours were detected.

Is there some techniques that can be applied to detect more of these contours? I played with the threshold value and found that 100 works the best. I also used a few other values for the parameters in the GaussianBlur method.

I could not get my images into this document so I uploaded them and provided links.

Thank you.

### background color affecting contour detection

I have been successful in detecting contours and drawing those back on the original image.

Here is my original image:

Portion of Python script where I detect contours:

image = cv2.imread("/Users/donaldkeidel/Downloads/input_template_masked.jpg")
# grayscale the image
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
# apply a Gaussian blur
blur = cv2.GaussianBlur(gray, (3, 3), 0)
# threshold the image
(t, binary) = cv2.threshold(blur, 100, 255, cv2.THRESH_BINARY)
# find contours
(_, contours, _) = cv2.findContours(binary, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
image_cropped_contoured_drawn = cv2.drawContours(image.copy(), contours, -1, (0, 255, 0), 3)


Here is the output image:

As you can see in the image, almost all the contours were captured where the background color is a lighter gray. However, where the background is an almost black in the middle of the image, less contours were detected.

Is there some techniques that can be applied to detect more of these contours? I played with the threshold value and found that 100 works the best. I also used a few other values for the parameters in the GaussianBlur method.

I could not get my images into this document so I uploaded them and provided links.

Thank you.

### background color affecting contour detection

I have been successful in detecting contours and drawing those back on the original image.

Here is my original image:

Portion of Python script where I detect contours:

image = cv2.imread("/Users/donaldkeidel/Downloads/input_template_masked.jpg")
# grayscale the image
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
# apply a Gaussian blur
blur = cv2.GaussianBlur(gray, (3, 3), 0)
# threshold the image
(t, binary) = cv2.threshold(blur, 100, 255, cv2.THRESH_BINARY)
# find contours
(_, contours, _) = cv2.findContours(binary, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
image_cropped_contoured_drawn = cv2.drawContours(image.copy(), contours, -1, (0, 255, 0), 3)


Here is the output image:

As you can see in the image, almost all the contours were captured where the background color is a lighter gray. However, where the background is an almost black in the middle of the image, less contours were detected.

Is there some techniques that can be applied to detect more of these contours? I played with the threshold value and found that 100 works the best. I also used a few other values for the parameters in the GaussianBlur method.

I could not get my images into this document so I uploaded them and provided links.

Thank you.

### background color affecting contour detection

I have been successful in detecting contours and drawing those back on the original image.

Here is my original image:

Portion of Python script where I detect contours:

image = cv2.imread("/Users/donaldkeidel/Downloads/input_template_masked.jpg")
# grayscale the image
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
# apply a Gaussian blur
blur = cv2.GaussianBlur(gray, (3, 3), 0)
# threshold the image
(t, binary) = cv2.threshold(blur, 100, 255, cv2.THRESH_BINARY)
# find contours
(_, contours, _) = cv2.findContours(binary, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
image_cropped_contoured_drawn = cv2.drawContours(image.copy(), contours, -1, (0, 255, 0), 3)


Here is the output image:

As you can see in the image, almost all the contours were captured where the background color is a lighter gray. However, where the background is an almost black in the middle of the image, less contours were detected.

Is there some techniques that can be applied to detect more of these contours? I played with the threshold value and found that 100 works the best. I also used a few other values for the parameters in the GaussianBlur method.

I could not get my images into this document so I uploaded them and provided links.

Thank you.

### background color affecting contour detection

I have been successful in detecting contours and drawing those back on the original image.

Here is my original image:

Portion of Python script where I detect contours:

image = cv2.imread("/Users/donaldkeidel/Downloads/input_template_masked.jpg")
# grayscale the image
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
# apply a Gaussian blur
blur = cv2.GaussianBlur(gray, (3, 3), 0)
# threshold the image
(t, binary) = cv2.threshold(blur, 100, 255, cv2.THRESH_BINARY)
# find contours
(_, contours, _) = cv2.findContours(binary, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
image_cropped_contoured_drawn = cv2.drawContours(image.copy(), contours, -1, (0, 255, 0), 3)


Here is the output image:

As you can see in the image, almost all the contours were captured where the background color is a lighter gray. However, where the background is an almost black in the middle of the image, less contours were detected.

Is there some techniques that can be applied to detect more of these contours? I played with the threshold value and found that 100 works the best. I also used a few other values for the parameters in the GaussianBlur method.

I could not get my images into this document so I uploaded them and provided links.

Thank you.

### background color affecting contour detection

I have been successful in detecting contours and drawing those back on the original image.

Here is my original image:

Portion of Python script where I detect contours:

image = cv2.imread("/Users/donaldkeidel/Downloads/input_template_masked.jpg")
# grayscale the image
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
# apply a Gaussian blur
blur = cv2.GaussianBlur(gray, (3, 3), 0)
# threshold the image
(t, binary) = cv2.threshold(blur, 100, 255, cv2.THRESH_BINARY)
# find contours
(_, contours, _) = cv2.findContours(binary, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
image_cropped_contoured_drawn = cv2.drawContours(image.copy(), contours, -1, (0, 255, 0), 3)


Here is the output image:

As you can see in the image, almost all the contours were captured where the background color is a lighter gray. However, where the background is an almost black in the middle of the image, less contours were detected.

Is there some techniques that can be applied to detect more of these contours? I played with the threshold value and found that 100 works the best. I also used a few other values for the parameters in the GaussianBlur method.

Thank you.

### background color affecting contour detection

I have been successful in detecting contours and drawing those back on the original image.

Here is my original image:

Portion of Python script where I detect contours:

image = cv2.imread("/Users/donaldkeidel/Downloads/input_template_masked.jpg")
# grayscale the image
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
# apply a Gaussian blur
blur = cv2.GaussianBlur(gray, (3, 3), 0)
# threshold the image
(t, binary) = cv2.threshold(blur, 100, 255, cv2.THRESH_BINARY)
# find contours
(_, contours, _) = cv2.findContours(binary, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
image_cropped_contoured_drawn = cv2.drawContours(image.copy(), contours, -1, (0, 255, 0), 3)


Here is the output image:

As you can see in the image, almost all the contours were captured where the background color is a lighter gray. However, where the background is an almost black in the middle of the image, less contours were detected.

Is there some techniques that can be applied to detect more of these contours? I played with the threshold value and found that 100 works the best. I also used a few other values for the parameters in the GaussianBlur method.

Thank you.

### background color affecting contour detection

I have been successful in detecting contours and drawing those back on the original image.

Here is my original image:

Portion of Python script where I detect contours:

image = cv2.imread("/Users/donaldkeidel/Downloads/input_template_masked.jpg")
# grayscale the image
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
# apply a Gaussian blur
blur = cv2.GaussianBlur(gray, (3, 3), 0)
# threshold the image
(t, binary) = cv2.threshold(blur, 100, 255, cv2.THRESH_BINARY)
# find contours
(_, contours, _) = cv2.findContours(binary, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
image_cropped_contoured_drawn = cv2.drawContours(image.copy(), contours, -1, (0, 255, 0), 3)


Here is the output image:

As you can see in the image, almost all the contours were captured where the background color is a lighter gray. However, where the background is an almost black in the middle of the image, less contours were detected.

Is Are there some techniques that can be applied to detect more of these contours? I played with the threshold value and found that 100 works the best. I also used a few other values for the parameters in the GaussianBlur method.

Thank you.

### background color affecting contour detection

I have been successful in detecting contours and drawing those back on the original image.

Here is my original image:

Portion of Python script where I detect contours:

image = cv2.imread("/Users/donaldkeidel/Downloads/input_template_masked.jpg")
# grayscale the image
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
# apply a Gaussian blur
blur = cv2.GaussianBlur(gray, (3, 3), 0)
# threshold the image
(t, binary) = cv2.threshold(blur, 100, 255, cv2.THRESH_BINARY)
# find contours
(_, contours, _) = cv2.findContours(binary, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
image_cropped_contoured_drawn = cv2.drawContours(image.copy(), contours, -1, (0, 255, 0), 3)


Here is the output image:

As you can see in the image, almost all the contours were captured where the background color is a lighter gray. However, where the background is an almost black in the middle of the image, less contours were detected.

Are there some techniques that can be applied to detect more of these contours? I played with the threshold value and found that 100 works the best. I also used a few other values for the parameters in the GaussianBlur method.

Thank you.

Update:

I applied equalizeHist by doing the following:

image = cv2.imread("/Users/donaldkeidel/Downloads/input_template_masked.jpg")
# grayscale the image
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
# Histogram equalization
equ = cv2.equalizeHist(gray)
# threshold the image
(t, binary) = cv2.threshold(equ, 100, 255, cv2.THRESH_BINARY)
# find contours
(_, contours, _) = cv2.findContours(binary, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
image_cropped_contoured_drawn = cv2.drawContours(image.copy(), contours, -1, (0, 255, 0), 3)