scale_interps
PURPOSE
function status=scale_interps(imin,imax,irows,icols,filenums,inroot,outroot,invf);
SYNOPSIS
function status=scale_interps(imin,imax,irows,icols,filenums,inroot,outroot,invf);
DESCRIPTION
CROSS-REFERENCE INFORMATION
This function calls:
This function is called by:
SOURCE CODE
0001 function status=scale_interps(imin,imax,irows,icols,filenums,inroot,outroot,invf);
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 status= -1;
0013
0014 if (nargin~=7) & (nargin~=8)
0015 error('get_interp_range requires 7 or 8 input params. See help.')
0016 end
0017
0018 n=length(filenums);
0019 if n==0
0020 error('Null vector passed as filenums param, asshole.');
0021 end
0022
0023 if imin>=imax
0024 error('Mins must be greater than maxs, dipshit.');
0025 end
0026
0027 if strcmp(inroot,outroot)==1
0028 error('Input and output paths must be different, you must be Doran.');
0029 end
0030
0031 if nargin==8
0032 if (invf~=0) & (invf~=1)
0033 error('Invert flag must be 0 or 1.');
0034 end
0035 else
0036 invf=0;
0037 end
0038
0039 tempdata=zeros(irows,icols);
0040
0041 for f=1:n
0042 infilename=[inroot int2str(filenums(f))];
0043 disp(['Current File: ' infilename]);
0044 if exist(infilename)~=2
0045 disp(['Skipping non-existing input file ' infilename ]);
0046 else
0047 infid=-1;msg='';
0048 [infid,msg]=fopen(infilename);
0049 if infid==-1
0050 disp([msg ': ' infilename]);
0051 else
0052 [tempdata, count]=fread(infid,size(tempdata),'float');
0053 if count~=(irows*icols)
0054 fclose('all');
0055 error(['Error reading file ' infilename]);
0056 end
0057 fclose(infid);
0058 tempdata=round(((tempdata - imin).*255)/(imax-imin));
0059 tempdata=tempdata.*(~(tempdata<0));
0060 tempdata=((tempdata>255)*255)+(tempdata.*(~(tempdata>255)));
0061
0062
0063 fnumstr=int2str(filenums(f));
0064 if filenums(f)<100, fnumstr=['0' fnumstr];end;
0065 if filenums(f)<10, fnumstr=['0' fnumstr];end;
0066 outfilename=[outroot fnumstr];
0067 outfid=-1;msg='';
0068 [outfid,msg]=fopen(outfilename,'w');
0069 if outfid==-1
0070 error(['Error opening output file ' outfilename]);
0071 else
0072 disp(['Output file is ' outfilename]);
0073 if invf==0
0074 count=fwrite(outfid,tempdata,'uchar');
0075 else
0076 count=fwrite(outfid,tempdata','uchar');
0077 end
0078 if count~=(irows*icols)
0079 error(['Error writing scaled data to file ' outfilename]);
0080 end
0081 fclose(outfid);
0082 end
0083 end
0084 end
0085 end
0086
0087 status=1;
Generated on Wed 20-Sep-2023 04:00:50 by m2html © 2003