| 查看: 3128 | 回复: 11 | |||
afgh2587849木虫 (小有名气)
|
[交流]
【求助】matlab如何只读取图像的一部分?已有7人参与
|
||
| 用matlab处理图像的时候遇到了一个问题,图像太大而且数目比较多,但感兴趣的只是图像中的一部分,现在想做的就是比如说对1024*1024的图像只读取200*200的这一小部分,不是先把整幅图像读进来然后再取矩阵的一部分,而是一开始就只读这一小部分图像,请问该如何操作? |
» 猜你喜欢
2025冷门绝学什么时候出结果
已经有3人回复
天津工业大学郑柳春团队欢迎化学化工、高分子化学或有机合成方向的博士生和硕士生加入
已经有4人回复
康复大学泰山学者周祺惠团队招收博士研究生
已经有6人回复
AI论文写作工具:是科研加速器还是学术作弊器?
已经有3人回复
孩子确诊有中度注意力缺陷
已经有6人回复
2026博士申请-功能高分子,水凝胶方向
已经有6人回复
论文投稿,期刊推荐
已经有4人回复
硕士和导师闹得不愉快
已经有13人回复
请问2026国家基金面上项目会启动申2停1吗
已经有5人回复
同一篇文章,用不同账号投稿对编辑决定是否送审有没有影响?
已经有3人回复
» 本主题相关价值贴推荐,对您同样有帮助:
Matlab图像处理问题
已经有10人回复
matlab如何读取一个文件夹下的所有图片
已经有9人回复
MATLAB能读出工具软件,如一些做图软件,或直接手汇的图(再扫描入电脑)里的数据吗?
已经有4人回复
matlab中bicubic如何进行图像抽样
已经有3人回复
求助Matlab图像加入噪声的问题
已经有1人回复
【求助】如何获得matlab中当前fig图像的信息
已经有6人回复
matlab做函数图象的问题
已经有6人回复
【求助】如何用matlab绘图图中阴影部分
已经有4人回复
afgh2587849
木虫 (小有名气)
- 应助: 2 (幼儿园)
- 金币: 3498.5
- 红花: 1
- 帖子: 200
- 在线: 61.8小时
- 虫号: 925965
- 注册: 2009-12-12
- 专业: 信号理论与信号处理
5楼2010-11-18 04:43:15
★
小木虫(金币+0.5):给个红包,谢谢回帖交流
小木虫(金币+0.5):给个红包,谢谢回帖交流
|
你参考下rawread函数。 function [X,map] = rawread(filename,n,m); % RAWREAD Read a Portable Bitmap file, or a raw file. % RAWREAD('imagefile.raw', xsize, ysize) reads a "raw" image file % RAWREAD('imagefile.pgm') reads a "pgm" (portable gray map) image % [X,map] = RAWREAD('imagefile.raw') returns both the image and a % color map, so that % [X,map] = rawread('imagefile.raw',sx,sy); % or [X,map] = rawread('imagefile.pgm'); % image(X) % colormap(map) % will display the result with the proper colors. % % NOTE : map is optional and could be replaced during the display by % the "colormap('gray')" command % % See also IMWRITE, IMREAD, IMAGE, COLORMAP. dot = max(find(filename == '.')); suffix = filename(dot+1:dot+3); % 提取图像文件后缀 if strcmp(suffix,'pgm') | strcmp(suffix,'raw') % 要求是pgm格式或者raw格式 disp(sprintf('\nopens %s file\n',filename)); fp = fopen(filename,'rb','b'); % "Big-endian" byte order. if (fp<0) error(['Cannot open ' filename '.']); end if strcmp(suffix,'pgm') % Read and crack the header head = fread(fp,2,'uchar'); % pgm magic number : P5 if ~strcmp(head,'P5'), fprintf(1,'\n Magic Number : %s\n',head); % 默认打印到窗口 else fprintf(1,'\n Bad Magic Number : %s\n',head); error('cannot continue this way, good bye cruel world'); end c = fread(fp,1,'uchar'); %reads the carriage return separating P5 from the creator precreator = fread(fp,1,'uchar'); % look for a '#' character preceeding a creator signature if precreator == '#', c = setstr(20); % any character except carriage return cr = setstr(10); % defines a carriage return while c ~= cr, c = fread(fp,1,'uchar'); creator = [creator,c]; end; fprintf(1,'\n creator : %s\n',creator); else fprintf('\n No creator signature\n'); fseek(fp,-1,'cof'); % return one char before end end if nargin <2, if strcmp(suffix,'raw') % assume image size is 256x256 disp('RAW file without size : assume image size is 256x256'); n = 256; m = 256; else % for PGM files % reads the size and depth % pgm格式开头包括维数 disp(' reads sizes'); n = fscanf(fp,'%d',1); tn = num2str(n); disp([' xsize = ' tn]); m = fscanf(fp,'%d',1); tm = num2str(m); disp([' ysize = ' tm]); p = fscanf(fp,'%d',1); tp = num2str(p); disp([' depth = ' tp]); c = fread(fp,1,'uchar'); %reads the last carriage return end; end % Creates a gray palette and scale it to [0,1]. disp(' create gray palette'); % 灰度映射表 for i=1:256, map(i,[1:3])=[i/256,i/256,i/256]; end; % Read the image disp(' Reads image data ...'); [X,l] = fread(fp,[n,m],'uchar'); % 维数错了 if l ~= m*n l error('HSI image file is wrong length') end % Image elements are colormap indices, so start at 1. X = X'+1; fclose(fp); disp('end'); else error('Image file name must end in ''raw'' or ''pgm''.') end |
6楼2010-11-18 18:22:50
2楼2010-11-15 20:26:25
afgh2587849
木虫 (小有名气)
- 应助: 2 (幼儿园)
- 金币: 3498.5
- 红花: 1
- 帖子: 200
- 在线: 61.8小时
- 虫号: 925965
- 注册: 2009-12-12
- 专业: 信号理论与信号处理
3楼2010-11-16 03:40:24
4楼2010-11-17 05:00:21
image_pro
新虫 (初入文坛)
- 应助: 0 (幼儿园)
- 金币: 417.3
- 散金: 20
- 帖子: 37
- 在线: 7.8小时
- 虫号: 1171273
- 注册: 2010-12-16
- 专业: 控制理论与方法
7楼2010-12-21 16:25:00
afgh2587849
木虫 (小有名气)
- 应助: 2 (幼儿园)
- 金币: 3498.5
- 红花: 1
- 帖子: 200
- 在线: 61.8小时
- 虫号: 925965
- 注册: 2009-12-12
- 专业: 信号理论与信号处理
8楼2010-12-23 23:31:29

9楼2010-12-26 23:14:16
afgh2587849
木虫 (小有名气)
- 应助: 2 (幼儿园)
- 金币: 3498.5
- 红花: 1
- 帖子: 200
- 在线: 61.8小时
- 虫号: 925965
- 注册: 2009-12-12
- 专业: 信号理论与信号处理
10楼2010-12-27 01:29:20













回复此楼