Skip to main content
Question

Matlab function to read .bim files


John.Hygelund
Fully Spectral
Forum|alt.badge.img+1

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 [im] = 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,[size(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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings