日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 人文社科 > 生活经验 >内容正文

生活经验

MATLAB【四】 ————批量适配图片信息与excel/txt等文档信息,批量移动拷贝图片,批量存图片中点和方框

發(fā)布時(shí)間:2023/11/27 生活经验 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 MATLAB【四】 ————批量适配图片信息与excel/txt等文档信息,批量移动拷贝图片,批量存图片中点和方框 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

1、批量讀取圖片,批量讀取文件

2、適配文件與excel、txt等文檔信息

3、獲取顯示圖片ROI、Point、rect、更改像素值

4、批量移動(dòng)拷貝圖片,批量顯示

5、保存顯示圖片或者圖片中的點(diǎn)和方框。

clear;
clc;
close all;%% crop the im into 256*256
num = 0;    %% num=1 內(nèi)縮3個(gè)像素  num =2  內(nèi)縮6個(gè)像素  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);%獲取圖像總數(shù)量 
% 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));% 顯示正在處理的圖像名  
%             %圖像處理過(guò)程 省略  
%             %這里直接可以訪問(wèn)細(xì)胞元數(shù)據(jù)的方式訪問(wèn)數(shù)據(jù)
%         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

getframe

捕獲坐標(biāo)區(qū)或圖窗作為影片幀

frame2im

返回與影片幀關(guān)聯(lián)的圖像數(shù)據(jù)

?

F?= getframe?捕獲顯示在屏幕上的當(dāng)前坐標(biāo)區(qū)作為影片幀。F?是一個(gè)包含圖像數(shù)據(jù)的結(jié)構(gòu)體。getframe?按照屏幕上顯示的大小捕獲這些坐標(biāo)區(qū)。它并不捕獲坐標(biāo)區(qū)輪廓外部的刻度標(biāo)簽或其他內(nèi)容

?

?

總結(jié)

以上是生活随笔為你收集整理的MATLAB【四】 ————批量适配图片信息与excel/txt等文档信息,批量移动拷贝图片,批量存图片中点和方框的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。