Read, Display & Write an Image using Matlab

Today we are going to discuss some basics  of image processing. We are going to discuss following topics:
  1. How to read an image
  2. How to display an image
  3. How to write an image

How to read an image

We can read any image by using  command imread  as:
imread(‘abc.jpg’);
Here abc is the name of image and jpg is its extension/type.
That command can be used in that way only  if our image is located in same directory. If we want to read image from some other folder then we have to mention complete path of image like:
our_image=imread(‘Z:\Blog\image_processngabc.jpg’);
Now our image will be saved in our_image.

How to display an image

We can write an image in Matlab by using imshow command as:
imshow (our_image)
 
Now lets suppose we have used that imshow command to display another picture f_image, Matlab will displace the first image our_image with second image f_image.
 
Therefore to encounter that problem and to display both images at same time we use function figure as
figure(1)iiiii.iiiiiiiii
imshow(our_image)
figure(2)kkkkkkkkk
imshow(f_image)…..
In that way we can read and show as many images as we want simultaneously.

How to write an image

 We can write image by using command imwrite  as follows:
imwrite (f_image, ‘blog.png’)
or
imwrite (f_image, ‘blog’,’png’)
 
Here f_image is the name of image which we want to save, blog is the new file name in which we want to save that image and png is the type/extension of image. We can save it in any format like jpg, png, tif  etc.
After entering that code we see that a new image with name blog is formed in our current folder/ directory. Now if we want to write image in some other folder (other than current directory), we can do that by including complete path as follows:
imwrite (f_image, ‘E:\blog.png’)
In next sessions we will learn more about image processing.
Thanks a lot for your time 🙂
For projects/paper implementations and one to one online training……