function [image_volume, mm2pp, camrate]=compute_image_volume
%Computes imaged volume from calibration file (e.g. c:\data\shunyo\calibration\imvol_dim.mat)
%The method sums the volumes of the four truncated triangular prism-shaped volumes 
%that make up the imaged volume.  Each prism volume is defined by two edges of the imaged volume
%at the corners of the field of view and the center line.
%The image_volume is in milliliters.

 
global basepathcruise cruise

eval(['load ' basepathcruise '\calibration\imvol_dim']);%loads the variables calibdata and camrate
camrate=str2num(camrate);
a=fieldnames(calibdata);
a=str2mat(a);
for j=1:size(a,1), eval([deblank(a(j,:)) '=str2num(calibdata.' deblank(a(j,:)) ');']);end
ul=abs(uln-ulf)/10;%divide by 10 to convert from mm to cm
ll=abs(lln-llf)/10;
c=abs(cn-cf)/10;
ur=abs(urn-urf)/10;
lr=abs(lrn-lrf)/10;
area=fh/10/2*fw/10/2;
prism_left_volume=(ul+ll+c)/3*area;
prism_top_volume=(ul+ur+c)/3*area;
prism_bottom_volume=(ll+lr+c)/3*area;
prism_right_volume=(ur+lr+c)/3*area;
image_volume=prism_left_volume+prism_top_volume+prism_bottom_volume+prism_right_volume;
%compute single pixel area in square millimeters
%pixel dimensions for digital camera are 1009 wide by 984 high
%and pixels are square so only need to use one dimension, choose x
if strcmp(cruise,'nbp0103_cam2'),
    npx=640;%found from # of pixels in largest rois (130kb rois are 640x207 pixels).
    npy=207;
elseif strcmp(cruise,'remusvprCCB0303'),
    npx=720;%AutoDeck.exe extraction of rois from wavelet files created by invaderwave board and autovpr.exe
    npy=480;%gives these dimensions for full field rois.
else
    npx=984;%new digital pulnix camera has 984 x 1009 pixels.
    npy=1009;
end
mm2pp=((fw/npx)*(fh/npy));
