I have an image with components, i have created a mask and extracted red colored regions out of it, then applied some inpainting on the components with some threshold size of component... but when i apply cv2.inpaint, it leaves some marks of red color behind.... i am not sure why... Here is the code.
lower_red = np.array([0,220,0]) #lower red color limit
upper_red = np.array([100,255,255]) # upper limit
mask = cv2.inRange(hsv,lower_red,upper_red) # masking red colored areas
nb_components, output, stats, centroids = cv2.connectedComponentsWithStats(mask, 8) # finding components
sizes = stats[1:, -1]; nb_components = nb_components - 1 # getting areas of each component
min_size = 800 # threshold of component size
inpaint_mask = np.zeros((output.shape))
for i in range(0, nb_components):
if sizes[i] <= min_size:
inpaint_mask[output == i + 1] = 255
inpaint_mask = inpaint_mask.astype('uint8')
dst = cv2.inpaint(src = rgb,inpaintMask=inpaint_mask,inpaintRadius=10, flags = cv2.INPAINT_TELEA)
plt.figure(figsize=(20,20),dpi=80)
plt.imshow(dst)
Here is the input image:
Output image:


