如何在MATLAB中计算环的半径?

4

我有一堆皮质骨图像,高分辨率且二值化。我该如何计算每个图像的平均内径和外径?以下是需要处理的图像示例:


我首先计算了白色像素在x和y方向上的质心。我认为我需要这个来计算中心和骨头内外周之间的距离。 - my MDB
1个回答

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


非常感谢您的快速回复和详细解答。 - my MDB

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接