clear; clc
[a ,map]= imread('test.JPG');
I=im2bw(a,0.75);
I=1-I;
Ileast = bwlabel(I,4); % 标定图像的连通域
nummax = max(Ileast(:)); % 分块数
col=length(I(:,1)); % 行数
row=length(I(1,:)); % 列数
Area_candidate = struct('top',{},'left',{},'bottom',{},'right',{});%初始化结构体
for n=1:nummax
Area_candidate(n).top=col;
Area_candidate(n).left=row;
Area_candidate(n).bottom=0;
Area_candidate(n).right=0;
end
%判定各个连通域的最小外接矩形的边界的值
for a=1:col
for b=1:row
if Ileast(a,b)~=0
Area_candidate(Ileast(a,b)).top = min ( Area_candidate(Ileast(a,b)).top ,a);%得到各个连通域的边界
Area_candidate(Ileast(a,b)).left = min ( Area_candidate(Ileast(a,b)).left ,b);
Area_candidate(Ileast(a,b)).bottom = max ( Area_candidate(Ileast(a,b)).bottom ,a);
Area_candidate(Ileast(a,b)).right = max ( Area_candidate(Ileast(a,b)).right ,b);
end
end
end
%新建的空矩阵上得出图像
I_out=zeros(size(I));
for n=1:nummax
I_out(Area_candidate(1,n).top:Area_candidate(1,n).bottom , Area_candidate(1,n).left:Area_candidate(1,n).right) =1 ;%填充矩形
end
imshow(I_out)
msgbox('MATLAB编程答疑,请加QQ: 993878382','MATLAB答疑','help')
web http://993878382.qzone.qq.com -browser
没有合适的资源?快使用搜索试试~ 我知道了~
MATLAB文字连通域源程序代码.zip.zip
共3个文件
jpg:1个
m:1个
db:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 74 浏览量
2023-10-22
11:35:37
上传
评论
收藏 22KB ZIP 举报
温馨提示
MATLAB文字连通域源程序代码.zip.zip
资源推荐
资源详情
资源评论
收起资源包目录
MATLAB文字连通域源程序代码.zip.zip (3个子文件)
MATLAB文字连通域源程序代码.zip
MATLAB文字连通域源程序代码
Thumbs.db 5KB
test.JPG 19KB
combindomain.m 1KB
共 3 条
- 1
资源评论
icwx_7550592
- 粉丝: 17
- 资源: 7163
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功