MATLAB【七】———— matlab 高斯核使用,超像素图像模拟,矩阵转图像,深度相机模型实践实现
深度模型,图片转稀疏矩阵,稀疏矩阵转图片
%% mat to 2array
temp_speckle = ref_speckle;
[row_index,col_index,v]=find(temp_speckle);
obj_matrix =[row_index,col_index];
[obj_matrix_height,obj_matrix_width] = size(obj_matrix);%% depth camera model
plane_matrix = ones(rows,cols);
% s = B*f*(diff_dis-d0)/(diff_dis*d0);row_index = round(row_index-B*f*(diff_dis-d0)/(diff_dis*d0)); %% 2array to mat obj_image = zeros(1280,800);obj_matrix =[row_index,col_index];for i_obj_image = 1:obj_matrix_heightif(obj_matrix(i_obj_image)~=0)a = obj_matrix(:,1);b = obj_matrix(:,2);obj_image(a,b) = 1;endend
clc;
close all;
clear %% %%----平面--1280*800 single plane fittingd0=800;%标定距离mm
B=45;%基线长度mm
f=1000;%焦距,像素
min_distance=350;%mmM=1280;
N=800;
MAX=1023;
max_value=800;d1 =1000;
dep_val=800;
img_depth=zeros(M,N)*dep_val;%%
figure
s = surf(img_depth);
s.EdgeColor = [0 1 0];
title('深度值')% load('center_coordinate245_8359');
load('center_coordinate270_vescl');
figure
plot(center_coordinate(:,1),center_coordinate(:,2),'.')
axis equal
set(gca,'FontSize',12)
set(gca,'ydir','reverse')%设左上角为(0,0)点
axis([0 800 0 1280])
title('点阵图')
% s=B*f*(d1-d0)/(d1*d0);%% 生成一个高斯函数,函数与散斑点的灰度分布具有有较高的一致性,即可以很好的仿真当前的
dia = 7;%散斑直径
sigma = 2;
gausFilter = fspecial('gaussian', [dia,dia], sigma);
% figure
times=19;%奇数
kernel=imresize(gausFilter,times);%%imresize 使用双三次插值。 B = imresize(A,scale) 返回图像 B,它是将 A 的长宽大小缩放 scale 倍之后的图像。
cx=round(dia*times/2);
cy=round(dia*times/2);
R=floor(dia*times/2);kernel_mask=ones(size(kernel));
for m=1:times*diafor n=1:times*diaif (cx-n)^2+(cy-m)^2>=(R+1)*Rkernel_mask(m,n)=0;endend
endmax_kernel = max(max(kernel));
kernel=kernel.*kernel_mask*(max_value/max_kernel);surf(kernel);
%% IR_speckle=zeros(M*times,N*times);
L=length(center_coordinate);for i=1:Lcenter_x=round(center_coordinate(i,1)*times);center_y=round(center_coordinate(i,2)*times);if(((center_y-R)>0) && ((center_y+R) < M*times) && ((center_x-R)>0) && ((center_x+R) < N*times) ) IR_speckle(center_y-R:center_y+R,center_x-R:center_x+R)=IR_speckle(center_y-R:center_y+R,center_x-R:center_x+R)+kernel;end
endref_speckle=uint8(imresize(IR_speckle,1/times));
ref_speckle(ref_speckle>MAX)=MAX;
% figure
% imshow(ref_speckle,[])
% title('40cm散斑图')
ref_speckle =imrotate(ref_speckle,-90);
figure, imshow(ref_speckle, 'border', 'tight')
save_path = 'D:\matlab\vescl\gauss\';
imwrite(ref_speckle,[save_path,'ref.bmp']);%% get object image
Dep=imresize(img_depth,times);
% surf(Dep);
Obj_spe=zeros(M*times,N*times);
for i=1:Lcenter_x=center_coordinate(i,1)*times;%先不取整center_y=round(center_coordinate(i,2)*times);
% if((center_x>M*times)||(center_y>N*times))
% continue;
% else
% d1 = Dep(round(center_x),center_y);center_x=round(center_x-times*B*f*(d1-d0)/(d1*d0));
% endif(((center_y-R)>0) && ((center_y+R) < M*times) && ((center_x-R)>0) && ((center_x+R) < N*times) ) Obj_spe(center_y-R:center_y+R,center_x-R:center_x+R)=Obj_spe(center_y-R:center_y+R,center_x-R:center_x+R)+kernel;end
endobj_speckle=uint8(imresize(Obj_spe,1/times));
obj_speckle(obj_speckle>MAX)=MAX;
obj_speckle =imrotate(obj_speckle,-90);
figure, imshow(obj_speckle, 'border', 'tight')
save_path = 'D:\matlab\vescl\gauss\';
imwrite(obj_speckle,[save_path,'object.bmp']);%%
将矩阵转换成图片,plot使用示例,数组操作剔除为0的元素
close all;
clear
clc
% origi= load('坐标270.txt');
% figure
% plot(origi(:,1),origi(:,2),'.');
% axis equal % Locate=find(a>122) %a是存储数据的数组名,find是找到大于122的数的位置
% a(Locate)=[]; %删除数组a中大于122的元素origin_data = load('center_coordinate270_vescl.mat');
x = origin_data.center_coordinate(:,1);
y = origin_data.center_coordinate(:,2);
origin_data_origin =[x,y];
% figure
% plot(x,y,'--gs',...
% 'LineWidth',1,...
% 'MarkerSize',2,...
% 'MarkerEdgeColor','b',...
% 'MarkerFaceColor',[0.5,0.5,0.5])
% axis equal Locate=find(x>800);
x(Locate) = [];
y(Locate) = [];
origin_data = [x,y];
% figure
% plot(x,y,'.');
% axis equal
[m,n] = size(origin_data); for num = 0:5% transposition x and y coeff =0.02*num;gauss = normrnd(0,coeff,[m,n] );gauss_round = roundn(gauss,-4);simulation_data = origin_data + gauss_round;simulation_data_x = simulation_data(:,1);simulation_data_y = simulation_data(:,2);simulation_data = [simulation_data_x,simulation_data_y]; %% t = uint16(simulation_data_x);simulation_data_x = uint16(simulation_data_y);simulation_data_y = t;rotate_data = [simulation_data_x,simulation_data_y] ;%% matrix to mat origin_image = zeros(1280,800);for i =1:mif(simulation_data_x(i)~=0)a = simulation_data_x(i);b = simulation_data_y(i);origin_image(a,b) = 1; end end origin_image = imrotate(origin_image,-90); %%%imrotate>0 anticlock origin_image = im2uint16(origin_image);figure, imshow(origin_image, 'border', 'tight') save_path = 'D:\matlab\vescl\gauss\';frame = getframe(gcf);result = frame2im(frame);result = im2uint16(result);imwrite(origin_image,[save_path,num2str(num),'.png']);
end
%% matrix to mat
origin_image = zeros(1280,800);
for i =1:m
if(simulation_data_x(i)~=0)
a = simulation_data_x(i);
b = simulation_data_y(i);
origin_image(a,b) = 1;
end
end
相关文章:

