matlab图像加权平均函数,matlab – 从电泳凝胶图像测量加权平均长度

这是我的尝试.它要求凝胶很好(即直通道和凝胶不应旋转),但应该相当普遍地工作.请注意,需要调整两个与图像大小相关的参数,以使其适用于不同大小的图像.

%# first size-dependent parameter: should be about 1/4th-1/5th

%# of the lane width in pixels.

minFilterWidth = 10;

%# second size-dependent parameter for filtering the

%# lane profiles

gaussWidth = 5;

%# read the image, normalize to 0...1

img = imread('http://img823.imageshack.us/img823/588/gele.png');

img = rgb2gray(img);

img = double(img)/255;

%# Otsu thresholding to (roughly) find lanes

thMsk = img < graythresh(img);

%# count the mask-pixels in each columns. Due to

%# lane separation, there will be fewer pixels

%# between lanes

cts = sum(thMsk,1);

%# widen the local minima, so that we get a nice

%# separation between lanes

ctsEroded = imerode(cts,ones(1,minFilterWidth));

%# use imregionalmin to identify the separation

%# between lanes. Invert to get a positive mask

laneMsk = ~repmat(imregionalmin(ctsEroded),size(img,1),1);

带有用于分析的车道的图像

%# for each lane, create an averaged profile

lblMsk = bwlabel(laneMsk);

nLanes = max(lblMsk(:));

profiles = zeros(size(img,1),nLanes);

midLane = zeros(1,nLanes);

for i = 1:nLanes

profiles(:,i) = mean(img.*(lblMsk==i),2);

midLane(:,i) = mean(find(lblMsk(1,:)==i));

end

%# Gauss-filter the profiles (each column is an

%# averaged intensity profile

G = exp(-(-gaussWidth*5:gaussWidth*5).^2/(2*gaussWidth^2));

G=G./sum(G);

profiles = imfilter(profiles,G','replicate'); %'

%# find the minima

[~,idx] = min(profiles,[],1);

%# plot

figure,imshow(img,[])

hold on, plot(midLane,idx,'.r')

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值