Ask Your Question

StefanCepa995's profile - activity

2020-11-17 16:00:11 -0600 received badge  Student (source)
2020-11-16 15:21:38 -0600 commented answer OpenCV Segmentation of Largest contour

Thank you for clarification. This helped me a lot.

2020-11-16 15:21:21 -0600 marked best answer OpenCV Segmentation of Largest contour

Hi,

This might be a bit too "general" question, but how do I perform GRAYSCALE image segmentation and keep the largest contour? I am trying to remove background noise (i.e. labels) from breast mammograms, but I am not successful. Here is the original image:

image description

First, I applied AGCWD algorithm (based on paper "Efficient Contrast Enhancement Using Adaptive Gamma Correction With Weighting Distribution") in order to get better contrast of the image pixels, like so: image description

Afterwards, I tried executing following steps: Image segmentation using OpenCV's KMeans clustering algorithm:

enhanced_image_cpy = enhanced_image.copy()
reshaped_image = np.float32(enhanced_image_cpy.reshape(-1, 1))

number_of_clusters = 10
stop_criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 100, 0.1)

ret, labels, clusters = cv2.kmeans(reshaped_image, number_of_clusters, None, stop_criteria, 10, cv2.KMEANS_RANDOM_CENTERS)
clusters = np.uint8(clusters)

Canny Edge Detection:

removed_cluster = 1

canny_image = np.copy(enhanced_image_cpy).reshape((-1, 1))
canny_image[labels.flatten() == removed_cluster] = [0]

canny_image = cv2.Canny(canny_image,100,200).reshape(enhanced_image_cpy.shape)
show_images([canny_image])

Find and Draw Contours:

initial_contours_image = np.copy(canny_image)
initial_contours_image_bgr = cv2.cvtColor(initial_contours_image, cv2.COLOR_GRAY2BGR)
_, thresh = cv2.threshold(initial_contours_image, 50, 255, 0)
contours, hierarchy = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
cv2.drawContours(initial_contours_image_bgr, contours, -1, (255,0,0), cv2.CHAIN_APPROX_SIMPLE)
show_images([initial_contours_image_bgr])

Here is how image looks after I draw 44004 contours:

image description

I am not sure how can I get one BIG contour, instead of 44004 small ones. Any ideas how to fix my approach, or possibly any ideas on using alternative approach to get rid of label in top right corner.

Thanks in advance!

2020-11-16 15:21:21 -0600 received badge  Scholar (source)
2020-11-15 16:06:25 -0600 edited question OpenCV Segmentation of Largest contour

OpenCV Segmentation of Largest contour Hi, This might be a bit too "general" question, but how do I perform GRAYSCALE i

2020-11-15 15:59:51 -0600 asked a question OpenCV Segmentation of Largest contour

OpenCV Segmentation of Largest contour Hi, This might be a bit too "general" question, but how do I perform GRAYSCALE i

2020-10-15 12:38:16 -0600 commented question OpenCV SelectiveSearch Segmentation

Hi! Thanks for your answer. I will try this out ASAP. And to answer your question, I am trying to build R-CNN network. I

2020-10-15 05:55:31 -0600 asked a question OpenCV SelectiveSearch Segmentation

OpenCV SelectiveSearch Segmentation Hi, I am trying to use OpenCV (4.1.2) SelectiveSearch segmentation in order to gene

2019-03-10 11:42:38 -0600 received badge  Enthusiast
2019-03-08 07:21:43 -0600 received badge  Organizer (source)
2019-03-08 07:14:17 -0600 asked a question How to run OpenCV method inside GoLang Project?

How to run OpenCV method inside GoLang Project? I have followed the instructions from this link: https://github.com/hybr

2018-11-28 01:50:18 -0600 commented question Something is wrong with VS2015 C++ Environment when using OpenCV DNN module

I am sorry. I have been so stuck on this problem I did not realize I posted a duplicate question. I apologize it wont ha

2018-11-28 01:38:01 -0600 edited question Something is wrong with VS2015 C++ Environment when using OpenCV DNN module

Something is wrong with VS2015 C++ Environment when using OpenCV DNN module I have a problem that I cannot understand at

2018-11-28 01:11:48 -0600 asked a question Something is wrong with VS2015 C++ Environment when using OpenCV DNN module

Something is wrong with VS2015 C++ Environment when using OpenCV DNN module I have a problem that I cannot understand at

2018-11-26 08:32:08 -0600 asked a question CNN model does not load inside Visual Studio 2017 using dnn.readNetFromTensorflow

CNN model does not load inside Visual Studio 2017 using dnn.readNetFromTensorflow Hello everyone! I have created a simpl

2018-11-23 07:54:39 -0600 commented question Running forward() method from opencv dnn module gives wrong predictions

I found a script online which freezes model into .pb file. I created load_graph in order to read that .pb file and I tes

2018-11-23 06:12:31 -0600 commented question Running forward() method from opencv dnn module gives wrong predictions

@dkurt Sadly I am not allowed to upload any of the data since this is a project from work. @berak both inputs to tf and

2018-11-22 03:53:51 -0600 received badge  Editor (source)
2018-11-22 03:53:51 -0600 edited question Running forward() method from opencv dnn module gives wrong predictions

Running forward() method from opencv dnn module gives wrong predictions Hello everyone! I am trying to load pretrained C

2018-11-22 03:44:56 -0600 commented question Running forward() method from opencv dnn module gives wrong predictions

Thank you for quick reply. I will do that right away!

2018-11-22 03:16:26 -0600 asked a question Running forward() method from opencv dnn module gives wrong predictions

Running forward() method from opencv dnn module gives wrong predictions Hello everyone! I am trying to load pretrained C