2016-12-16 11 views
0

많은 이미지 데이터를 계량하려고합니다. 각 이미지에는 세포와 핵이 있습니다. 개략적 인 형태로 표현해야할 것에 "나는 필요"있는 그대로 : 내가 가지고있는유역, skikit 이미지를 사용하여 셀과 핵의 개수를 계산합니다.

raw image

: 예 이미지가 "원시 이미지"에 표시됩니다

what I need

세포 수를 세는 온라인 유역 알고리즘 프로그램을 발견했지만 셀 안의 (그리고 바깥 쪽) 핵수를 세지 못했습니다. 여기

은 I 화상으로부터 원시 세포 수를 계산하는 데 사용 프로그램

#import packages 

import numpy as np 
import matplotlib.pyplot as plt 
from skimage import io, color, filters as filters 
from scipy import ndimage 
from skimage.morphology import watershed 
from skimage.feature import peak_local_max 
from skimage.measure import regionprops, label 
import numpy as np 
from scipy.ndimage import gaussian_filter 
import matplotlib.pyplot as plt 
from skimage import data 
from skimage import img_as_float 
from skimage.morphology import reconstruction 
import skimage 
from skimage import segmentation 

%matplotlib inline 
import matplotlib 
#import image 
from IPython.core.display import Image 

Image(filename=('/Users/sasi/Desktop/image1.jpeg')) 

# Find number of cells 

image = color.rgb2gray(io.imread('/Users/sasi/Desktop/image1.jpeg')) 
image = image < filters.threshold_otsu(image) 
distance = ndimage.distance_transform_edt(image) 
local_maxi = peak_local_max(distance, indices=False, footprint=np.ones((3, 3)), labels=image) 

markers, num_features = ndimage.label(local_maxi) 
labels = watershed(-distance, markers, mask=image) 
regions = regionprops(labels) 
regions = [r for r in regions if r.area > 60] 

print('Number of cells:', len(regions) - 1) 

가 어떻게 화상 전체 핵의 세포 내부 핵도 수를 카운트한다입니까? 세포를 계산하는 또 다른 좋은 프로그램이라면 알려주세요.

답변

0
import cv2 
    import numpy as np 
    from skimage.feature import peak_local_max 
    from skimage.morphology import watershed 
    from scipy import ndimage 

    image=cv2.imread("Da0003.jpg") 
    gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) 
    sigma=2 
    gauss_img = cv2.GaussianBlur(gray_image,(0,0),1.6*sigma,0) 
    main_img = cv2.GaussianBlur(gray_image,(0,0),sigma,0) 
    ret,threshold_img = cv2.threshold(main_img,127,255,cv2.THRESH_BINARY) 
    threshold=cv2.bitwise_not(threshold_img) 
    D = ndimage.distance_transform_edt(threshold) 
    localMax = peak_local_max(D, indices=False, min_distance=10, 
     labels=threshold) 

    markers = ndimage.label(localMax, structure=np.ones((3, 3)))[0] 
    labels = watershed(-D, markers, mask=threshold) 
    for label in np.unique(labels): 
     # if the label is zero, we are examining the 'background' 
     # so simply ignore it 
      if label == 0: 
       continue 

      # otherwise, allocate memory for the label region and draw 
      # it on the mask 
      x,y,_=image.shape 
      image_copy=image 
      mask = np.zeros((x,y), dtype="uint8") 
      mask[labels == label] = 255 


      cnts = cv2.findContours(mask.copy(), cv2.RETR_EXTERNAL, 
       cv2.CHAIN_APPROX_SIMPLE)[-2] 
      c = max(cnts, key=cv2.contourArea) 

      cv2.drawContours(image_copy, [c], -1, (0, 255, 255), 1) 
      #print(label) 

    cv2.imwrite("_watershead"+".jpg", image_copy) 
    print("count:"+str(label))