声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 936|回复: 2

[综合讨论] 请大家帮我看看代码。

[复制链接]
发表于 2010-4-29 21:55 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
大家好。我是新手。MATLAB的水平灰常滴一般,但是由于近期在做毕业设计,遇到一些不得不解决的问题。
实在弄不懂,希望能得到各路高手指点迷津。

以下是别人的一段代码。我看不是很明白,不知有没有人能解释一下?
它所实现的功能是确定图片的边界吗?即可以裁减去图片背景中空白的地方?
在运行的过程中,出现了Strings passed to EVAL cannot contain function declarations.这样的错误,请问该怎么改?我做了一些修改,可以顺利运行,但是结果却不对。

希望大家帮帮忙。拜托拜托。


function bw2 = edu_imgcrop(bw)
% Find the boundary of the image
[y2temp x2temp] = size(bw);
x1=1; y1=1; x2=x2temp; y2=y2temp;
% Finding left side blank spaces
cntB=1;
while (sum(bw(:,cntB))==y2temp)
    x1=x1+1; cntB=cntB+1;
end
% Finding right side blank spaces
cntB=1;
while (sum(bw(cntB,:))==x2temp)
    y1=y1+1; cntB=cntB+1;
end
% Finding upper side blank spaces
cntB=x2temp;
while (sum(bw(:,cntB))==y2temp)
    x2=x2-1; cntB=cntB-1;
end
% Finding lower side blank spaces
cntB=y2temp;
while (sum(bw(cntB,:))==x2temp)
    y2=y2-1; cntB=cntB-1;
end
% Crop the image to the edge
bw2=imcrop(bw,[x1,y1,(x2-x1),(y2-y1)]);

[ 本帖最后由 ChaChing 于 2010-5-4 18:04 编辑 ]
回复
分享到:

使用道具 举报

发表于 2010-5-4 08:37 | 显示全部楼层
请LZ不要运行函数文件。
发表于 2010-5-4 18:09 | 显示全部楼层
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-9-21 23:24 , Processed in 0.058121 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表