function [layer_stack_out, segmentation_cost] = quad_tree_lossy_segmentation(layer_stack, lambdas)

number_of_layers = size(layer_stack, 3);

w = cd;
cd('../Andriy/Original QuadTree_EncDec_v9');

% min_lambda = 0.01;
% max_lambda = 20;
% lambdas    = linspace(min_lambda, max_lambda, num_points);

num_points = length(lambdas);

segmentation_cost = cell(num_points, 1);
layer_stack_out   = cell(num_points, 1);
for ith_point = 1 : num_points
    [segmentation_cost{ith_point}, layer_stack_out{ith_point}] = evaluate_segmentation_cost(layer_stack, number_of_layers, lambdas(ith_point));
    segmentation_cost{ith_point} = segmentation_cost{ith_point} + number_of_layers * 16;
end

cd(w);
