当前位置: 首页 > 编程日记 > 正文

MATLAB【十四】————遍历三层文件夹操作

文件夹遍历

clear;
clc;
close all;%% crop the im into 256*256
num = 0;    %% num=1 内缩3个像素  num =2  内缩6个像素  load('qualitydata1.mat')
load('qualitydata2.mat')[data1_m,data1_n] = size(qualitydata1);
[data2_m,data2_n] = size(qualitydata2);%% read image_name in filepath% file_path =  'D:\matlab\motive_vs_exe\data\cg\30\15\';% 图像文件夹路径  
% img_path_list_bmp = dir(strcat(file_path,'*.png'));%获取该文件夹中所有bmp格式的图像  
% img_num = length(img_path_list_bmp);%获取图像总数量 
% I=cell(1,img_num);
% if img_num > 0 %有满足条件的图像  
%         for j = 1:img_num %逐一读取图像  
%             image_name = img_path_list_bmp(j).name;% 图像名  
%             image =  imread(strcat(file_path,image_name));  
%             I{j}=image;
%            fprintf('%d %d %s\n',i,j,strcat(file_path,image_name));% 显示正在处理的图像名  
%             %图像处理过程 省略  
%             %这里直接可以访问细胞元数据的方式访问数据
%         end  
% end  
%% readme  suitable for three layers of the file like  cg/30/1  cg/30/2 ... cg/30/10   .....cg/100/1 ...cg/100/10
%% 
oriDataPath = 'D:\matlab\motive_vs_exe\data\';  
saveDirPath = 'D:\matlab\motive_vs_exe\we_chat_data\';
imgDataDirList  = dir(oriDataPath);             % 遍历所有文件
layer_1_list = imgDataDirList(3:end);
% 
for i = 1:length(layer_1_list)layer_1_list_folder =layer_1_list(i,:).folder; layer_1_list_name =layer_1_list(i,:).name; layer_2_list = dir( fullfile(layer_1_list_folder,layer_1_list_name));layer_2_list = layer_2_list(3:end); for i2 = 1:length(layer_2_list)layer_2_list_folder=layer_2_list(i2,:).folder; layer_2_list_name =layer_2_list(i2,:).name; layer_3_list = dir( fullfile(layer_2_list_folder,layer_2_list_name));layer_3_list = layer_3_list(3:end); for i3 = 1:length(layer_3_list)layer_3_list_folder=layer_3_list(i3,:).folder; layer_3_list_name =layer_3_list(i3,:).name; layer_4_list = dir( fullfile(layer_3_list_folder,layer_3_list_name));layer_4_list = layer_4_list(3:end); %              for i4 = 1:1
%                      layer_4_list_folder=layer_4_list(i4,:).folder; layer_4_list_folder=layer_4_list.folder;layer_4_list_name =layer_4_list(2,:).name; 
%                      layer_5_list =  fullfile(layer_3_list_folder,layer_3_list_name);for j = 1:data1_mkey = qualitydata1(j,:).key;key_fore = split(key,'.');str_key = key_fore(1);   %%%% get excel strstr_key = replace(str_key,'/','\');%%%%%%%%%%%%%%%%%judge whether the%%%%%%%%%%%%%%%%%same depth and then deal with it  str_aim = replace(layer_4_list_folder,oriDataPath,'');                                     if(isequal(str_aim,str_key))rect_x = qualitydata1(j,:).rect_x;rect_y = qualitydata1(j,:).rect_y;rect_width = qualitydata1(j,:).rect_width;rect_height = qualitydata1(j,:).rect_height;point_0_x = qualitydata1(j,:).point_0_x;point_0_y = qualitydata1(j,:).point_0_y;point_1_x = qualitydata1(j,:).point_1_x;point_1_y = qualitydata1(j,:).point_1_y;point_2_x = qualitydata1(j,:).point_2_x;point_2_y = qualitydata1(j,:).point_2_y;point_3_x = qualitydata1(j,:).point_3_x;point_3_y = qualitydata1(j,:).point_3_y;point_4_x = qualitydata1(j,:).point_4_x;point_4_y = qualitydata1(j,:).point_4_y;%% change roi rect_x = rect_x + 3*num ;rect_y = rect_y + 3*num ;rect_width = rect_width -  2*3*num;rect_height = rect_height - 2*3*num;%% roi = [rect_x,rect_y,rect_width,rect_height];path_depth = fullfile(layer_4_list_folder,'depth.png');depth_image = imread(path_depth);path_ir = fullfile(layer_4_list_folder,'auto_rectified_ir.png');ir_image = imread(path_ir);path_rgb = fullfile(layer_4_list_folder,'rgb.jpg');rgb_image = imread(path_rgb);%                                          figure, imshow(depth_image*255, 'border', 'tight')                                            %                                          Point  = roi;%                                          hold on;%                                          rectangle('Position', roi, 'LineWidth', 2, 'EdgeColor', 'r')  %%%                                          rectangle('Position', Point, 'LineWidth', 2, 'EdgeColor', 'r')[image_h,image_w] = size(depth_image); for jj = 1:1:image_hfor ii = 1:1:image_wif ((jj>rect_y)&&(jj<rect_y + rect_height))if ((ii>rect_x)&&(ii<rect_x + rect_width))continue;elsedepth_image(jj,ii) = 0;endelsedepth_image(jj,ii) = 0;end   endend%%    imwshow(roi_depth,)
%                                              figure, imshow(depth_image*255, 'border', 'tight')          %%depth  show    figure, imshow(rgb_image, 'border', 'tight')                  %%rgb show    Point  = roi;hold on;rectangle('Position', roi, 'LineWidth', 2, 'EdgeColor', 'r')  %%rectangle('Position', Point, 'LineWidth', 2, 'EdgeColor', 'r')text(point_0_x,point_0_y,'o','color','g');                  %%key point show on rgbtext(point_1_x,point_1_y,'o','color','g');text(point_2_x,point_2_y,'o','color','g');text(point_3_x,point_3_y,'o','color','g');text(point_4_x,point_4_y,'o','color','g');%%   save depth roinew_str_aim = split(str_aim,'\');savePathDepth = fullfile(saveDirPath,char(new_str_aim(1)),char(new_str_aim(2)),'depth\');mkdirDepthDir = mkdir(savePathDepth); imwrite(depth_image,[savePathDepth,char(new_str_aim(3)),'.png']);%%%remove rgb and ir pic and change its name%% saveas(figure(num2str((char(new_str_aim(3))))), [savePathDepth,char(new_str_aim(3)),'.png'])savePathIr = fullfile(saveDirPath,char(new_str_aim(1)),char(new_str_aim(2)),'ir\');mkdirIrDir = mkdir(savePathIr); imwrite(ir_image,[savePathIr,char(new_str_aim(3)),'.png']);savePathRgb = fullfile(saveDirPath,char(new_str_aim(1)),char(new_str_aim(2)),'rgb\');mkdirRgbDir = mkdir(savePathRgb);imwrite(rgb_image,[savePathRgb,char(new_str_aim(3)),'.jpg']);%% saveas(figure(), [savePathRgbKeyPoint,char(new_str_aim(3)),'.jpg']);savePathRgbKeyPoint = fullfile(saveDirPath,'rgbKeyPointDir',char(new_str_aim(2)));mkdirRgbKeyPointDir = mkdir(savePathRgbKeyPoint);frame = getframe(gcf);result = frame2im(frame);imwrite(result,[savePathRgbKeyPoint,char(new_str_aim(3)),'.jpg']);endend%              end              endend
end   1

相关文章:

LoadRunner监控Linux

有的linux机器上安装rpc后会保存如下&#xff1a; test -z "/usr/local/sbin" || mkdir -p -- . "/usr/local/sbin"/bin/install -c rpc.rstatd /usr/local/sbin/rpc.rstatd make[2]: Nothing to be done for install-data-am. make[2]: Leaving directory…

scala while循环中断

Scala内置控制结构特地去掉了break和continue&#xff0c;是为了更好的适应函数化编程&#xff0c;推荐使用函数式的风格解决break和contine的功能&#xff0c;而不是一个关键字。 如何实现continue的效果 Scala内置控制结构特地也去掉了continue&#xff0c;是为了更好的适应…

05-04-查看补丁更新报告

《系统工程师实战培训》 -05-部署补丁管理服务器 -04-查看补丁更新报告 作者&#xff1a;学 无 止 境QQ交流群&#xff1a;454544014///安装报表工具&#xff08;在100-Admin01上面安装如下工具&#xff0c;方便查看WSUS更新补丁报告!&#xff09;Microsoft System CLR Types f…

ISP【三】———— raw读取、不同格式图片差异

part zero: 如何处理.raw格式数据&#xff0c;读取和转化 matlab读取raw图 &#xff08;mark读取图片尺寸和位数均可设置&#xff0c;图片尺寸M,N&#xff0c;图片数据类型8bit,16bit改成uint16&#xff09; clear; clc; close all; % % rotpath imread(D:\matlab\ncc_ive…

深度学习 - 相关名词概念

2019独角兽企业重金招聘Python工程师标准>>> Neural Network 神经网络 Weights 权重 Bias 偏移 Activation Function 激活函数, 用于调整每个神经的输出, 有如下几个常用的函数种类 ReLU Sigmoid Optimizer 优化器 Adam Input Layer, Hidden Layer, Output Layer 输…

HDFS的API操作

准备工作&#xff1a;IDEA > HDFS客户端准备 目录 文件上传 文件下载 文件夹删除 修改文件名称 查看文件详情 文件和文件夹的判断 完整代码 文件上传 注意conf.set("dfs.replication","2");的位置&#xff0c;位置不一样&#xff0c;设置的副本…

微信小程序-锚点定位+内容滑动控制导航选中

之前两篇文章分别介绍了锚点定位和滑动内容影响导航选中&#xff0c;这里我们就结合起来&#xff0c;实现这两个功能&#xff01; 思路不再多说&#xff0c;直接上干货&#xff01; WXML <view class"navigateBox"><view class"title"><ima…

MATLAB【十四】————调用深度库生成exe,批量运行三层文件夹下图片,保存结果

运行路径&#xff1a;D:\matlab\cmd_batch_processing 文件夹架构&#xff1a; clear; clc; close all;%% crop the im into 256*256oriDataPath D:\matlab\cmd_batch_processing\data\; targetPathOri D:\matlab\cmd_batch_processing\result\;report_path D:\matlab\cm…

JDK1.8学习

2019独角兽企业重金招聘Python工程师标准>>> List<OrderGoodsDetail> olist BeanMapper.mapList(list,OrderGoodsDetail.class);List<String> list2 Arrays.asList("123", "45634", "7892", "abch", "s…

HDFS的数据流

目录 HDFS写数据流程 剖析文件写入 网络拓扑-节点距离计算 机架感知&#xff08;副本存储节点选择&#xff09; Hadoop2.7.2 副本节点选择 HDFS读数据流程 HDFS写数据流程 剖析文件写入 1&#xff09;客户端通过Distributed FileSystem模块向NameNode请求上传文件&#x…

Js----闭包

1、闭包的概念&#xff1a;(我找了很多&#xff0c;看大家的理解) A:闭包是指可以包含自由&#xff08;未绑定到特定对象&#xff09;变量的代码块&#xff1b; 这些变量不是在这个代码块内或者任何全局上下文中定义的&#xff0c;而是在定义代码块的环境中定义&#xff08;局部…

【C++】【四】企业链表

// 企业链表.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。 // 链表改进版 企业常用#include <iostream> #include<stdlib.h>//链表小节点 不包含数据域 typedef struct linknode {struct linknode* next; }linknode; //链表节点 数据指…

GoldenGate的Logdump工具使用简介

Logdump工具是GoldenGate提供的一个用于查询、分析、过滤、查看和保存存储在trail文件或extract文件中的数据的工具。1、启动Logdump工具[oraclerhel6 ~]$ cd /ogg [oraclerhel6 ogg]$ ./logdumpOracle GoldenGate Log File Dump Utility for Oracle Version 12.2.0.1.1 OGGCOR…

scala惰性函数

惰性计算&#xff08;尽可能延迟表达式求值&#xff09;是许多函数式编程语言的特性。惰性集合在需要时提供其元素&#xff0c;无需预先计算它们&#xff0c;这带来了一些好处。首先&#xff0c;您可以将耗时的计算推迟到绝对需要的时候。其次&#xff0c;您可以创造无限个集合…

计算机组成原理-第3章-3.1

|--总线&#xff1a;本质上就是一组连线&#xff0c;通路 |--发展过程&#xff1a; 分散连接时代&#xff1a; 运算器为中心 ↓ 存储器为中心 ↓ 中断&#xff0c;DMA的出现修正 ↓ 依旧无法解决效率问题 总线连接时代&#xff1a; 以CPU为核心&#xff0c;双总线&#xff1a;M…

【C++】【三】单向链表

// 单向链表.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。 //#include <iostream> #include<stdlib.h>typedef struct LINKNODE {void* data;struct LINKNODE* next; }linknode;typedef struct LINKLIST {LINKNODE* head;int size; }lin…

gulp相关说明

1.当你按下ctrls 或切换到浏览器&#xff0c;浏览器将会会自动刷新 如果你修改的是html文件将会刷新网页如果你修改的是css或less&#xff0c;这个less文件或css文件将会被重载而不是刷新整个页面&#xff08;这个特性在写单页面应用时尤为实用&#xff09;2.模板引入 考虑以下…

IDEA中提示:Warning:java: 源值1.5已过时, 将在未来所有发行版中删除

问题描述&#xff1a; 运行Java Web项目时&#xff0c;IDEA中提示&#xff1a;Warning:java: 源值1.5已过时, 将在未来所有发行版中删除解决方法&#xff1a; 1. 打开【File】—【Project Structure】&#xff0c;找到以下两个地方&#xff1a; Project Structure->Proje…

mysql 数据库乱码

mysql 数据库乱码 转载自https://www.cnblogs.com/gne-hwz/p/8748028.html 如有侵权&#xff0c;请联系。 遇到这种情况&#xff0c;现有项目的数据库已经建好&#xff0c;数据表也已经创建完成。 问题来的&#xff0c;数据库不能插入中文&#xff0c;调试时候发现中文数据从发…

【C++】【二】动态数组-Dynamic_linklist

// dynamicArray.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。 // #include <stdlib.h> #include <iostream>typedef struct DYNAMICARRAY {int* paddr;int size;int capacity; }dynamiCarray;dynamiCarray* Init_dynamiCarray() {dynam…

在MySQL和PostgreSQL之外,为什么阿里要研发HybridDB数据库?

编者按\\在大数据火遍IT界之前&#xff0c;大家对数据信息的挖掘通常聚焦在BI&#xff08;Business Intelligence&#xff09;之上。BI具有着明确的分析需求&#xff0c;清晰地知道需要处理哪些信息&#xff0c;并且如何最终获得多维度的SQL类型数据&#xff0c;这种多维度的分…

Linux命令-安装zip和unzip命令

1 [rootiz2zeea05by6vofxzsoxdbz elasticsearch]# unzip elasticsearch-6.2.4.zip 2 -bash: unzip: command not found 如果你如法使用unzip命令解压.zip文件&#xff0c;可能是你没有安装unzip软件&#xff0c;下面是安装方法 命令&#xff1a; yum list | grep zip/unzip …

【C++】【五】循环链表

数据结构&#xff1a;具体的高效有序的管理内存的方法。 链表&#xff1a;数据结构的一种 节点&#xff1a;每一块内存 每一个节点可以是裸指针 也可以是结构体 &#xff0c;结合企业链表的思路可以将类型强转&#xff0c;完成高效的访问。main.cc // 单向循环链表.cpp …

IntelliJ IDEA 设置项目编码

2019独角兽企业重金招聘Python工程师标准>>> IntelliJ IDEA-> Editor->File Encodings 转载于:https://my.oschina.net/bigxuan/blog/804345

util.sh 脚本

#!/bin/bash for i in zzzhadoop101 zzzhadoop102 zzzhadoop103 doecho " $i "ssh $i /opt/module/jdk1.8.0_144/bin/jps donebin目录是在环境变量里的&#xff0c;所以在哪都可以执行 /home/zzz/bin目录下touch util.sh [zzzhadoop101 bin]$ touch …

bzoj3467: Crash和陶陶的游戏

就一篇题解&#xff1a; BZOJ3467 : Crash和陶陶的游戏 - weixin_34248487的博客 - CSDN博客 1.离线&#xff0c;建出Atrie树&#xff1b;B树的倍增哈希数组&#xff0c;节点按照到根路径字典序排序 2.处理A节点对应前缀对应B中的极长可以匹配的区间。在父亲节点区间内二分即可…

载入图像并且显示

#include <opencv2/opencv.hpp> using namespace cv;void main( ) { const char *fileName "1.jpg";Mat srcImage imread("1.jpg");imshow(fileName,srcImage);waitKey(0); }

alter system switch logfile与alter system archive log current的区别

以前知道 ALTER SYSTEM SWITCH LOGFILE对单实例数据库或RAC中的当前实例执行日志切换&#xff0c; ALTER SYSTEM ARCHIVE LOG CURRENT会对数据库中的所有实例执行日志切换&#xff0c; 所以在RAC环境上大多时间一般使用后者&#xff0c;而今天遇到了不管执行多少次ALTER SYSTEM…

【C++】【六】约瑟夫问题

核心代码&#xff1a; int index 1;clinknode* pcur list->head.next;while (Size_circlelinkist(list)>1){if (index N) {mynum* temnum (mynum*)pcur;printf("%d ", temnum->val);clinknode* pnext pcur->next;RemoveByValue_circlelinkist(list…