使用Python OpenCV测量微小颗粒的费雷特直径

问题描述

我正在尝试使用Python OpenCV2测量沉积在玻璃上的微小颗粒的费雷特直径。目前,我有近150张图像需要自动执行此过程。为了进行测量,我编写了以下Python脚本:

import cv2
import numpy as np
import matplotlib.pyplot as plt
from skimage import io,color,measure

##step-1 reading the image
img = cv2.imread('1.tif',0)
pixel_2_micron = 1.75 #1 pixel is equal too 1.75 microns
#img = color.rgb2gray(io.imread('1.tif',0))

##step-2 selecting required region if necessary
cropped_img = img[0:1422,:]
#plt.hist(img.flat,bins=100,range=(0,255))
ret,thresh = cv2.threshold(cropped_img,162,217,cv2.THRESH_BINARY)

#Step-3
kernel = np.ones((3,3),np.uint8)
eroded = cv2.erode(thresh,kernel,iterations = 1)
dilated = cv2.dilate(eroded,iterations = 1)
#cv2.imshow("Original Image",img)
#cv2.imshow("Threshold Image",thresh)
#cv2.imshow("Eroded Image",eroded)
#cv2.imshow("Dilated Image",dilated)
#cv2.waitKey(0)

#step-4

mask = thresh == 217
io.imshow(mask) #show the masked image 

请协助我测量遮罩区域的尺寸。尤其是所有遮盖区域的费雷直径。

我已经附上了遮盖了颗粒的图像。

Binary image consisting of particles that have been masked

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...