function photo = imread_pct(fingerprint_file) % imread_pct.m % load a fingerprint from a ".pct" file, % such as the ones in % ftp://sequoyah.ncsl.nist.gov/pub/databases/data/prints9.tar.Z % . % Usage: % photo = imread_pct('H:\compression\compression\nist\f0000001.pct'); % image(photo); % colormap(gray(256)) % axis equal % axis tight % `fingerprint_file' must be the *full* path+filename of a ".pct" file. % FIXME: this should really be merged into the IMREAD % routine, to automatically detect '.pct' files. % See also IMREAD, IMREAD_FITS. % change log: % 1999-05-13:DAV: started (based on my imread_fits.m). % David Cary % open the file % if the images look funny, omit the ieee-be flag fp = fopen(fingerprint_file,'r','ieee-be'); if(fp==-1) error(['Can''t open the file ' fingerprint_file ' in imread_pct.m']); else header_string = char(fread(fp, 8, 'char')'); expected_header_string = zeros(1,8); expected_header_string(1:3) = '288'; expected_header_string = char(expected_header_string); if(~strncmp(expected_header_string, header_string, 8)) error([... '??? Error using ==> imread_pct\n'... 'Unable to determine the file format\n'... '['... fingerprint_file ... '] Not in fingerprint format.'... ]) else [header_length] = sscanf(header_string, '%i') s = char(fread(fp, header_length, 'char')') width = sscanf(s((106+1):(106+8)), '%i'); height = sscanf(s((106+1+8):(106+8+8)), '%i'); [bits_per_pixel] = sscanf(s((106+1+8+8):(106+8+8+8)), '%i'); compression_code = sscanf(s((106+1+8+8+8+8):(106+8+8+8+8+8)), '%i'); % s = char(fread(fp, 80, 'char')'); % disp(['[' s ']']) % s = char(fread(fp, 80, 'char')'); % disp(['[' s ']']) % datastart = ftell(fp); if( ~isequal( 8, bits_per_pixel ) ) bits_per_pixel error([... 'Sorry -- reading this type of image not yet implemented.\n',... 'Check (d.cary at ieee.org) for a later version.']); end if( ~isequal( 0, compression_code ) ) error([... 'Sorry -- reading compressed image not yet implemented.\n',... 'Check (d.cary at ieee.org) for a later version.']); end % photo=zeros(height, width); % Assumes 8 bits per pixel. % Transpose needed to make it look right on screen. % fseek(fp, datastart, 'bof'); photo = uint8(fread(fp,[width height],'uint8'))'; end; fclose(fp); end % end imread_pct.m