Two other problems with your code.
First is that there are no comments.
Second is that you reversed x and y. In the for loop you have it correct -- img_res(i, j) which is img_res(y, x). However when you preallocated it you used
img_res = zeros(y_res,x_res,3, 'uint8');