Skip to main content
Question

Matlab function to read .bim files

  • 28 May 2024
  • 0 replies
  • 29 views

For anyone that finds it useful:

Below is a simple function to read .bim files into matlab

The inputs are the .bim file name and image width

This was written to consume the output from ‘Geometric Image Analysis’.

Values are consistent with units displayed in zemax as long as the Total Watts = 1

function tim] = imReadBIM(fileName,image_width)
% read Zemax .bim file format
% John Hygelund, May 28, 2024
% example use: imagesc(imReadBIM('spot.bim',.003)), axis image, colorbar, colormap jet

fid = fopen(fileName, 'r');
size = fread(fid, 1:2, 'int32');
im = fread(fid, inf, 'float64');
fclose(fid);

im = reshape(im,esize(1) size(2)]);
im = im';
im = flip(im);

im = im ./ sum(im(:)); % normalize to total weight of rays
im = im ./ (image_width./size(1)).^2; % normalize to area of pixel

 

0 replies

Be the first to reply!

Reply