导航:首页 > 源码编译 > 抠图算法matlab

抠图算法matlab

发布时间:2024-02-27 10:11:15

❶ 基于matlab的边缘检测的robert算子的算法怎么写

matlab本身有库函数的。直接调用啊
VC代码:
void BianYuanJianCeDib::Robert()
{
LPBYTE p_data; //原图数据区指针
int wide,height; //原图长、宽
int i,j; //循环变量
int pixel[4]; //Robert算子
p_data=this->GetData ();
wide=this->GetWidth ();
height=this->GetHeight ();
LPBYTE temp=new BYTE[wide*height]; //新图像缓冲区
//设定新图像初值为255
memset(temp,255, wide*height);
//由于使用2*2的模板,为防止越界,所以不处理最下边和最右边的两列像素
for(j=0;j<height-1;j++)
for(i=0;i<wide-1;i++)
{
//生成Robert算子
pixel[0]=p_data[j*wide+i];
pixel[1]=p_data[j*wide+i+1];
pixel[2]=p_data[(j+1)*wide+i];
pixel[3]=p_data[(j+1)*wide+i+1];
//处理当前像素
temp[j*wide+i]=(int)sqrt((pixel[0]-pixel[3])*(pixel[0]-pixel[3])
+(pixel[1]-pixel[2])*(pixel[1]-pixel[2]));
}
//将缓冲区中的数据复制到原图数据区
memcpy(p_data, temp,wide*height);
//删除缓冲区
delete temp;
}

❷ 图像软抠图(soft matting) 怎么做算法是什么

function [A]=getLaplacian1(I,consts,epsilon,win_size)

if (~exist('epsilon','var'))
epsilon=0.0000001;
end
if (isempty(epsilon))
epsilon=0.0000001;
end
if (~exist('win_size','var'))
win_size=1;
end
if (isempty(win_size))
win_size=1;
end

neb_size=(win_size*2+1)^2;
[h,w,c]=size(I);
n=h; m=w;
img_size=w*h;
consts=imerode(consts,ones(win_size*2+1));

indsM=reshape([1:img_size],h,w);

tlen=sum(sum(1-consts(win_size+1:end-win_size,win_size+1:end-win_size)))*(neb_size^2);

row_inds=zeros(tlen ,1);
col_inds=zeros(tlen,1);
vals=zeros(tlen,1);
len=0;
for j=1+win_size:w-win_size
for i=win_size+1:h-win_size
if (consts(i,j))
continue
end
win_inds=indsM(i-win_size:i+win_size,j-win_size:j+win_size);
win_inds=win_inds(:);
winI=I(i-win_size:i+win_size,j-win_size:j+win_size,:);
winI=reshape(winI,neb_size,c);
win_mu=mean(winI,1)';
win_var=inv(winI'*winI/neb_size-win_mu*win_mu' +epsilon/neb_size*eye(c));

winI=winI-repmat(win_mu',neb_size,1);
tvals=(1+winI*win_var*winI')/neb_size;

row_inds(1+len:neb_size^2+len)=reshape(repmat(win_inds,1,neb_size),...
neb_size^2,1);
col_inds(1+len:neb_size^2+len)=reshape(repmat(win_inds',neb_size,1),...
neb_size^2,1);
vals(1+len:neb_size^2+len)=tvals(:);
len=len+neb_size^2;
end
end

vals=vals(1:len);
row_inds=row_inds(1:len);
col_inds=col_inds(1:len);
A=sparse(row_inds,col_inds,vals,img_size,img_size);

sumA=sum(A,2);
A=spdiags(sumA(:),0,img_size,img_size)-A;

❸ matlab实现弗洛伊德算法的代码,。

function
[d,r]=floyd(a)
%floyd.m
%采用floyd算法计算图a中每对顶点最短路
%d是矩离矩阵
%r是路由矩阵
n=size(a,1);
d=a;
for
i=1:n
for
j=1:n
r(i,j)=j;
end
end
r
for
k=1:n
for
i=1:n
for
j=1:n
if
d(i,k)+d(k,j)

评论
0

0

0

加载更多

阅读全文

与抠图算法matlab相关的资料

热点内容
centos开机命令行模式 浏览:695
遍历所有listpython 浏览:660
力控加密文件夹 浏览:515
如何更改移动服务器密码 浏览:686
苹果8p手机加密 浏览:749
ipad建文件夹怎么弄 浏览:833
iphone13对wap3加密 浏览:555
pdf文件打开失败 浏览:913
dubbo怎么调用不同服务器接口 浏览:40
全能解压王app历史版本 浏览:75
优先队列与拓扑排序算法 浏览:281
pdf转换formacbook 浏览:871
pdf文件内容怎么编辑 浏览:48
134压缩机排气温度多少 浏览:256
unity等待编译后 浏览:806
黑鲨手机锁屏视频在哪个文件夹 浏览:781
wow地图解压后怎么压缩 浏览:823
有pdf却打不开 浏览:461
七星彩软件app怎么下载 浏览:219
32单片机的重映射哪里改 浏览:818