本文整理汇总了Python中Model.Model._get_patients方法的典型用法代码示例。如果您正苦于以下问题:Python Model._get_patients方法的具体用法?Python Model._get_patients怎么用?Python Model._get_patients使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model.Model
的用法示例。
在下文中一共展示了Model._get_patients方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Model
# 需要导入模块: from Model import Model [as 别名]
# 或者: from Model.Model import _get_patients [as 别名]
from Model import Model
import time
m1 = Model()
start_time = time.time()
m1._get_patients(14,8)
print("--- %s seconds ---" % (time.time() - start_time))
start_time = time.time()
m1._procrustes_analysis(m1.Patients)
print("--- %s seconds ---" % (time.time() - start_time))
start_time = time.time()
[evals,evecs,num] = m1._PCA(m1.Patients)
print("--- %s seconds ---" % (time.time() - start_time))
m1 = Model()
m1._get_patients(14)
start_time = time.time()
m1._procrustes_analysis(m1.Patients)
print("--- %s seconds ---" % (time.time() - start_time))
mean_shape = m1._get_mean_shape(m1.Patients)
[evals,evecs,num] = m1._PCA(m1.Patients)
tot = sum(evals)
ratio_s = evals / tot
test = np.dot(evecs,_all_teeths.T)
plot(test[:,0])
m1._weight_matrix(m1.Patients)
[a,b]=m1.Patients[1]._alignment_parameters(m1.Patients[2],m1.weight_matrix_)
示例2: __init__
# 需要导入模块: from Model import Model [as 别名]
# 或者: from Model.Model import _get_patients [as 别名]
class ModelFitter:
file_in = 'C:/Users/tangc/Documents/ComVi/_Data/Radiographs/extra/20.tif'
def __init__(self):
# Loc is the initial location of Active Shape Model
# Loc can be given by class Locator (automatic initialisation)
# Loc can also be given by manual initialization (mouse input)
self.loc = []
#file_in = image
self.img = []
self.model = Model()
self.model._get_patients(14,8)
def add_graph(self):
#
img = cv2.imread(self.file_in)
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
# Clahe parameters were adjusted manually.
clahe = cv2.createCLAHE(clipLimit=8.0, tileGridSize=(25,25))
cl1=clahe.apply(gray)
blur = cv2.GaussianBlur(cl1,(3,3),0)
blur = cv2.bilateralFilter(blur, 2, 20, 20)
sobelx = cv2.Sobel(blur,cv2.CV_64F,1,0,ksize=3)
sobely = cv2.Sobel(blur,cv2.CV_64F,0,1,ksize=3)
absY = cv2.convertScaleAbs(sobely)
absX = cv2.convertScaleAbs(sobelx)
dst = cv2.addWeighted( absX, 0.5, absY, 0.5,0)
self.img = dst
#def onclick(self,event):
# if event.xdata != None and event.ydata != None:
# print(event.xdata, event.ydata)
#
#def on_click(self):
# im = plt.imread(self.file_in)
# self.onclick()
# cid = fig.canvas.mpl_connect('button_press_event', self.onclick)
# plt.show()
#
def init_shape(self):
init_shape = self.model._get_mean_shape(self.model.Patients)
return init_shape
#def __produce_gradient_image(self):
# gray = cv2.cvtColor(self.img,cv2.COLOR_BGR2GRAY)
# clahe = cv2.createCLAHE(clipLimit=8.0, tileGridSize=(25,25))
# cl1=clahe.apply(gray)
# blur = cv2.GaussianBlur(cl1,(3,3),0)
# blur = cv2.bilateralFilter(blur, 2, 20, 20)
# sobelx = cv2.Sobel(blur,cv2.CV_64F,1,0,ksize=3)
# sobely = cv2.Sobel(blur,cv2.CV_64F,0,1,ksize=3)
# absX = cv2.convertScaleAbs(sobelx)
# absY = cv2.convertScaleAbs(sobely)
# dst = cv2.addWeighted( absX, 0.5, absY, 0.5,0)
# cv2.imshow('Result', dst)
# return dst
def image_fitting(self,loc,k,ns,loop_num):
# loop_num is the loop number for fitting process
img = cv2.imread(self.file_in)
clone = img.copy()
cv2.namedWindow("Fitting Window", cv2.WINDOW_AUTOSIZE)
small = cv2.resize(clone, (0,0), fx=0.3, fy=0.3)
cv2.imshow( "Fitting Window", small )
cv2.waitKey(1)
os.chdir("C:/Users/tangc/Documents/ComVi/ASM")
shape_datas = pickle.load( open( "save.p", "rb" ) )
_evals_shape = shape_datas[0]
_evecs_shape = shape_datas[1]
#_num_shape = shape_datas[0]
_grey_mean,_grey_evals,_grey_evecs = self.model.greyscale_PCA(k)
_init_shape = self.init_shape()
_centroid = np.mean(_init_shape.Teeth, axis=0)
_dist_x = _centroid[0] - loc[0]
_dist_y = _centroid[1] - loc[1]
_init_shape.Teeth[:,0] = _init_shape.Teeth[:,0] - _dist_x
_init_shape.Teeth[:,1] = _init_shape.Teeth[:,1] - _dist_y
init_mean_Teeth = np.copy(_init_shape.Teeth)
for i in range(loop_num):
_init_shape.get_normal_to_teeth()
_Normals = _init_shape.Normals
l = k + ns
_init_shape.alter_get_profile_and_Derivatives(l,self.file_in)
f=np.zeros(shape=(ns*2+1,3200))
for j in range(3200):
for n in range(ns*2+1):
gi=np.zeros(shape=(2*k+1,1))
gi = _init_shape.profiles[n:17+n,j]
bc = np.dot(_grey_evecs[j],(gi-_grey_mean[j]))
bc = bc/np.sqrt(_grey_evals[j])
f[n,j]=np.sum(bc**2)
temp = np.amin(f, axis=0)
_idx = np.argmin(f, axis=0)
movement = (_idx-1)-ns
_init_shape.Teeth[:,0] = _init_shape.Teeth[:,0] + movement*_Normals[:,0]
_init_shape.Teeth[:,1] = _init_shape.Teeth[:,1] + movement*_Normals[:,1]
clone = img.copy()
for s in range(8):
#_pointx = _init_shape.Teeth[s,0].astype('int')
#.........这里部分代码省略.........