⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pgm2x.m

📁 支持向量机工具箱
💻 M
字号:
function [x,width,height]=pgm2x(fname, normalize)% PGM2X leads PGM image from file.% [x,width,height]=pgm2x(fname, normalize)%% PGM2X loads an image from file which must be in the PGM %  format. The loaded image is returned as a column vector %  of doubles. If normalize is set to 1 then image values%  will be normalized to range <0,1>.% %  % Input:%  fname [string] file nam of the image.%  normalize [int] if equal to 1 then output x is in range <0,1>.%% Output:%  x [width x height] vector containg read image.%  width [1x1] width of the image.%  height [1x1] height of the image.%% See also X2PGM%% Statistical Pattern Recognition Toolbox, Vojtech Franc, Vaclav Hlavac% (c) Czech Technical University Prague, http://cmp.felk.cvut.cz% Written Vojtech Franc (diploma thesis)% Modifications% 27-sep-2001, V.Franc, argument normallized% 26-feb-2001 V.Francif nargin < 2,  normalize = 0;endfid=fopen(fname,'r');line1=fgets(fid);line2=fgets(fid);line3=fgets(fid);a = sscanf(line2,'%d');width=a(1);height=a(2);prec= sscanf(line3, '%d');if  prec==255,  precision='uchar';elseif prec==65535,  precision='int16';end[x, count] = fread(fid,inf,precision);fclose(fid);if count ~= width*height,  error('Invalid input format.');  return;endx=x(:);if normalize == 1,   x=double(x)/prec;endreturn;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -