网页资讯视频图片知道文库贴吧地图采购
进入贴吧全吧搜索

 
 
 
日一二三四五六
       
       
       
       
       
       

签到排名:今日本吧第个签到,

本吧因你更精彩,明天继续来努力!

本吧签到人数:0

一键签到
成为超级会员,使用一键签到
一键签到
本月漏签0次!
0
成为超级会员,赠送8张补签卡
如何使用?
点击日历上漏签日期,即可进行补签。
连续签到:天  累计签到:天
0
超级会员单次开通12个月以上,赠送连续签到卡3张
使用连续签到卡
02月06日漏签0天
matlab吧 关注:292,512贴子:1,659,369
  • 看贴

  • 图片

  • 吧主推荐

  • 游戏

  • 6回复贴,共1页
<<返回matlab吧
>0< 加载中...

正在做成熟番茄识别,遇到一个小问题,求大神帮忙

  • 只看楼主
  • 收藏

  • 回复
  • 朕后悔了
  • 无名之辈
    2
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
pic=imread('D:\机械视觉\新建文件夹\图片.jpg'); %载入图象
function result=avefilter(pic)%均值滤波器进行滤波处理
H=[1,1,1;1,1,1;1,1,1];%产生滤波模板
H=h/9;%滤波模板归一化
rgb=im2double(pic);
R=rgb(:,:,1);
G= rgb(:,:,2);
B= rgb(:,:,3);
result_r=conv2(r,h);%对图象进行滤波
result_g=conv2(g,h);%对图象进行滤波
result_b=conv2(b,h);%对图象进行滤波
result=cat(3,result_r,result_g,result_b);
function his=rgb2hsi(rgb) % RGB格式转换成HIS,并提取h分量
rgb=im2double(rgb);
R=rgb(:,:,1);
G=rgb(:,:,2);
B=rgb(:,:,3); %Implement the conversion equations.
num=0.5*((r-g)+(r-b));
den=sqrt((r-g).^2+(r-b).*(g-b));
theta=acos(num./(den+eps));
H=theta;
H(b>g)=2*pi-H(b>g);
H=H/(2*pi);
num=min(min(r,g),b);
den=r+g+b;
den(den==0)=eps;
S=1-3.*num./den;
H(S==0)=0;
I=(r+g+b)/3; %combine all three results into an his image.
his=cat(3,H,S,I);
function result=midfilter(pic) %对提取的h分量进行中值滤波
result=medfilt2(pic,[5 5]);
function result=zhifangtu(pic) %获取直方图
[M,N]=size(pic);
pic=(pic)*100;
pic=floor(pic);
H=zeros(1,100);
for m=1:M
for n=1:N
rk=pic(m,n)+1;
h(rk)=h(rk)+1;
end
end
result=h;
function t=get_yuzhi(h) %获取直方图的阈值
len=length(h);
hmax=0;
hmin=0;
max=0;
for i=1:len
if h(i)>max
max=h(i);
hmax=i;
end
end
t1=(hmax+hmin)/2;
t2=t1;
t=0;
totalh=0;
totalt=0;
num=0;
while abs(t1+t2-2*t)>0.5
t=(t1+t2)/2;
totalh=0;
totalt=0;
for i=1:floor(t)
totalh=totalh+h(i)*i;
totalt=totalt+h(i);
end
t2=(totalh/totalt);
totalh=0;
totalt=0;
for i=floor(t)+1:len
totalh=totalh+h(i)*i;
totalt=totalt+h(i);
end
t1=(totalh/totalt);
num=num+1;
if num==200
break;
end
end
function result=pengzhang(pic) %对图象进行膨胀操作
se=strel('disk',13);
result=imdilate(pic,se);
function result=fushi(pic) %对图象进行腐蚀操作
se=strel('disk',8);
result=imdilate(pic,se);
[1,num]=bwlabel(h_pengzhang2,8);
function res=zhongxin(pic,num) %求取重心
[m,n]=size(pic); %m hang
temp=1:num;
ii=zeros(1,num);
jj=zeros(1,num);
count= zeros(1,num);
for io=1:num
for i=1:m
for j=1:n
if pic((i-1)*n+j)==temp(io)
ii(io)=ii(io)+i;
jj(io)=jj(io)+j;
count=count+1;
end
end
end
end
res=[ii./count;jj./count];
错误: 文件:avefilter.m 行:119 列:1
脚本中的所有函数都必须以 'end' 结束。


  • 朕后悔了
  • 无名之辈
    2
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
pic=imread('D:\机械视觉\新建文件夹\图片.jpg'); %载入图象
function result=avefilter(pic)%均值滤波器进行滤波处理
H=[1,1,1;1,1,1;1,1,1];%产生滤波模板
H=h/9;%滤波模板归一化
rgb=im2double(pic);
R=rgb(:,:,1);
G= rgb(:,:,2);
B= rgb(:,:,3);
result_r=conv2(r,h);%对图象进行滤波
result_g=conv2(g,h);%对图象进行滤波
result_b=conv2(b,h);%对图象进行滤波
result=cat(3,result_r,result_g,result_b);
function his=rgb2hsi(rgb) % RGB格式转换成HIS,并提取h分量
rgb=im2double(rgb);
R=rgb(:,:,1);
G=rgb(:,:,2);
B=rgb(:,:,3); %Implement the conversion equations.
num=0.5*((r-g)+(r-b));
den=sqrt((r-g).^2+(r-b).*(g-b));
theta=acos(num./(den+eps));
H=theta;
H(b>g)=2*pi-H(b>g);
H=H/(2*pi);
num=min(min(r,g),b);
den=r+g+b;
den(den==0)=eps;
S=1-3.*num./den;
H(S==0)=0;
I=(r+g+b)/3; %combine all three results into an his image.
his=cat(3,H,S,I);
function result=midfilter(pic) %对提取的h分量进行中值滤波
result=medfilt2(pic,[5 5]);
function result=zhifangtu(pic) %获取直方图
[M,N]=size(pic);
pic=(pic)*100;
pic=floor(pic);
H=zeros(1,100);
for m=1:M
for n=1:N
rk=pic(m,n)+1;
h(rk)=h(rk)+1;
end
end
result=h;
function t=get_yuzhi(h) %获取直方图的阈值
len=length(h);
hmax=0;
hmin=0;
max=0;
for i=1:len
if h(i)>max
max=h(i);
hmax=i;
end
end
t1=(hmax+hmin)/2;
t2=t1;
t=0;
totalh=0;
totalt=0;
num=0;
while abs(t1+t2-2*t)>0.5
t=(t1+t2)/2;
totalh=0;
totalt=0;
for i=1:floor(t)
totalh=totalh+h(i)*i;
totalt=totalt+h(i);
end
t2=(totalh/totalt);
totalh=0;
totalt=0;
for i=floor(t)+1:len
totalh=totalh+h(i)*i;
totalt=totalt+h(i);
end
t1=(totalh/totalt);
num=num+1;
if num==200
break;
end
end
function result=pengzhang(pic) %对图象进行膨胀操作
se=strel('disk',13);
result=imdilate(pic,se);
function result=fushi(pic) %对图象进行腐蚀操作
se=strel('disk',8);
result=imdilate(pic,se);
[1,num]=bwlabel(h_pengzhang2,8);
function res=zhongxin(pic,num) %求取重心
[m,n]=size(pic); %m hang
temp=1:num;
ii=zeros(1,num);
jj=zeros(1,num);
count= zeros(1,num);
for io=1:num
for i=1:m
for j=1:n
if pic((i-1)*n+j)==temp(io)
ii(io)=ii(io)+i;
jj(io)=jj(io)+j;
count=count+1;
end
end
end
end
res=[ii./count;jj./count];
错误: 文件:avefilter.m 行:119 列:1
脚本中的所有函数都必须以 'end' 结束。


2026-02-06 23:21:30
广告
不感兴趣
开通SVIP免广告
  • 朕后悔了
  • 无名之辈
    2
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
求帮忙,顶一下


  • 朕后悔了
  • 无名之辈
    2
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
顶


  • 朕后悔了
  • 无名之辈
    2
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
顶


  • 朕后悔了
  • 无名之辈
    2
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
顶


  • 幸运星20
  • 武林新贵
    8
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
程序太长,没有完全看完,就是你检查检查是不是缺少END ,就是每个IF,FOR 都是以END 结束


登录百度账号

扫二维码下载贴吧客户端

下载贴吧APP
看高清直播、视频!
  • 贴吧页面意见反馈
  • 违规贴吧举报反馈通道
  • 贴吧违规信息处理公示
  • 6回复贴,共1页
<<返回matlab吧
分享到:
©2026 Baidu贴吧协议|隐私政策|吧主制度|意见反馈|网络谣言警示