MATLAB常见函数
2016-12-07 09:40
411 查看
设图像矩阵为A。。
1、读取图像
imread
2、显示图像
imshow(A,[])
3、保存图像
imwrite
○ 作用:imwrite Write image to graphics file.
○ 用法:imwrite(A,FILENAME,FMT) writes the image A to the file specified by FILENAME in the format specified by FMT.
○ 说明:FILENAME is a string that specifies the name of the file.最好是绝对路径文件名,这样就可以保存到自己想要的路径中。
调用方式:
dir(‘.’)列出当前目录下所有子文件夹和文件
dir(‘G:\Matlab’)列出指定目录下所有子文件夹和文件
dir(‘*.m’)列出当前目录下符合正则表达式的文件夹和文件
返回:
返回一个结构体,包含5个字段
name(the first two are . and ..)
date
bytes
isdir(0:not , 1:is)
datenum
例子:
1、方法一:
用中括号将str1和str2像矩阵元素一样包含起来:
SC=[str1,str2]
输出:SC = Iloveyou123
rgb2gray converts RGB images to grayscale by eliminating the hue and saturation information while retaining the luminance.
I = rgb2gray(RGB) converts the truecolor image RGB to the grayscale intensity image I.
NEWMAP = rgb2gray(MAP) returns a grayscale colormap equivalent to MAP.
Class Support
If the input is an RGB image, it can be uint8, uint16, double, or single. The output image I has the same class as the input image.
If the input is a colormap, the input and output colormaps are both of class double.
Example
1、读取图像
imread
2、显示图像
imshow(A,[])
3、保存图像
imwrite
○ 作用:imwrite Write image to graphics file.
○ 用法:imwrite(A,FILENAME,FMT) writes the image A to the file specified by FILENAME in the format specified by FMT.
○ 说明:FILENAME is a string that specifies the name of the file.最好是绝对路径文件名,这样就可以保存到自己想要的路径中。
dir
Matlab使用dir函数获得指定文件夹下的所有子文件夹和文件,并存放在在一种为文件结构体数组中.调用方式:
dir(‘.’)列出当前目录下所有子文件夹和文件
dir(‘G:\Matlab’)列出指定目录下所有子文件夹和文件
dir(‘*.m’)列出当前目录下符合正则表达式的文件夹和文件
返回:
返回一个结构体,包含5个字段
name(the first two are . and ..)
date
bytes
isdir(0:not , 1:is)
datenum
例子:
file_dir = dir([path '*.bmp']); dircell = struct2cell(file_dir); fileNames = dircell(1,:); for i = 1:length(fileNames) fileName = char(fileNames(i)); end
trainingFiles = dir('pristine'); trainingIms = cell(length(trainingFiles)-2,1); for fileIndex = 3:length(trainingFiles) %the first two are . and .. currentFileName = ['pristine\' trainingFiles(fileIndex).name]; image = imread(currentFileName); resizedIm = imresize(image, [normalizedWidth normalizedWidth]); trainingIms{fileIndex-2} = resizedIm; end
构造绝对路径,将两个字符串连载一起的方法
str1=’Iloveyou’; str2=’123’;1、方法一:
用中括号将str1和str2像矩阵元素一样包含起来:
SC=[str1,str2]
输出:SC = Iloveyou123
rgb2gray
rgb2gray Convert RGB image or colormap to grayscale.rgb2gray converts RGB images to grayscale by eliminating the hue and saturation information while retaining the luminance.
I = rgb2gray(RGB) converts the truecolor image RGB to the grayscale intensity image I.
NEWMAP = rgb2gray(MAP) returns a grayscale colormap equivalent to MAP.
Class Support
If the input is an RGB image, it can be uint8, uint16, double, or single. The output image I has the same class as the input image.
If the input is a colormap, the input and output colormaps are both of class double.
Example
I = imread('board.tif'); J = rgb2gray(I); figure, imshow(I), figure, imshow(J);
[X,map] = imread('trees.tif'); gmap = rgb2gray(map); figure, imshow(X,map), figure, imshow(X,gmap);
相关文章推荐
- matlab 常见的函数用法
- matlab常见的运算函数
- MatLab常见函数和运算符号
- matlab 中一些常见的函数1
- 四、Matlab 之 常见函数的使用
- MATLAB内置常见函数
- MATLAB算数运算符及常见函数
- 【matlab图像处理】matlab图像处理常见函数及联系
- 常见的Matlab运算函数
- matlab常见变量和函数
- 离散时间信号常见函数的实现(matlab)
- Afx全局函数及MFC常见数据类型
- asp.net常见开发的一些函数
- MATLAB主要函数命令分类
- oracle 常见函数
- Matlab入门教程--基本运算与函数(一)
- Afx全局函数及MFC常见数据类型
- JS常见函数
- Matlab函数一点收集
- VC与Matlab联合编程常见问题集合