'How to color the circles on a thresholded image in python
I created a code to isolate big circles (white) and I would like to color those circles and create contours on the thresholded image to calculate area.
The thing is the threshold image is a binary image 8uint. How can do that in a binary imagee ?
Thanks for the help
import os
#from skimage import measure, io, img_as_ubyte
from skimage.color import label2rgb, rgb2gray
from skimage.segmentation import clear_border
import matplotlib.pyplot as plt
import numpy as np
import cv2
import pandas as pd
import sys
import glob
original = cv2.imread('D:/2022/Python program/NBC_new2022_/images/image1.jpg',-1)
original = cv2.resize(original, (864, 648)) #resize of original image
img = cv2.cvtColor(original, cv2.COLOR_BGR2GRAY)
median = cv2.medianBlur(img, 3)
ret, th = cv2.threshold(median, 0, 255, cv2.THRESH_BINARY+cv2.THRESH_OTSU)
kernel = np.ones((9,9), np.uint8)
opening = cv2.morphologyEx(th, cv2.MORPH_OPEN, kernel)
edge_touching_removed = clear_border(opening)
cv2.imshow('original', original)
cv2.imshow("Theshrold image", edge_touching_removed)
cv2.waitKey(0)
cv2.destroyAllWindows()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