jsp 出现cannot be resolved to a type问题解决办法
(1)检查<% page import>是否导入了相关的包。若是没有则需导入 (2)若导入相应的包后问题仍然存在则需创建相关的servlet转载于:https://www.cnblogs.com/wth21-1314/p/6126655.html

U盘中毒了?教你如何删除System Volume Information这个顽固文件夹
不得不说cmd命令很好用呢。最近我的U盘中毒了,格式化都删除不了System Volume Information这个顽固的文件夹,真心伤不起哇!还好现在解决了问题。看来以后得好好对待U盘,不能乱用了。本篇文章教大家如何删除System Volume Informat…

69亿美元英伟达史上最大收购!这家基金又赢了
。另一方面,在虚拟货币的浪潮告一段落之后,英伟达需要给增速放缓的数据中心业务注入一枚强心剂。 有意思的是,英伟达对Mellanox的收购也成就了国际知名维权对冲基金Starboard Value LP的又一次投资胜利。 击败微软、英特尔,交易…

基础数据结构【一】————数组
二维数组相乘,矩阵相乘, #include <iostream> using namespace std;void MatrixMultiply(int*, int*, int*, int, int, int); int main() {int M, N, P;int i, j;//矩阵A部分 cout << "请输入矩阵A的维数(M,N): " << endl;…

