% clear workspace and command line
clear;clc;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% START OF PART1: LOAD VOLUME DATA
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% read file
fid = fopen('myDataset.rawb','r');
A = fread(fid);

% reshape the dataset
B = reshape(A,[181 217 181]);

% extract the slice at z=90
myImage = B(:,:,90);


% normalize image to 0-1 interval
maxValue = max(myImage(:));
minValue = min(myImage(:));
myRange = maxValue - minValue;
normImage = ((myImage - minValue)./(maxValue-minValue)).*1;
% display the normalized image
imagesc(normImage);colormap(gray);title('Normalized Image');
