Basic Commands In MATLAB for Image

Images are read into the MATLAB environment using function imread,
>>  imread('filename. format');

>> f = imread('a.jpg');

>> f = imread('D:\myimages\a.jpg');



Typing size at the prompt gives the row and column dimensions of an
image:




>> size(f)

This syntax returns the number of rows (M) and columns (N) in the image.

>> [M, N] = size(f);

This syntax gives the size of f along its first dimension, which is defined by MATLAB as the 

vertical dimension.

>> M = size(f, 1);


Displaying Images

Images are displayed on the MATLAB desktop using function imshow, which has the basic syntax:

>> imshow(f)


>> imshow(f, [low high])

displays as black all values less than or equal to low, and as white all values greater than or 

equal to high.


Image Tool

Image Tool in the Image Processing Toolbox provides a more interactive environment for viewing and 

navigating within images, displaying detailed information about pixel values, measuring distances, 

and other useful operations.

>> f = imread('a.jpg');
>> imtool(f)

Writing Images

>> imwrite(f, 'filename')

>> imwrite(f, 'patient10_run1.bmp')

Function imwrite writes the image as a BMP file because it recognizes the .tif extension in the 

filename.

imfinfo filename

where filename is the file name of the image stored on disk. For example,
>> imfinfo a.jpg


outputs the following information (note that some fields contain no information in this case):

Filename: 'a.jpg'
FileModDate: '04-Jan-2003 12:31:26'
FileSize: 13849
Format: 'jpg'
FormatVersion: ''
Width: 714
Height: 682
BitDepth: 8
ColorType: 'grayscale'
FormatSignature: ''
Comment: {}
Contact:  
Mr. Roshan P. Helonde
Mobile: +91-7276355704
WhatsApp: +91-7276355704
Email: roshanphelonde@rediffmail.com
Share:

Contact Us

Name

Email *

Message *

Blog Archive

Blog Archive

Popular posts