function output = change_size(input, x_sz, y_sz)
% Up/downsamples input matrix to be size specified in x & y

[inp_y, inp_x] = size(input);
output = zeros(y_sz, x_sz);
flperror = 0.001;
thrsh = 0.1;

% conversion factors
conv_x = inp_x/x_sz;
conv_y = inp_y/y_sz;

for row=1:y_sz
    for col=1:x_sz
        x_min = floor((col-1)*conv_x)+1;
        x_max = floor(col*conv_x-flperror)+1;
        y_min = floor((row-1)*conv_y)+1;
        y_max = floor(row*conv_y-flperror)+1;
        output(row,col) = mean(mean(input(y_min:y_max,x_min:x_max))) > thrsh;
    end
end