首页 > 其他分享 >图像的深度信息提取

图像的深度信息提取

时间:2022-10-10 17:07:34浏览次数:50  
标签:end XL 图像 信息提取 nx disparity 深度 XR matching

%*******************************************************************
% Region Based Stereo Matching Algorithm by Global Error Energy
% Minimization by Smoothing Functions method explanied in the
% "Obtaining Depth Maps From Color Images By Region Based Stereo
% Matching Algorithms"
%
% It uses stereo color image pairs. Right camera image is loaded into XR array
% and left camera image is loaded into XL array. You can set Disparity search
% range by DisparityRange.
%
%
% Programmer: B. Baykant ALAG諾
% Ver.1.0 date: 09.2008
%******************************************************************clear all
tic
% User can set DisparityRange and matching variable.
%You can set upper bound of disparity search range by dmax
dmax=40;
%Select window type for calculation error energy
% matching=1 for point, matching=2 for line, matching=3 for 3x3 square
% window
matching=3;% Alfa tolerance coefficient for eliminating unreliable estimation
Alfa=1;% Stereo Camera System Parameter for dept map calcualtion
% foc: focal length of cameras in unit of cm
foc=30;
% T: distance between stereo camera pair in unit of cm
T=20;
%Loading Right image to XR and Left iamage to XL
[XR,MAP] = imread('view5m.png');
[XL,MAP] = imread('view1m.png');%------------------ END of USER SETTINGS----------------------
% auto-presettings for the program
[m n p]=size(XR);
Edis=1000000*ones(m,n);
disparity=zeros(m,n);
XR=double(XR);
XL=double(XL);% process by increasing disparity
for d=0:dmax
fprintf ('Computing for disparity: %d\n',d);
% composing error energy matrix for every disparity.(Algorithm step:1)
for j=3+d:n-2
for i=2:m-1
if p==3
%kareselfark(i,j-d)=(XR(i,j,1)-XL(i,j-d,1))^2+(XR(i,j,2)-XL(i,j-d,2))^2+(XR(i,j,3)-XL(i,j-d,3))^2;
if matching==1
%point matching
ErrorEnergy(i,j-d)=(1/3)*[(XL(i,j,1)-XR(i,j-d,1))^2+(XL(i,j,2)-XR(i,j-d,2))^2+(XL(i,j,3)-XR(i,j-d,3))^2];
elseif matching==2
%block matching with line type window
ErrorEnergy(i,j-d)=(1/15)*[(XL(i,j,1)-XR(i,j-d,1))^2+(XL(i,j,2)-XR(i,j-d,2))^2+(XL(i,j,3)-XR(i,j-d,3))^2+(XL(i,j-1,1)-XR(i,j-1-d,1))^2+(XL(i,j-1,2)-XR(i,j-1-d,2))^2+(XL(i,j-1,3)-XR(i,j-1-d,3))^2+(XL(i,j+1,1)-XR(i,j+1-d,1))^2+(XL(i,j+1,2)-XR(i,j+1-d,2))^2+(XL(i,j+1,3)-XR(i,j+1-d,3))^2+(XL(i,j-2,1)-XR(i,j-2-d,1))^2+(XL(i,j-2,2)-XR(i,j-2-d,2))^2+(XL(i,j-2,3)-XR(i,j-2-d,3))^2+(XL(i,j+2,1)-XR(i,j+2-d,1))^2+(XL(i,j+2,2)-XR(i,j+2-d,2))^2+(XL(i,j+2,3)-XR(i,j+2-d,3))^2];
else
top=0;
for k=i-1:i+1
for l=j-1:j+1
top=top+(XL(k,l,1)-XR(k,l-d,1))^2+(XL(k,l,2)-XR(k,l-d,2))^2+(XL(k,l,3)-XR(k,l-d,3))^2;
end
end
ErrorEnergy(k,l-d)=(1/27)*top;
end
else
Disp('ERROR WARNING: Use RGB color image for stereo pair');
end
end
end
% applying smooting on error energy surfaces by iterative averaging
% filtering. (Algorithm step:2)
ErrorEnergyFilt=IterativeAveragingFilter(ErrorEnergy,1,[4 4]);% selecting disparity which has minimum error energy.(Algorithm step:3)
[m1 n1]=size(ErrorEnergyFilt);
for k=1:m1
for l=1:n1
if Edis(k,l)>ErrorEnergyFilt(k,l)
disparity(k,l)=d;
Edis(k,l)=ErrorEnergyFilt(k,l);
end
end
end
end
% clear 1000000 pre-setting in Edis
for k=1:m
for l=1:n
if Edis(k,l)==1000000
Edis(k,l)=0;
end
end
end% extracting calculated zone
nx=n-dmax;
for k=2:m-1
for l=2:nx-1
disparityx(k,l)=disparity(k,l);
%Edisx(k,l)=Edis(k,l);
%regMapx(k,l)=regMap(k,l);
XLx(k,l)=XL(k,l);
XRx(k,l)=XR(k,l);
top=0;
for x=k-1:k+1
for y=l-1:l+1
top=top+(XL(x,y+disparity(k,l),1)-XR(x,y,1))^2+(XL(x,y+disparity(k,l),2)-XR(x,y,2))^2+(XL(x,y+disparity(k,l),3)-XR(x,y,3))^2;
end
end
Ed(k,l)=(1/27)*top;
end
end%calculates error energy treshold for reliablity of disparity
Toplam=0;
for k=1:m-1
for l=1:nx-1
Toplam=Toplam+Ed(k,l);
end
end
% Error threshold Ve
Ve=Alfa*(Toplam/((m-1)*(nx-1)));EdReliable=Ed;
disparityReliable=disparityx;
Ne=zeros(m,nx);
for k=1:m-1
for l=1:nx-1
if Ed(k,l)>Ve
% sets unreliable disparity to zero
disparityReliable(k,l)=0;
EdReliable(k,l)=0;
Ne(k,l)=1; % indicates no-estimated state
end
end
end% calculating reliablities both raw disparity and filtered disparity
TopE=0;
TopER=0;
Sd=0;
for k=1:m-1
for l=1:nx-1
TopE=TopE+Ed(k,l);
if Ne(k,l)==0
TopER=TopER+EdReliable(k,l);
Sd=Sd+1;
end
end
end
ReliablityE=((nx-1)*(m-1))/(TopE);
ReliablityER=(Sd)/(TopER);% median filtering for repairment of occulations
%disparityF=IterativeAveragingFilter(disparity,5,[4 4]);
disparityF=medfilt2(disparityReliable,[5 5]);for k=1:m-1
for l=1:nx-1
% Zero disparity produce zero dept
if disparityF(k,l)<5;
DepthMap(k,l)=0;
else
DepthMap(k,l)=foc*(T/disparityF(k,l));
end
end
endfprintf ('******** Reliablity Report ********** \n')
fprintf ('Reliablity of the disparity map: %f \n',ReliablityE)
fprintf ('Reliablity of the disparity map filtered: %f \n',ReliablityER)
fprintf ('******** Algoritm Speed Report ********** \n')
fprintf ('Time Spend for calculation: %f \n',toc)figure(1)
imagesc(disparityx);colorbar;
colormap('gray')
title('Disparity Map')
% pixval onfigure(2)
colormap('gray')
imagesc(disparityReliable);colorbar;
title('Disparity Map with Reliable Disparities')
% pixval onfigure(3)
colormap('gray')
imagesc(disparityF);colorbar;
title('Median Filtered Disparity Map with Reliable Disparities')
% pixval onfigure(4)
colormap('gray')
imagesc(DepthMap);colorbar;
title('Depth Map from Disparity Map with Reliable Disparities [cm]')
% pixval onfigure(5)
colormap('gray')
imagesc(log10(Ed));colorbar;
title('Dispatiy Map Error Energy')
% pixval onfigure(6)
imagesc(XR./255)
title('Right Camera Color Image')
% pixval onfigure(7)
imagesc(XL./255)
title('Left Camera Color Image')
% pixval onfigure(8)
colormap('bone')
mesh(disparityF)
title('3D View')

