function Height = ind2height(Header, Image) %IND2HEIGHT Convert the image data into heigth values in nm. % % K = IND2HEIGHT(HEADER, IMAGE) % % return a matrix of the same size as IMAGE % conteining the height values in nm. % The trasformation has done on the base of the % formulas reported at pag 85 of the STM manual. % % See also ... % % Claudio 11 August 1994 % % if it is an imported image and alex added the Trasform Factor % parameter to the header. % % If the message Image data UNKNOWN appears you should add to this function % the appropriate transformation of your data. % % Copyright (c) 1995 by Claudio Rivetti and Mark Young % claudio@alice.uoregon.edu, mark@alice.uoregon.edu % fact=getparameter(Header, 'Trasform. Factor', 1); if fact ~= inf & ~isempty(fact) Height = Image * fact; return; end %For a version 4 file format if getparameter(Header, 'Version',1) ~= inf [zs, u]=zscale(Header); Height=Image*(zs/65536); return; end % Get the image type Imtype = getparameter(Header, 'Image data', 1); if strcmp(Imtype, 'Height') == 1 %for Height data Zscale = getparameter(Header, 'Z scale height', 1); if Zscale == inf q = getparameter(Header, 'Z scale', 1); i = q(1)+2; Zscale = q(i); end Zatten = getparameter(Header, 'Z atten.', 1); Zmax = getparameter(Header, 'Z max', 1); Zsens = getparameter(Header, 'Z sensitivity', 1); fact = ((Zscale*Zatten/65536) * (Zmax*2/65536*Zsens))/65536; Height = Image * fact; elseif strcmp(Imtype, 'Deflection') == 1 %for deflection data % I don't know what is Graph range Grange = getparameter(Header, 'Graph range', 1); In1max = getparameter(Header, 'In1 max', 1); Insens = getparameter(Header, 'In sensitivity', 1); Insens = sscanf(Insens, '%f'); Detectsens = getparameter(Header, 'Detect sens.', 1); fact = ((Grange*In1max*2/65536) * (Insens/Detectsens))/65536; Height = Image * fact; else message('Image data UNKNOWN.|Please check the functions:| ind2height.m and height2ind.m||Data converted to grayscale'); Height = (Image-min(min(Image)))/(max(max(Image))-min(min(Image))); end return