江南烟雨

江南烟雨在哈工大工作生活的简介!

« Zixiang Xiong教授报告" Network information theory, code designs, and applications"怀童心的孩子回家了---浙江工商大学人文学院院长徐斌的告别演说 »

基于积分图的自适应阈值分割的matlab源代码

paper title : Adaptive Thresholding using Integral Image

matlab code is listed as follow:

function outputbinaryimage = adaptivethresholding(inputimage)
if ndims(inputimage) == 3
inputimage = rgb2gray(inputimage);
end
inputimage = double(inputimage);
[width height] = size(inputimage);
outputbinaryimage = zeros(width,height);
s = width/8;
t = 15;
intimg = ones(width,height).*255;
for i = 1:width
sum = 0;
for j = 1:height
sum = sum + inputimage(i,j);
if i == 1
intimg(i,j) = sum;
else
intimg(i,j) = intimg(i-1,j) + sum;
end
end
end
for i = 1:width
for j = 1:height
x1 = round(i – s/2);
x2 = round(i + s/2);
y1 = round(j – s/2);
y2 = round(j + s/2);
if x1 width
x1 = width;
end
if x2 > width
x2 = width;
end
if y1 height
y2 = height;
end
if y1 > height
y1 = height;
end
count = (x2 – x1 + 1) * (y2 – y1 + 1);
sumv = intimg(x2,y2) – intimg(x2,y1) – intimg(x1,y2) + intimg(x1,y1);
if inputimage(i,j) * count <= (sumv * (100.0 – t)/100)
outputbinaryimage(i,j) = 0;
else
outputbinaryimage(i,j) = 255;
end
end
end

  • 相关文章:

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

日历

最新评论及回复

最近发表

Powered By Z-Blog 1.8 Arwen Build 90619

Copyright;2009-2009 blog.hit.edu.cn All Rights Reserved 哈工大网络与信息中心