function image = inverse_spatial_shape_adaptive_DWT(input, temporal_label, number_of_decompositions, maximum_block_size, output_dimensions)


%Input contain submatrixes of the original image. Reshape input and
%convert back into a double matrix
if ~isempty(input)
if iscell(temporal_label)
    temporal_label = reorganize_partitions(temporal_label, output_dimensions, number_of_decompositions, maximum_block_size);
end

input_size = size(temporal_label);
input = reorganize_partitions(input, input_size, number_of_decompositions, maximum_block_size);

%{
number_of_submatrices = floor(sqrt(length(input)));
input = reshape(input, [number_of_submatrices, number_of_submatrices]);
input = cell2mat(input);
%}
if number_of_decompositions > 0   
    image = inverse_SA_DWT_full_decomposition(input, temporal_label, number_of_decompositions);
    %image = inverse_spatial_shape_adaptive_transform_matlab(input, temporal_label, number_of_decompositions);
else
    image = input;
end

else
    image = [];
end

end