-
OpenCV中图像Mat存储格式和MATLAB中图像Mat存储格式的区别
2019-04-23 13:05:29首先,看一下图像中的宽高与笛卡尔坐标系之间的关系如下图所示,即x与width(cols)对应,y与height(rows)对应,x是按列来进行变化,y按行...MATLAB读入图像以Mat形式存储时,为Mat(Height,Width),访问时用B=Ma...首先,看一下图像中的宽高与笛卡尔坐标系之间的关系如下图所示,即x与width(cols)对应,y与height(rows)对应,x是按列来进行变化,y按行变化。
OpenCV读入图像以Mat形式存储时,为Mat(Width,Height),访问时用的是A=Mat.at(y,x),y代表行,x代表列;
MATLAB读入图像以Mat形式存储时,为Mat(Height,Width),访问时用B=Mat(y,x),同OpenCV,由于存储时互为转置关系,因此访问同一幅图片中同一个像素,MATLAB里面的Mat(i,j)对应的OpenCV里面为Mat(j,i)。对比如图2
对于opencv的Rect(int x,int y,int width,int height)结构而言,x代表起始点的列坐标(即cols),y代表起始点的行坐标(即rows)。 -
matlab中图像的批量存储与读取
2018-08-27 15:29:41savepath='F:\matlabwork\Target image\blank1'; for i=0:10 x=b+2.5*d+i*7*d; rect=[a+(7*i-4)*d,m-1.5*d,3*d,3*d];... imwrite(A,[savepath,num2str(i'%02d'),'.bmp']);%将处理后的图片保存...图像的批量存储
savepath='F:\matlabwork\Target image\blank1'; for i=0:10 x=b+2.5*d+i*7*d; rect=[a+(7*i-4)*d,m-1.5*d,3*d,3*d]; A=imcrop(im,rect); imwrite(A,[savepath,num2str(i'%02d'),'.bmp']);%将处理后的图片保存在F:\matlabwork\Target image\下,命名为01.bmp end;
图片的批量读写`
str='F:\matlabwork\Target image\blank1-'; %我的图像放在F盘,matlabwork\Target image\图像文件夹下,图片的前缀是blank1-; for i=1:20 I=imread([str,num2str(i),'.bmp']); %依次读取每一幅图像 end
读取指定目录下的图片
Img1=imread('F:\matlabwork\blank\blank81.bmp'); %读取指定文件下的图片
-
mat文件存储struct结构,使用matlab显示图像
2017-11-09 20:21:28使用matlab显示.mat文件的图像(ground truth) 将数组或者矩阵保存为一个mat格式的文件,进行load命令读取a=load('gth.mat'); 当进行imshow(a,[]);显示图像时发生报错: Error using ...使用matlab显示.mat文件的图像(ground truth)
将数组或者矩阵保存为一个mat格式的文件,进行load命令读取a=load('gth.mat');
当进行imshow(a,[]);显示图像时
发生报错:
Error using imageDisplayValidateParams
Expected input number 1, I, to be one of these types:
double, single, uint8, uint16, uint32, uint64, int8, int16, int32, int64, logical
Instead its type was struct.
Error in imageDisplayValidateParams (line 12)
validateattributes(common_args.CData, {'numeric','logical'},...
Error in imageDisplayParseInputs (line 79)
common_args = imageDisplayValidateParams(common_args);
Error in imshow (line 198)
[common_args,specific_args] = ...报错原因:得到的a是struct类型的数据,而imshow()显示应该是一个矩阵或者数组。
如何修改:将命令改写为:a=cell2mat(struct2cell(load('gth.mat')));得到的a即为矩阵。imshow(a,[]);可正常显示。
-
【图像处理】基于matlab GUI图像灰度+缩放+存储处理【含Matlab源码 651期】
2021-03-29 23:44:36一、简介 本GUI实现的功能:加载图片、灰度处理图片、0.5倍缩放...% GUI_TEST MATLAB code for GUI_TEST.fig % GUI_TEST, by itself, creates a new GUI_TEST or raises the existing % singleton*. % % H = GUI_TEST一、简介
本GUI实现的功能:加载图片、灰度处理图片、0.5倍缩放图片、保存处理
版本为R2014a中文版本二、源代码
function varargout = GUI_TEST(varargin) % GUI_TEST MATLAB code for GUI_TEST.fig % GUI_TEST, by itself, creates a new GUI_TEST or raises the existing % singleton*. % % H = GUI_TEST returns the handle to a new GUI_TEST or the handle to % the existing singleton*. % % GUI_TEST('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in GUI_TEST.M with the given input arguments. % % GUI_TEST('Property','Value',...) creates a new GUI_TEST or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before GUI_TEST_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to GUI_TEST_OpeningFcn via varargin. % % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help GUI_TEST % Last Modified by GUIDE v2.5 20-Mar-2020 09:03:44 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @GUI_TEST_OpeningFcn, ... 'gui_OutputFcn', @GUI_TEST_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT % --- Executes just before GUI_TEST is made visible. function GUI_TEST_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to GUI_TEST (see VARARGIN) % Choose default command line output for GUI_TEST handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes GUI_TEST wait for user response (see UIRESUME) % uiwait(handles.figure1); global label; label=0; % --- Outputs from this function are returned to the command line. function varargout = GUI_TEST_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure varargout{1} = handles.output; % --- Executes on button press in pushbutton1. function pushbutton1_Callback(hObject, eventdata, handles) % hObject handle to pushbutton1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global OriginalPic; [filename,pathname]=uigetfile({'*.bmp;*.jpg;*.png;*.jpeg;*.tif'},'选择一个图片','F:\test'); str=[pathname filename]; if isequal(filename,0)||isequal(pathname,0) warndlg('Please select a picture first!','Warning'); return; else OriginalPic= imread(str); axes(handles.axes1); imshow(OriginalPic); end; % --- Executes on button press in pushbutton5. function pushbutton5_Callback(hObject, eventdata, handles) % hObject handle to pushbutton5 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global OriginalPic; global GrayPic; global label; [rows , cols , colors] = size(OriginalPic); %原图的矩阵参数 GrayPic = zeros(rows , cols); %用参数创建一个全零矩阵,来存储用灰度图像 GrayPic = uint8(GrayPic);%图像是double型的,将全零矩阵转化为uint8格式 for i = 1:rows for j = 1:cols GrayPic(i , j) = OriginalPic(i , j , 1)*0.3+OriginalPic(i , j , 2)*0.59+OriginalPic(i , j , 3)*0.11; %按照W=0.30,V=0.59,U=0.11进行加权运算,得到最合理的灰度图像 end end axes(handles.axes2); imshow(GrayPic); label=1; % --- Executes on button press in pushbutton6. function pushbutton6_Callback(hObject, eventdata, handles) % hObject handle to pushbutton6 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global OriginalPic; global ScalePic; global label; ScalePic=imresize(OriginalPic,0.5,'cubic'); axes(handles.axes2); imshow(ScalePic); label=2; % --- Executes on button press in pushbutton7. function pushbutton7_Callback(hObject, eventdata, handles) % hObject handle to pushbutton7 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global OriginalPic; global GrayPic; global ScalePic; global label; [FileName,PathName] = uiputfile({'*.jpg','JPEG(*.jpg)';... '*.bmp','Bitmap(*.bmp)';... '*.gif','GIF(*.gif)';... '*.*', 'All Files (*.*)'},... 'Save Picture','Untitled');
三、运行结果
四、备注
完整代码或者代写添加QQ 1564658423
-
MATLAB图形图像处理
2011-01-03 12:20:118.7.3 图像文件的存储 8.7.4 图像数据类型的转换 8.7.5 图像文件格式的转换 第九章 MATLAB 图像显示与色彩 9.1 图像显示 9.1.1 imshow 函数 9.1.2 显示索引图像 9.1.3 显示灰度图像 9.1.4 显示二值图像 ... -
学习笔记(01):MATLAB图像处理-MATLAB图像表达方式
2021-01-20 12:20:19图像以矩阵存储 图像即矩阵,矩阵即图像 把图像变成矩阵进行处理 matlab中图像可以有两种方式表达,分为像素索引和空间位置 像素索引:图像被视为离散的单元,按照空间顺序从上往下从左往右排列,像素索引值为正整数... -
MATLAB中图像的基本操作
2019-09-27 15:46:02MATLAB中图像的基本操作 1、读取、显示图片 MATLAB中提供了immread()与imshow()...A是结构体名,用来存储读入的图像数据。filename是读取的文件名,文件名要用”括起来。fmt是读取文件的类型如:jpg、png等等,... -
图像在MATLAB中的存储方式
2014-02-28 16:22:51matlab中的数组和C中的不同,举个例子a=[1 2 3;...在C中这么表示肯定是错的,理解这种存储方式后,再看图片,其实在matlab中就是一个二维数组,M*N,M行N列,那么第x列y行的地址就是 x*height+y 。 -
MATLAB数字图像处理基本概念及图像文件读取
2017-03-18 15:14:091.什么是数字图像 数字图像是模拟图像经过采样和量化使其在空间上和数值上都离散化,形成一个数字点阵。 2.数字图像的特点 ...a.目前,数字图像处理的信息大多是二维信息,处理...分辨率是指图像中存储的信息量, -
VC++ matlab图像处理
2013-09-15 15:17:548.7.3 图像文件的存储 8.7.4 图像数据类型的转换 8.7.5 图像文件格式的转换 第九章 MATLAB 图像显示与色彩 9.1 图像显示 9.1.1 imshow 函数 9.1.2 显示索引图像 9.1.3 显示灰度图像 9.1.4 显示二值图像 ... -
matlab 图像输出 命令 imwrite
2017-07-06 19:58:37imwrite输出图像 imwrite(A,FILENAME,FMT) 把图像 A 写入图像文件 FILENAME. A是一张图像数据,FILENAME是要存放图像的文件名,FMT是存放的格式。...如果要存储一张索引图像, 需要指定颜色表,这样在硬 -
【图像处理】基于GUI图像灰度、缩放、存储处理【Matlab 599期】
2021-04-03 18:52:17一、简介 本GUI实现的功能:加载图片、灰度处理图片、0.5倍缩放...% GUI_TEST MATLAB code for GUI_TEST.fig % GUI_TEST, by itself, creates a new GUI_TEST or raises the existing % singleton*. % % H = GUI_TEST -
matlab读bin文件显示图像_Matlab中如何读出写入图像文件以及对图像的简单处理
2020-12-31 08:54:48在MATLAB中如果索引图像的颜色图小于256行,则它的图像矩阵以uint8格式存储,否则以双精度格式存储。一:imread:从图像文件夹中读取图像。A=imread(FILENAME,FMT)读取图像到A,如果文件是包含一灰度图像,A是一二维... -
MATLAB图像处理基础
2021-01-18 16:54:151.1 使用readtable("")导入数据,并存储在表格中,使用axis equal可以校正坐标轴纵横比。 letter = readtable("M.txt"); plot(letter.X,letter.Y) axis equal 1.2 **range(x)**函数返回x的值的范围,即max(x) - min... -
图形图像处理源程序-matlab6.5图形图像处理源程序.rar
2019-08-13 13:22:478.7.3 图像文件的存储 8.7.4 图像数据类型的转换 8.7.5 图像文件格式的转换 第九章 MATLAB 图像显示与色彩 9.1 图像显示 9.1.1 imshow 函数 9.1.2 显示索引图像 9.1.3 显示灰度图像 9.1.4 显示二值... -
matlab 实现图像三通道转为单通道代码实现
2020-01-03 21:37:19pathdir = 'F:/#Study/Infrared target track/video/a/17/';%三通道图片所在文件夹路径 format = 'jpg';%图片文件格式 files=dir(strcat(pathdir,'*.',format));%读取所有的图片文件名存储在files steps=100; hwait... -
matlab实现改变指定图像的尺寸,然后存储到指定的文件夹
2016-11-21 18:10:21[filename,pathname]=uigetfile('*','choose a picture'); path=[pathname,filename]; Origimg=imread(path); img=imresize(Origimg,[480 640]);%改变图像尺寸的大小为480*640 %设定存储的文件夹 path='E:\Code... -
MATLAB实现图像镜像变换的源代码!
2016-05-14 15:20:56还是直接上源码和运行结果吧! clear all; close all; clc; A=imread('pout_gray.png'); [height,width,dim]=size(A); tform=maketform('affine',[-1 0 0;...B=imtransform(A,tform,'nearest');%B中存储... -
MATLAB 图像处理相关知识
2015-06-28 21:51:31%% 读取图像与现实图像 fig = imread('1.jpg'); imshow(fig); %% 转化为灰度图像 fig_bw = rgb2gray(fig);...%% 将图像转化为二值图像 ...a = imread('1.jpg');...bw1 = im2bw(a,0.5);...%% 图像存储或进行图像格 -
matlab6.5图形图像处理源程序
2011-09-21 18:27:518.7.3 图像文件的存储 8.7.4 图像数据类型的转换 8.7.5 图像文件格式的转换 第九章 MATLAB 图像显示与色彩 9.1 图像显示 9.1.1 imshow 函数 9.1.2 显示索引图像 9.1.3 显示灰度图像 9.1.4 显示二值图像 ... -
Converting Between Image Classes (matlab 中图像类之间的转换)
2014-09-21 16:41:00首先类似于C中的类型转换,matlab中也有其对应的类型转换。 For example, a=2;double(a) ---> 2.0 or 更多位数 a=2.1;uint8(a) ---> 2,反正是去掉了小数部分。 因为uint8是八个bit即一个byte存储的,因此... -
MATLAB图像处理基本操作(1)
2020-10-03 22:51:38本示例读取一个名为peppers.png的图像,并将其存储在名为a的数组中:a = imread('peppers.png'); b)显示图像,imshow函数 imshow(a); %显示图像 一个可用于显示图像的功能是imagesc。 imagesc(a); %将... -
MATLAB字符串数组存储为CSV格式
2020-07-21 23:10:29搬运自matlab官网的代码:https://www.mathworks.com/matlabcentral/fileexchange/7601-cell2csv?s_tid=mwa_osa_a 以下为MATLAB cell array to csv的函数实现: function cell2csv(filename,cellArray,delimiter)... -
数字图像处理及应用(MATLAB)第1章教学文案.ppt
2020-08-17 08:40:57i 表示垂直方向j表示水平方向这样从左上角开始纵向第 i 行横向第j列的第ij像素就存储到矩阵的元素fij中数字图像中的像素与二维矩阵中的每个元素便一一对应起来a所示图像可用图c所示矩阵表示 ; (a) -
matlab练习程序(奇异值分解压缩图像)
2019-07-05 17:58:47介绍一下奇异值分解来压缩图像。今年的上半年中的一篇博客贴了一篇用奇异值分解处理pca问题的程序,当时用的是图像序列,是把图像序列中的不同部分分离开来。...比如一幅1000*1000的图像A,存储就需要100000... -
基于自适应扫描次序的二叉树图像编码方法matlab代码
2014-01-04 19:47:25[原创]本matlab代码是2012年发表在IEEE Transactions on Geoscience and Remote Sensing(2012 IEEE TGRS IF=3.467)的一篇文章A new on-board image codec based on binary tree with adaptive scanning order in ... -
Matlab在高光谱图像处理上的使用指南(不断补充ing)
2020-01-13 22:10:31一、常用命令: 1、数据读取:load( ) & save( ) : Matlab会自动保存并区分我们所存储的内容。...save mydata A M %save命令会将当前工作区(workspace)内的A变量和M变量存储在“mydata.mat...