Лучше для вас сделать вашу программу для всех размеров изображений не только для 256 * 256.
[row, col]=size(your_image);
mr = round(row/2); % median of rows
mc = round(col/2); % median of columns
% Now divide your image and call each of them separately and do what ever you want
top_left = your_image(1:mr , 1:mc);
top_right = your_image(1:mr , (mc+1):col);
bot_left = your_image((mr+1):row , 1:mc);
bot_right = your_image((mr+1):row , (mc+1):col);
% final stage is to combining these parts again to return to its original shape
Back_to_original = [top_left,top_right ; bot_left,bot_right];
% надеюсь, что это будет полезно для вас ,