MATLAB Language Image processing Basic image I/O


>> img = imread('football.jpg');

Use imread to read image files into a matrix in MATLAB.
Once you imread an image, it is stored as an ND-array in memory:

>> size(img)
ans =
 256   320     3

The image 'football.jpg' has 256 rows and 320 columns and it has 3 color channels: Red, Green and Blue.

You can now mirror it:

>> mirrored = img(:, end:-1:1, :);  %// like mirroring any ND-array in Matlab

And finally, write it back as an image using imwrite:

>> imwrite(mirrored, 'mirrored_football.jpg');