matlab读写pgm文件
来源:互联网 发布:淘宝平台 编辑:程序博客网 时间:2024/06/03 14:35
读文件
%function disp_pgm(pgm_image_name)
%不支持文件中有注释
pgm_image_name='tmp.pgm';
f = fopen(pgm_image_name,'r');
if f == -1
error(['Could not open file ',pgm_image_name]);
end
[imgsize, num]=fscanf(f, 'P5\n%d\n%d\n255\n');
if num~=2,error('error num');end
image=[];
for h=1:imgsize(2)
image=[image fread(f,imgsize(1),'uint8')];
end
image=image.';
fclose(f);
imshow(image);
写文件
% Load image
% image = imread(imageFile);
% If you have the Image Processing Toolbox, you can uncomment the following
% lines to allow input of color images, which will be converted to grayscale.
if isrgb(image)
image = rgb2gray(image);
end
[rows, cols] = size(image);
% Convert into PGM imagefile, readable by "keypoints" executable
f = fopen('tmp.pgm', 'w');
if f == -1
error('Could not create file tmp.pgm.');
end
fprintf(f, 'P5\n%d\n%d\n255\n', cols, rows);
fwrite(f, image', 'uint8');
fclose(f);
- matlab读写pgm文件
- matlab读写pgm文件
- PGM文件读写
- 【数字图像处理】pbm/pgm/ppm图片的读写(Matlab)
- PGM格式图像文件读写
- Matlab 文件读写函数
- Matlab文件读写函数
- matlab 读写txt文件
- matlab 读写txt文件
- MATLAB读写mat文件
- matlab 读写txt文件
- Matlab读写文件
- matlab 文件操作,读写
- MATLAB读写文件汇总
- Matlab读写excel文件
- matlab读写txt文件
- matlab文件读写
- matlab读写文件
- hadoop2.7.4的安装
- OPC数据访问方法简介
- Java程序员面试题及解答(一)
- spring笔记6-事物及整合hibernate
- Java递归删除树形结构父节点
- matlab读写pgm文件
- C++中的重写、重载、重定义
- 排序算法之归并排序及利用归并排序求逆序数
- hdu 1224
- HDU1272 小希的迷宫 并查集入门||判环
- Java程序员面试题及解答(二)
- ASP.Net 总结
- JNDI
- 欢迎使用CSDN-markdown编辑器