Fragment 和 FragmentActivity的使用
Fragment 和 FragmentActivity的使用 http://blog.csdn.net/izy0001989624/article/details/17072211转载于:https://www.cnblogs.com/as3lib/p/6126761.html

win10 VMware15 安装 CentOS6.4 64位(慢慢弄吧,别急)
参考:CentOS 6.4安装(超级详细图解教程) 可以都不勾,有需要,以后使用中有需要再手动安装 除了KDE,其他都选就可以了 系统管理、虚拟化、负载平衡器、高可用性可以都不选

Nginx网站常见的跳转配置实例
相信大家在日常运维工作中如果你用到nginx作为前端反向代理服务器的话,你会对nginx的rewrite又爱又恨,爱它是因为你搞定了它,完成了开发人员的跳转需求后你会觉得很爽,觉得真的很强大,恨它是因为当一些稀奇古怪跳转的需…

基础数据结构【二】————动态数组,单向链表及链表的反转
DEMO1: 动态分配变量(链表,而静态数组是线性表,意味着动态数组访问和遍历复杂度为O(n),而插入和删除复杂度为O(1),而静态数组线性表则完全相反) int* in…

VMware15克隆虚拟机Centos
在克隆虚拟机之前,我们需要了解以下文件: 1、/etc/udev/rules.d/70-persistent-net.rules 这是网卡有关信息的配置文件,我们可以先查看一下master的网卡信息(当然也可以用ifconfig命令查看) 要注意的是网卡名称以及…

EXPDP 时ORA-27054 问题处置
现象:[oracleoracle1 ~]$ expdp xian/xian schemasxian directorydumpdir dumpfilexian.dmp LOGFILExian.logExport: Release 10.2.0.5.0 - 64bit Production on Friday, 02 December, 2016 20:19:48Copyright (c) 2003, 2007, Oracle. All rights reserved.Connec…

OSC源创会往期图文回顾链接地址收藏
为什么80%的码农都做不了架构师?>>> 格式:源创会报名链接地址 - 源创会结束后图文回顾链接地址 【深圳】第1期】- 图文回顾【广州】第2期】- 图文回顾【北京】第3期】- 图文回顾【珠海】第4期】- 图文回顾【深圳】第5期】- 图文回顾--------…

ionic + cordova+angularJs 搭建的H5 App完整版总结
为期半个月的项目实践开发,已完整告一段落,团队小组获得第一名,辛苦总算没有白费,想起有一天晚上,整个小组的人,联调到12点才从公司回去,真是心酸。这里总结一下,项目过程中遇到的问…

基础数据结构【三】————老鼠走迷宫问题————堆栈应用
假设:老鼠在一个二维地图中i行走,地图中大部分路径被墙阻断,无法前进。老鼠可以按照尝试错误的方法找到出口。只是,这只老鼠必须具备走错路时候就退回来,并且把走过的路记下来,避免下次走重复路,…

eclipse Debug中step into功能失灵的问题
step into 和 step over功能一样,无法进入方法内部,解决方法如下: 需要使用jdk中的jre,而不是独立安装的jre 再次Debug,当运行到断点的时候,点击step into(F5)就可以看见println函数…

