function [sig_overhead, block_rate_overhead, bit_plane_overhead] = calculate_overhead(block_rate, largest_bit_plane)

%parts of the overhead are encoded using the arithmetic coding engine from 
%http://marknelson.us/1991/02/01/arithmetic-coding-statistical-modeling-data-compression/

significance_plane = block_rate;
significance_plane(significance_plane >0) = 1;


block_rate = block_rate(significance_plane == 1);

%Ensure that the data is only made from 8 bit chars
block_rate = transform_block_rate_into_8bit_char(block_rate);

largest_bit_plane = largest_bit_plane(significance_plane == 1);


%Encoder significance plane overhead
fid = fopen('data.txt', 'wb');
fwrite(fid, significance_plane);
fclose(fid);
%Encode 
dos('comp-2_overhead -f data.txt -c test.cmp');
fid = fopen('test.cmp', 'rb');
A = fread(fid);
fclose(fid);
sig_overhead = length(A)*8;

%Encoder the block rate overhead
fid = fopen('data.txt', 'wb');
fwrite(fid, block_rate);
fclose(fid);
%Encode 
dos('comp-2_overhead -f data.txt -c test.cmp');
fid = fopen('test.cmp', 'rb');
A = fread(fid);
fclose(fid);
block_rate_overhead = length(A)*8;


%Encoder the largest bit plane
fid = fopen('data.txt', 'wb');
fwrite(fid, largest_bit_plane);
fclose(fid);
%Encode 
dos('comp-2_overhead -f data.txt -c test.cmp');
fid = fopen('test.cmp', 'rb');
A = fread(fid);
fclose(fid);
bit_plane_overhead = length(A)*8;



end