a=imread('C:\Users\Public\Pictures\Sample Pictures\Desert.jpg'); b=rgb2gray(a); c(:,:,:)=255-b(:,:,:); imwrite(c,'neg.jpg'); subplot(1,3,1); imshow(a); title('Original Image'); subplot(1,3,2); imshow(b); title('Grayscale Image'); subplot(1,3,3); imshow(c); title('Negative Image');