Wednesday, 13 February 2019

Measuring SEM Image using Opencv

I have about 30 SEM (scanning-electron microscope) images like that:

enter image description here

What you see is photoresist pillars on a glass substrate. What I would like to do, is to get the mean diameter in x and y-direction as well as the mean period in x- and y-direction.

Now, instead of doing all the measurement manually, I was wondering, if maybe there is a way to automate it using python and opencv ?

EDIT: I tried the following code, it seems to be working to detect circles, but what I actually need are ellipse, since I need the diameter in x- and y-direction.

... and I don't quite see how to get the scale yet ?

import numpy as np
import cv2
from matplotlib import pyplot as plt

img = cv2.imread("01.jpg",0)
output = img.copy()

edged = cv2.Canny(img, 10, 300)
edged = cv2.dilate(edged, None, iterations=1)
edged = cv2.erode(edged, None, iterations=1)



# detect circles in the image
circles = cv2.HoughCircles(edged, cv2.HOUGH_GRADIENT, 1.2, 100)


# ensure at least some circles were found
if circles is not None:
    # convert the (x, y) coordinates and radius of the circles to integers
    circles = np.round(circles).astype("int")

    # loop over the (x, y) coordinates and radius of the circles
    for (x, y, r) in circles[0]:
        print(x,y,r)
        # draw the circle in the output image, then draw a rectangle
        # corresponding to the center of the circle
        cv2.circle(output, (x, y), r, (0, 255, 0), 4)
        cv2.rectangle(output, (x - 5, y - 5), (x + 5, y + 5), (0, 128, 255), -1)

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

enter image description here

Source of inspiration: https://www.pyimagesearch.com/2014/07/21/detecting-circles-images-using-opencv-hough-circles/



from Measuring SEM Image using Opencv

No comments:

Post a Comment