function scaled_image_bartlett = bartscale(padded_image,x_scale,y_scale)

% Creacion del Filtro Bartlett
row_vector = zeros(1, x_scale*2-1);
col_vector = zeros(y_scale*2-1, 1);

x_length = length(row_vector);
for i=1:x_length
    if (i <= x_scale)
        row_vector(i) = i;
    else
        row_vector(i) = x_length-i+1;
    end
end

y_length = length(col_vector);
for i=1:y_length
    if (i <= y_scale)
        col_vector(i) = i;
    else
        col_vector(i) = y_length-i+1;
    end
end

bartlett = 1/(x_scale*y_scale) .* (col_vector * row_vector); 
            % Filtro Bartlett listo para convolucion

% Se realiza el filtrado de Bartlett
scaled_image_bartlett = conv2(padded_image,bartlett);

% Se retiran los bordes negros de la imagen.

for i=1:x_scale
    scaled_image_bartlett(size(scaled_image_bartlett,1),:) = [];
end

for i=1:y_scale
    scaled_image_bartlett(:,size(scaled_image_bartlett,2)) = [];
    
for i=1:x_scale-1
    scaled_image_bartlett(:,1) = [];
end

for i=1:y_scale-1
    scaled_image_bartlett(1,:) = [];    
end

end