MATLAB Language Image processing Basic image I/O

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

>> 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');


Got any MATLAB Language Question?