我将MRI图像按3D阵列形状(2D和切片)分组,这些图像来自不同的机器,因此空间分辨率彼此不同,我想动态地从所有机器中削减ROI。
切割将取决于对圆的检测,这是我感兴趣的点(圆的半径和形状因切片而异,因为它代表心脏的运动)。为此,我正在尝试:
此方法的问题是:在距我的兴趣点较远的位置检测到一些圆圈,这将严重影响均值。如您在代码下的图像中所见。
是否有任何解决方案(无需详尽计算协方差矩阵)以排除这个过分的点?
#============================================
def processImage(img,kernel_size):
#gray = cv.cvtColor(img, cv2.COLOR_BGR2GRAY)
#blur = cv.GaussianBlur(img, (kernel_size,kernel_size), 0)
thresh = cv.adaptiveThreshold(img,255,cv.ADAPTIVE_THRESH_GAUSSIAN_C, cv.THRESH_BINARY,11,2)
blur = cv.GaussianBlur(thresh, (kernel_size,kernel_size), 0)
#thresh = cv.Canny(blur, 50, 150)
return blur
#--------------------------------------------
#============================================
def locateCenters(self,img,ker_sz):
# define circles center & initialization
centers = np.array([[90,120]],dtype=int)
# loop all the slices
for idx in range(img.shape[2]):
#convert the pixels to uint8
imag = img[:,:,idx].astype('uint8')
# PreProcessing for Images
img_pro = ROI.processImage(imag,ker_sz)
# Detecting circles
circles = cv.HoughCircles(img_pro,cv.HOUGH_GRADIENT,1,10, param1=40,param2=50,minRadius=10,maxRadius=35)
# check wrther if there is circles or not
if circles is not None :
circles = np.uint16(np.around(circles))
#print(circles[0,:])
for i in circles[0,:]:
centers = np.append(centers, [[i[0],i[1]]],axis = 0).astype(int)
center = np.mean(centers,axis=0,dtype=np.int)#.reshape(1,2)
print("Center ",center,"\nCenters:",centers.shape)
x,y = center
return x,y
#--------------------------------------------
解决方案是拍摄4D图像(3D +时间)并使用标准偏差来定位心脏(因为心脏始终在移动)。