資源簡介
利用matlab讀取raw文件并畫出對應的灰度圖像,給出灰度條。(注:M文件)
代碼片段和文件信息
function?[imagedata]?=?dpcrawprocessing(filename);
%fnum?=?str2num(filename(1));
dot?=?max(find(filename?==?‘.‘));
suffix?=?filename(dot+1:dot+3);%?提取圖像文件后綴
name?=?filename(1:dot-1);%?提取圖像文件名
if?strcmp(suffix‘raw‘)???%?要求是raw格式
????disp(sprintf(‘\nOpens?%s?file\n‘filename));
????fp?=?fopen(filename);??%?“Big-endian“?byte?order.
????if?(fp<0)
????????error([‘Cannot?open?‘?filename?‘.‘]);
????end
????%?Creates?a?gray?palette?and?scale?it?to?[01].
????%disp(‘Creating?gray?palette...‘);
????%?灰度映射表
???%?for?k=1:512
?????%???map(k[1:2])=[k/512k/512];
???%?end;
????
????%??讀取raw文件,并以矩陣顯示
image?=?fread(fp‘uint16‘);
imagesize?=?sqrt(size(image(:1)));
for?i=1:imagesize
for?j=?1:imagesize
- 上一篇:添加回聲matlab
- 下一篇:kmeans聚類程序
評論
共有 條評論