0

I have MRI images grouped in 3D array shape(2D and slices) the images come from different machines so the spatial resolution is different from one to another, I do like to cut a ROI from all of them dynamically.

The cut will be depending on the detection of the circle which is my point of interest (the radius and the shape of the circle varies from slice to another because it represents the heart movement). to do that I'm trying to:

  1. locate the centers of all detected circles.
  2. get the mean of all of the circles centers.

The problem in this approach is that: there is some detected circles far from my point of interest which will affect the mean badly.As you can see in the image under the code.

Is there any solution(without exhaustive computation of covariance matrix) to exclude this drastic points ?

MRI with different circles Original image

#============================================
 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
 #--------------------------------------------
Bilal
  • 3,191
  • 4
  • 21
  • 49

1 Answers1

1

The solution was to take the 4D Image (3D + time) and use standard deviation to locate the heart(since it's moving always).

Bilal
  • 3,191
  • 4
  • 21
  • 49