1

This is the kind of image that I have: enter image description here

Another example: enter image description here

now the ground truth: enter image description here enter image description here

I need a code to get the results similar to the ground truth algorithm, any idea and suggestion will help me because I don't even know where to start, thanks.

João
  • 175
  • 1
  • 2
  • 10

1 Answers1

1
import cv2 as cv
from matplotlib import pyplot as plt

# Load image in grayscale
img = cv.imread('coins.png',0)

# threshold the image
thresh = cv.threshold(img,0,255,cv.THRESH_BINARY_INV+cv.THRESH_OTSU)[1]

# display the image
plt.imshow(thresh, cmap = 'gray', interpolation = 'bicubic')
plt.xticks([]), plt.yticks([])  # to hide tick values on X and Y axis
plt.show()

refer this example

one
  • 2,205
  • 1
  • 15
  • 37