Linux 基金会宣布红队项目,致力于孵化开源安全工具
百度智能云 云生态狂欢季 热门云产品1折起>>> 谁都想软件有着很高的安全性吧。毕竟,每一天都会有不一样的安全漏洞,从糟糕软件的沼泽中冒出来。 在近期举办的开源领导力峰会上,Linux 基金会宣布了新的红队项目(Red Tea…

基础数据结构【四】————环形链表与多项式
主要演示环形列表节点的创建插入, 删除,遍历,环形链表连接 。双向链表节点的建立与插入 ,双向链表中节点的删除 以及环形链表在多项式中的应用 DEMO1:环形链表节点的创建与插入 /* [名称]:ch03_08.cpp [示范]:环形链表节点的创…

关联scala源码
首先需要去官网下载sources 将下载好的压缩包拷贝到scala安装的lib目录下,解压 ctrlb以后 查看源码, 选择要查看的方法或者类, 输入 ctrl b import scala.io.StdIn 如果想看StdIn的源码,则将光标放在StdIn处,ctrlb 如果想查看io包下的内容&…

MySQL安装使用的2个问题
问题:1.遇到不输入密码能登上 ,使用密码报错.2.(解压版的) 在cmd输入>mysql –u root –p 时,按enter回车时,会叫你输入密码Enter password____,否则出现错误:ERROR 1045(28000):Access denied for user’root’’localhost’(using passw…

Flink1.7.2 sql 批处理示例
Flink1.7.2 sql 批处理示例 源码 https://github.com/opensourceteams/flink-maven-scala概述 本文为Flink sql Dataset 示例主要操作包括:Scan / Select,as (table),as (column),limit,Where / Filter,between and (where),Sum,min,max,avg,(group by ),group by having,disti…

ISP 【一】————boost标准库使用——批量读取保存文件 /boost第三方库的使用及其cmake添加,图像gramma
CMakeLists.txt文件中需要添加第三方库,并企鹅在CMakeLists.txt中添加 include_directories(${PROJECT_SOURCE_DIR}/../3party/gflags-2.2.2/include) link_directories(${PROJECT_SOURCE_DIR}/../3party/boost-1.73.0/lib-import) target_link_libraries( gram…

简单ajax类, 比较小, 只用ajax功能时, 可以考虑它
忘了哪儿转来的了, 不时的能够用上, 留存一下<script language"javascript" type"text/javascript"> /***var ajaxAjax();/*get使用方式* /ajax.get("php_server.php?id1&namexxx", function(data){ alert(data); //d…

Hadoop 三大发行版本
Hadoop三大发行版本:Apache、Cloudera、Hortonworks。 Apache版本最原始(最基础)的版本,对于入门学习最好。 Cloudera在大型互联网企业中用的较多。 Hortonworks文档较好。 1. Apache Hadoop 官网地址:http://had…

MongoDB主动撤回SSPL的开源许可申请
2018年10月,MongoDB将其开源协议更换为SSPL,虽然在当时引起了很大的争议,但是MongoDB始终坚信SSPL符合符合开源计划的批准标准,并向Open Source Initiative (以下简称OSI)提交了申请。不过,近日…

MATLAB【八】———— matlab 读取单个(多个)文件夹中所有图像
0.matlab 移动(复制)文件到另一个文件夹 sourcePath .\Square_train; targetPath .\Square_test; fileList dir(sourcePath); for k 3 :5: length(fileList) movefile([sourcePath,\,fileList(k).name],targetPath); end %copyfile([sourcePat…

JAVA IO学习
2019独角兽企业重金招聘Python工程师标准>>> 很多初学者接触IO时,总是感觉东西太多,杂乱的分不清楚。其实里面用到了装饰器模式封装,把里面的接口梳理一下之后,就会觉得其实蛮清晰的 相关的接口和类 接口或类描述Input…

Java面向对象三大特征 之 多态性
1、理解多态性:可以理解为一个事物的多种形态 2、对象的多态性:父类的引用指向子类的对象(子类的对象赋给父类的引用) 3、多态的使用:虚拟方法的调用 子类中定义了与父类同名同参数的方法(重写ÿ…

Bootstrap3基础 btn-group-vertical 按钮组(横着、竖着排列)
内容参数OS Windows 10 x64 browser Firefox 65.0.2 framework Bootstrap 3.3.7 editor Visual Studio Code 1.32.1 typesetting Markdowncode <!DOCTYPE html> <html lang"zh-CN"><head><meta charset&quo…

ISP【二】————camera ir图
1. 加串解串芯片作用? A: 加串和解串是成对出现的,串行器在模组内,将并行信号转换为串行信号,然后用一根线可以实现远距离传输。sensor输出的raw data如果不加串,需要8根线传输,很难传输很远&a…

Hadoop运行模式 之 本地运行模式
Hadoop的运行模式包括:本地模式、伪分布式模式以及完全分布式模式 Hadoop官网地址:https://hadoop.apache.org/ 本次使用的Hadoop的版本是2.7.2 官网文档:https://hadoop.apache.org/docs/r2.7.2/hadoop-project-dist/hadoop-common/Single…

一些使用Vim的小技巧
7.增加注释(一个操作应用在多行)比如需要增加#或者是//这种注释:Ctrl v 定位到开始行,然后选定需要的行,然后执行 I命令,然后输入 # 或 //,然后按 Esc键两次,即可把注释操作应用到所…