毕业设计——人脸检测——001 图片导入MATLAB

来源:互联网 发布:中国软件评测 编辑:程序博客网 时间:2024/04/30 11:57

问题:如何导入图片到MATLAB


解决:

Image1 = imread('E:\Graduate project\Database\test\subject01.centerlight.gif');  % 括号内为绝对路径

Image2 = imread('subject01.centerlight.gif');  %使用文件相对路径

Image3 = imread('subject01.centerlight','GIF');  %注意文件只有文件名,无后缀(不区分大小写),记着加引号

imshow(Image1);%显示


IMREAD Read image from graphics file.
A = IMREAD(FILENAME,FMT) reads a grayscale or color image from the file specified by the string FILENAME. If the file is not in the current directory, or in a directory on the MATLAB path, specify the full pathname.    
The text string FMT specifies the format of the file by its standard file extension. For example, specify 'gif' for Graphics Interchange Format files. To see a list of supported formats, with their file extensions, use the IMFORMATS function. If IMREAD cannot find a file named FILENAME, it looks for a file named FILENAME.FMT. 
The return value A is an array containing the image data. If the file contains a gray scale image, A is an M-by-N array. If the file contains a true color image, A is an M-by-N-by-3 array. For TIFF files containing color images that use the CMYK color space, A is an M-by-N-by-4 array. See TIFF in the Format-Specific Information section for more information.

上面英文帮助来自MATLAB帮助文档(在MATLAB Command Window使用‘help imread’可以查询到)


MATLAB注释方式:

A、

%{

    若干语句,测试可以使用,注意括号都在百分号后面

%}

B、

多行注释: 选中要注释的若干语句, 编辑器菜单Text->Comment, 或者快捷键Ctrl+R

取消注释: 选中要取消注释的语句, 编辑器菜单Text->Uncomment, 或者快捷键Ctrl+T

(Ctrl+R注释多行,Ctrl+T取消注释)

C、

if LOGICAL(0)

若干语句

end

这个方法实际上是通过逻辑判断语句不执行相关的语句

最后一种方法还没有测试使用过,会在以后的学习中测试(???)


注释方法参考:http://icictech.blog.163.com/blog/static/2797425420084595725499/ 

    http://blog.sciencenet.cn/home.php?mod=space&uid=296318&do=blog&id=273228 


用类似下面的语句导入多幅图片数据:

geshi = {'*.jpg','JPEG image (*.jpg)';...       '*.bmp','Bitmap image (*.bmp)';...       '*.*','All Files (*.*)'};[FileName FilePath] = uigetfile(geshi,'导入外部图片','*.jpg','MultiSelect','on');if ~isequal([FileName,FilePath],[0,0]);    FileFullName = strcat(FilePath,FileName);    if iscell(FileName)        FileFullName = FileFullName([2:end 1])';        FileName = FileName([2:end 1])';    else        FileName = {FileName};        FileFullName = {FileFullName};    endelse    return;endn = length(FileFullName);for i=1:n    Ii = imread(FileFullName{i});end
上面方法来自:http://www.matlabsky.com/thread-13432-1-1.html @xiezhh

相关链接还有:http://www.ilovematlab.cn/thread-27106-1-1.html

           http://www.paper.edu.cn/paper.php?serial_number=200812-844 图片导入matlab后色彩分量矩阵的处理


在此对各位表示谢意