ldimgff.m

来自「改进等高线拟合代码」· M 代码 · 共 95 行

M
95
字号
function [img] = ldmimgff(name);% LDIMGFF: Load image from file (Part of GUI)% All the software included in this package is presented as is.% It may be distributed freely. The author can, however, not be% held responsible for any problems whatever.% % Designed by Johan Baeten.% Last updated: 22-03-2000% Johan.baeten@mech.kuleuven.ac.beglobal XSIZE;global YSIZE;global IMAGENAMEglobal MAINFIGglobal NEWIMAGENAMEglobal MAP%nargs= nargin;if nargin == 0,  [filename, PATHNAME]= uigetfile('*.pgm','Select Image');else   filename = name;endlen = length(filename);if (len < 4),      % probally cancel in uigetfile  seterror([' ... cancelled']);  return;endfilename = lower(filename);ext = filename(len-3:len);if ~((strcmp(ext,'.gry'))|(strcmp(ext,'.pgm'))),   seterror(' ... Only ''.gry'' and ''.pgm'' supported.');         return;endfid = fopen(filename);if (fid == -1),   seterror(' ... Can''t load file. File doesn''t exist');   % this can/should never happenelse   if strcmp(filename(len-2:len),'gry'),      seterror([' ... Opening ',filename,' with set image sizes.']);      watchon;      drawnow;      [a]=fscanf(fid,'%c',[XSIZE YSIZE]);      fclose(fid);   else      seterror([' ... Opening ',filename]);      watchon;      drawnow;            format = fscanf(fid,'%s',1);      XSIZE = fscanf(fid,'%d',1);      YSIZE = fscanf(fid,'%d',1);      grayvalues = fscanf(fid,'%d',1);      dummy = fscanf(fid,'%c',1);      [a]=fscanf(fid,'%c',[XSIZE YSIZE]);      fclose(fid);      MAP = gray(255);   end   IMAGENAME = filename;   if (XSIZE <= 64) & (YSIZE <= 64),      setting('imagesize64');   elseif (XSIZE <= 128) & (YSIZE <= 128),      setting('imagesize128');   elseif (XSIZE <= 256) & (YSIZE <= 256),      setting('imagesize256');   elseif (XSIZE <= 512) & (YSIZE <= 512),      setting('imagesize512');   else      setting('imagesizenn');   end   set(MAINFIG,'userdata',(abs(a)'));	if nargout == 0,   	set(findobj(gca,'type','image'),'cdata',(abs(a)'));        setting ('showimage');      setting('drawaxes');   	setting('saveimageenableon');	   drawnow;	else	   img = (abs(a)') ;	end   watchoff;end

⌨️ 快捷键说明

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