Ask Your Question

XTSR's profile - activity

2020-11-25 08:02:55 -0600 received badge  Famous Question (source)
2020-02-14 01:57:58 -0600 received badge  Notable Question (source)
2020-02-14 01:57:58 -0600 received badge  Notable Question (source)
2019-11-20 21:59:36 -0600 received badge  Popular Question (source)
2019-01-03 00:27:29 -0600 marked best answer zero center normalization image

Hello, I need to normalize an image using zero center normalization. How to do it in OpenCV?

2019-01-03 00:09:34 -0600 asked a question zero center normalization image

zero center normalization image Hello, I need to normalize an image using zero center normalization. How to do it in Ope

2018-12-27 01:47:42 -0600 asked a question Is there a way I can remove these unwanted parts in a grayscale image?

Is there a way I can remove these unwanted parts in a grayscale image? Hello, I am a beginner in OpenCV and I am trying

2018-12-02 21:36:14 -0600 commented answer merge overlapping rectangles

thank you! it works great. i thought i needed grouprectangles() for it, i overlooked the problem a bit much but i learne

2018-12-02 19:57:49 -0600 commented answer merge overlapping rectangles

oh ok, here are some images

2018-12-02 19:57:19 -0600 commented answer merge overlapping rectangles

oh ok, here are some images. images

2018-12-02 19:56:52 -0600 commented answer merge overlapping rectangles

oh ok, here are some images. images

2018-12-02 18:57:17 -0600 commented answer merge overlapping rectangles

with the same problems such as the one on the post?

2018-12-02 16:44:52 -0600 marked best answer merge overlapping rectangles

Hello, I am new to OpenCV and I have been trying to detect WBCs. So far, so good but I encountered a problem. There are cells where they are not detected as one and it causes to draw 2 rectangles instead of just one. How can I merge the overlapping rectangles? I found out that OpenCV have a groupRectangles function, can this solve my problem and how do I use it (I can't find an example)? I am using Python 3.7.

Here is the output image of my code: output image of my code

Here is my code:

import cv2
import numpy as np

limit_area = 1000   
x = 0   
y = 0   
w = 0   
h = 0   
nuclei = []   
count = 0   
number_name = 1   

img = cv2.imread('7.bmp')
img = cv2.add(img, 0.70)
img_hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)   
mask1 = cv2.inRange(img_hsv, (90,90,0), (255,255,255))  
mask2 = cv2.inRange(img_hsv, (70,100,0), (255,255,255)) 
mask = mask1 + mask2  
kernel = np.ones((1,3),np.uint8)  
mask = cv2.dilate(mask,kernel,iterations = 2)   
mask = cv2.morphologyEx(mask, cv2.MORPH_OPEN, kernel)  
mask_blur = cv2.medianBlur(mask,5)  
canny = cv2.Canny(mask_blur, 100,300,3) 
im2, contours, hierarchy = cv2.findContours(canny,cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_SIMPLE)  

for cnt in contours:   
    if cv2.contourArea(cnt) >= limit_area:   
        nuclei.append(cnt)
        print(cv2.contourArea(cnt))
        x, y, w, h = cv2.boundingRect(cnt)
        cv2.rectangle(img, (x, y), (x+w, y+h), (0,255,0), 7)

cv2.imshow('img', img)
cv2.waitKey(0)
cv2.destroyAllWindows()
2018-12-02 16:44:52 -0600 received badge  Scholar (source)
2018-12-02 16:44:30 -0600 commented answer merge overlapping rectangles

is there a way i can determine the value of epsilon to use on an image? and can i also make the rectangle larger? i need

2018-12-02 16:41:41 -0600 received badge  Supporter (source)
2018-12-02 09:02:23 -0600 received badge  Student (source)
2018-12-02 08:30:12 -0600 commented answer merge overlapping rectangles

i got the points now, what could i do with the points?

2018-12-02 02:15:22 -0600 asked a question merge overlapping rectangles

merge overlapping rectangles Hello, I am new to OpenCV and I have been trying to detect WBCs. So far, so good but I enco