图像的深度信息提取_3d

D-74

标签:end,XL,图像,信息提取,nx,disparity,深度,XR,matching
From: https://blog.51cto.com/u_15815923/5744751

相关文章

  • 【yolov4】基于yolov4深度学习网络目标检测MATLAB仿真
        YOLO发展至YOLOv3时,基本上这个系列都达到了一个高潮阶段,很多实际任务中,都会见到YOLOv3的身上,而对于较为简单和场景,比如没有太密集的目标和极端小的目标,多数时候......
  • 深度学习/机器视觉/数字IC/FPGA/算法手撕代码目录总汇
    目录​​FPGA/数字IC手撕代码总汇​​​​常用算法手撕代码总汇​​​​FPGA工程师经典面试题​​​​数字IC经典面试题​​​​深度学习/人工智能/机器学习面试题​​​​......
  • 基于matlab的图象拼接--数字图像拼接技术
    全景图(Panorama),或者说是图像拼接(Mosaic)技术是由于摄像器材的视角限制,不可能一次拍出很大图片而产生的。本文主要围绕拼接合成技术展开讨论,首先关注一下拼接的主要用途,再......
  • Matlab R2015b+CUDA7.5+vs2013深度学习网络GPU搭建
    传统的跟踪算法大多从物体的外观出发,只能在线学习,从当前的视频中在线抓取数据进行学习跟踪的算法,如:TLD、Struck、KCF,这类算法必须足够简单才行,否则耗时严重。当然现在也有人......
  • 基于灰度变换的图像增强及MATLAB实现
    一  引言:图像增强技术是不考虑图像降质的原因,只将图像中感兴趣的特征有选择地突出,而衰减其不需要的特征,故改善后的图像不一定要去逼近原图像。如突出目标物轮廓,去除各类......
  • 基于Matlab实现的图像特效处理毕业设计
    数字图像是指由被称作象素的小块区域组成的二维矩阵。将一幅二维的图像通过有限个离散点来表示就成为了数字图像,其中的每个点称为图像元素,即像素。像素值往往用来表示像素的......
  • NLEM算法图像去噪源码程序
    functionimgDenoised=NLEM(imgNoisy,h,P,S)[m,n]=size(imgNoisy);N=2*P+1;h2=h*h;kNN=ceil((2*S+1)^2/2);%top50%oftheneighborsu......
  • 小波变换在图像分割中的应用
    1.1 空域图像分割空域是指图像平面本身,空域图像分割就是直接对图像的像素进行处理分割。研究者经过几十年的研究与努力,研究出了很多种空域图像分割方法。归纳起来大致包括......
  • 【图像去模糊】基于维纳滤波模糊图像复原算法的MATLAB仿真
    1.软件版本MATLAB2021a2.本算法理论知识   利用维纳滤波器进行图像去抖去模糊的基本原理如下所示:            对原始图像进行维纳滤波的算法是首先估计......
  • seam+carving算法对图像进行非等比例缩放以及无缝拼接
    下面介绍本系统的主要操作方法以及对应的函数说明:打开图片:选择图片:得到如下的仿真结果:下面开始非等比例缩放:从上面的图中,你可以看到人物的大小基本不变,然偶人物上方的蓝天的......