2015-02-09 83 views
4

我有一堆皮質骨圖像,高分辨率和二值化。我如何去計算每個圖像的平均內徑和外徑?以下是圖像的種類,我需要處理的一個例子: 如何計算MATLAB環的半徑?

+0

我開始通過計算在x和y方向上的白色像素的質心。我想我需要這個來計算中心與骨骼內外周之間的距離。 – 2015-02-09 10:25:21

回答

3

這可能是一個辦法 -

%// Read in image and conert to binary 
im = im2bw(imread('http://s9.postimg.org/aew1l7tvz/4_COPY_copy.png')); 
figure, imshow(im), title('Original Image') 

%// Fill holes giving us the "outer blob" 
outer_blob = imfill(im,'holes'); 
outer_blob = biggest_blob(outer_blob); %// remove noise 
figure, imshow(outer_blob), title('Outer Blob') 

%// Get the inner filled blob by "removing" the original image from outer blob 
inner_blob = outer_blob & ~im; 
inner_blob = biggest_blob(inner_blob); %// remove noise 
figure, imshow(inner_blob), title('Inner Blob') 

%// Find the equivalent/mean inner and outer radii 
inner_dia = regionprops(inner_blob,'Equivdiameter'); 
inner_radius = inner_dia.EquivDiameter/2 

outer_dia = regionprops(outer_blob,'Equivdiameter'); 
outer_radius = outer_dia.EquivDiameter/2 

相關的功能碼 -

function out = biggest_blob(BW) 

%// Find and labels blobs in the binary image BW 
[L, num] = bwlabel(BW, 8); 

%// Count of pixels in each blob, basically this should give the area of each blob 
counts = sum(bsxfun(@eq,L(:),1:num)); 

%// Get the label(ind) cooresponding to blob with the maximum area 
%// which would be the biggest blob 
[~,ind] = max(counts); 

%// Get only the logical mask of the biggest blob by comparing all labels 
%// to the label(ind) of the biggest blob 
out = (L==ind); 

return; 

代碼運行和調試圖片 -

inner_radius = 
    211.4740 
outer_radius = 
    267.8926 

enter image description here

enter image description here

enter image description here

+0

非常感謝您的快速回復和詳細解答。 – 2015-02-10 09:46:04