2017-03-06 80 views
2

我有下面的圖片是胰腺細胞enter image description here如何使用matlab正確地鑲嵌細胞圖像?

的照片,我想什麼做的是能夠得到每個細胞(紅色長絲)的膜,然後做一個細分,以得到一個想法長絲的長度。 到目前爲止,我曾嘗試使用MATLAB的網站上給出的例子,但結果是不是真的好...

I = imread('picture.tiff'); 
I_gray = rgb2gray(I); 
[~, threshold] = edge(I_gray, 'sobel'); 
fudgeFactor = .5; 
BWs = edge(I_gray,'sobel', threshold * fudgeFactor); 
se90 = strel('line', 3, 90); 
se0 = strel('line', 3, 0); 
BWsdil = imdilate(BWs, [se90 se0]); 

enter image description here

我一直在尋找了幾個小時等方式做到這一點,但沒有任何滿意的結果...有沒有辦法做到這一點?也許除matlab之外的其他軟件可能更高效。先謝謝您!

+2

幾個小時?只* *小時*?所以,你想實現一個研究水平的方法來自動分割細胞,你搜索*小時*?我的意思是,人們有4年的博士學位才​​能正確地做這件事。你的第一步應該是一個圖像處理書/課程。 –

+2

長絲似乎很紅,如果我是你,我會嘗試利用這些信息。 – UJIN

+0

我知道這很複雜,我不會給我個人的情況,但是我正在研究的這個項目是我博士學位(我是物理學家,而不是生物學家)的一個側面項目部分,我沒有太多時間專注於。我試圖使用這樣一個事實,即燈絲非常紅,但它永遠不會結束那麼好... – Hyppolite

回答

3

我不知道任何關於單元格或鑲嵌或其他任何東西。但是如果你想在非統一背景中檢測到這些斑點,那麼我可能會提供幫助。由於背景不均勻,您需要單獨分析這些斑點。您不能只設置一個固定閾值來一次檢測所有斑點。首先,您將分別檢測每個斑點,然後使用單個閾值。這裏是例子

原始圖像

im=imread('gxGkH.jpg'); 
figure,imagesc(im);axis image; 

enter image description here

我只選擇藍色,分析

imb=im(:,:,3); 
figure,imagesc(imb);axis image; 

enter image description here

1)模糊化圖像,因爲模糊的斑點後會有在其中心

sigma=7; 
kernel = fspecial('gaussian',4*sigma+1,sigma); 
im2=imfilter(imb,kernel,'symmetric'); 

figure,imagesc(im2);axis image; 

enter image description here

2)局部 最大值/最小值使用分水嶺變換來分隔每個斑區域

% L = watershed(im2); 
L = watershed(max(im2(:))-im2); 
[x,y]=find(L==0); 

繪製邊界

figure,imagesc(im2),axis image 
hold on, plot(y,x,'r.') 

enter image description here

3)在這裏,我單獨分析每個斑,找到一個大津閾值 各一滴,然後我發現了斑點,並結合所有檢測

tmp=zeros(size(imb)); 

for i=1:max(L(:)) 
    ind=find(L==i); 
    mask=L==i; 
    [thr,metric] =multithresh(imb(ind),1); 
    if metric>0.7 
    tmp(ind)=imb(ind)>thr; 
    end 
end 

刪除一些噪音

tmp=imopen(tmp,strel('disk',1)); 
figure,imagesc(tmp),axis image 

enter image description here

如果背景具有較高的對比度,那麼斑點,那麼你將不需要在分水嶺變換中反轉圖像。

2

我不確定這是否會讓你更接近問題的解決方案,但是我會做的就是這樣。你要知道,這是一個非常簡單和原始的方法:

image = imread('picture.tiff'); % load image 
image = rgb2hsv(image); % convert to hsv colorspace 
image = image(:,:,1); % take the hue channel 

binary_im = imbinarize(image); % make binary image 

二進制圖像看起來應該是這樣:

enter image description here

現在你可以使用數學形態學的噪音消除。首先創建一個結構化元素,然後你用二進制圖像卷積它:

現在
str_el = strel('disk', 5, 0); % create a round, 5px radius, str_el 
closed_im = imclose(binary_im, str_el); % close image with str_el 

你的新形象應該是這樣的:

enter image description here

在這一點上,你可以用另一種形態操作該發現骨架:

skeleton = bwmorph(closed_im, 'skel', Inf); % Find skeleton image 

的骨幹圖像應該是這樣的:

enter image description here

當然,這種方法是遠遠準確,但可以給你長絲長度的整體信息,特別是如果你能擺脫最終的噪聲(骨架的附錄)。

+0

這確實不準確,但因爲我可以重複處理大量圖像,所以可能就足夠了。我會努力的!非常感謝你 ! – Hyppolite