file_name = 'tsukuba_extracted4.mat';
% file_name = 'teddy.mat';

% Disparity vector
load(file_name, 'D');
% Labels array
load(file_name, 'label');

% Obtain the stack of labels
layers_stack = generate_layer_stack(label, D);

%%
% Size of the data
[r, c, num_images] = size(layers_stack);

last_layer = zeros(r, c);
for ith_layer = 1 : num_images-1
    last_layer = xor(last_layer, layers_stack(:,:,ith_layer));
end

last_layer = ~last_layer;

figure
imagesc(last_layer)
figure
imagesc(layers_stack(:,:,end))

