20060610-Determining point positions in MRI peg phantom

原文:http://blogs.mathworks.com/steve/2006/06/10/determining-point-position-in-mri-phantom/

Blog reader Jonathan from St. Jude Children's Research Hospital sent me an image derived from an MRI peg phantom:

bw = imread('http://blogs.mathworks.com/images/steve/62/mri_peg_phantom.png');
imshow(bw)
Jonathan wanted to know how to determine the position of each point. The functions bwlabel and regionprops do the trick.

The function bwlabel takes a binary image and figures which groups of white pixels are connected to each other.

L = bwlabel(bw);
The output L is called a label matrix. It has the same size as bw and contains nonnegative integers. Each positive integer value corresponds to a particular object. For example, to display the 10th object, just compare L to 10:

imshow(L == 10)
The function regionprops computes a number of different geometric properties of all the different regions contained in a label matrix. All we need for this application is the centroid:
s = regionprops(L, 'Centroid')
The size of the structure array s tells you the number of labeled objects: 205. The centroid of the 10th object is:

centroid_10 = s(10).Centroid

Here's a simple way to superimpose the centroid locations onto the original image:

imshow(bw)
hold on
for k = 1:numel(s)
    plot(s(k).Centroid(1), s(k).Centroid(2), 'x')
end
hold off
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值