only 10 lines. % Want to swap pixel at (x1,y1) in image with the pixel at (x2,y2) I = imread('face.jpg'); x1 = 25; y1 = 25; x2 = 25; y2 = 370; % Get pixel data from image pixel1 = I(y1, x1, :); pixel2 = I(y2, x2, :); % Swap pixels I(y1, x1, :) = pixel2; I(y2, x2, :) = pixel1; imshow(I); |