Digital Images Processing: 4 Class Dr. Majid Dhirar
Digital Images Processing: 4 Class Dr. Majid Dhirar
4 Class
th
Dr. Majid
Dhirar
For a practical example of using matrices, we will now look at and
manipulate multidimensional data in the form of images. Monitor
screens and images are inherently matrices with rows and columns,
where each element (pixel) can be addressed by a particular row and
column index.
MATLAB stores most images as two-dimensional arrays
(i.e., matrices), in which each element of the matrix
corresponds to a single pixel in the displayed image.
When we get to images, we are still working with matrices
that can be accessed through indices. The upper left-hand
corner of the image is indexed by (1,1). The general format
of indexing is (row, col) or (y,x).
Color Format (Type of data stored in the image array or matrix).
Examples
(‘autumn.tif’)
('football.jpg')
('coins.png')
Images Data Types
>> I=imread(‘onion.png’)
>> imshow(I)
>> imtool(I)
>> i = imread(‘football.jpg');
img=imread('onion.png');
imshow('onion.png')
%Convert to grayscale
img_gray=rgb2gray(img);
imshow(img_gray)
Saving Images
When saving a binary, grayscale or truecolor image, all you need to
specify are the matrix and filename. For example:
imwrite(img_bin, 'onion_bw.png')