function v = predikcija(s)

[height width N] = size(s);

Min = s;
MoutX = s;
MoutY = s;
MoutZ = s;

%predikcija
for z = 1:N
    z
    for y = 1:height
        for x = 1:width
            
            if(x == 1)
                MoutX(x, y, z) = Min(x, y, z);
            else
                MoutX(x, y, z) = Min(x, y, z) - Min(x-1, y, z);
            end
            
            if(y == 1)
                MoutY(x, y, z) = MoutX(x, y, z);
            else
                MoutY(x, y, z) = MoutX(x, y, z) - MoutX(x, y-1, z);
            end
            
            if(z == 1)
                MoutZ(x, y, z) = MoutY(x, y, z);
            else
                MoutZ(x, y, z) = MoutY(x, y, z) - MoutY(x, y, z-1);
            end
        end
    end
end

%hafmanovanje
%prvo pretvaramo 3D matricu u vektor
v = uint16(MoutZ(:));
%s1=MoutZ(:,:,1);
