function J = remove_horizontal_seam(I, S)
[rows, cols] = size(I);
cols = size(S, 2);
J = zeros(rows, cols, 3);

for col=1:cols
    index = S(col);
    J(1:index - 1, col, :) = I(1:index - 1, col, :);
    J(index:rows, col, :) = circshift(I(index:rows, col,:), [-1, 0, 0]);
    
end

J(rows, :, :) = [];

end