I=imread('flower.jpg'); % convert the JPG image file into a matrix. I=double(I); % convert the unsigned integer matrix to a double precision matrix J=255*ones(size(I))-I; % this operation inverts the image intensities J=uint8(J); % convert back to an unsigned integer matrix imwrite(J,'ivflower.jpg','jpg'); % convert the matrix into a JPG image file % plot out the original image and the inverted image. colormap(gray); subplot(2,1,1),imagesc(I); % Subplot: creates axes in tiled positions. title('Original Image') subplot(2,1,2),imagesc(J); % Imagesc: scales data and displays as image. title('Inverted Image')