Fundamental image processing using MATLAB

This tutorial will show you the very basic method on how to read an image from your computer and put it in the MATLAB workspace that finally display them on MATLAB's figure. This tutorial is aimed for a very beginner people who want to know this. I hope this can help a little bit. Lets get started...

In image processing, the first thing you should have is of course the image(located in your computer drive) you would like to process. For beginner, place your image in "C:\Users\username\Documents\MATLAB\yourimage.jpg" for the sake of easiness. In this tutorial, the image below is an image in .jpg format. Yes, you can use others format but you need to make sure your MATLAB version do support them.
 
Noted that in this example, the picture is borrowed from ARTSJOURNAL . Only for the purpose of this tutorial. Below is the image.


alt

Once you have the image (remember any image you would like to process), in this tutorial the house image shown above. After that you need to be familiar with MATLAB windows layout. You have to know three important windows that are command, workspace, editor windows. Below image show how MATLAB windows looks like:

alt

On the top-left shows the workspace windows, bottom-left is the command windows and on the right hand side is the editor windows. Once you get all windows organized as above thus we can start smiling because we are going to import the image into the MATLAB workspace now !!. Do remember this layout is not necessary be as in the picture above, you can put them anywhere you want. Yes, it is moveable..great isn't it?

Now, concentrate on the command windows. For beginner there is no need to use editor windows yet as you have to be familiar in MATLAB working process. Editor windows is for intermediate user which we will cover in the next tutorials. What you will see in command windows is the ">> ". Click you mouse pointer into this command windows and start typing the command "house = imread('example.jpg');". The word house is a variable that you can use your own name (e.g. myinput, input,example, etc..). The "imread" however is a MATLAB command used to read the image. imread = image read. The wording in the bracket is the file name. You have to make sure your file name extention (e.g. *.jpg, *.tif, *.bmp, etc) is exactly as what you have in the MATLAB folder or otherwise there will be an error coming out. Below show how the command is typed.

alt

PRESS ENTER and you will get exactly as the picture below. Look at your workspace windows. We are now succesfully imported/read the image and also success to put it in MATLAB workspace.

altThe question now is how to display the loaded image in the MATLAB's figure windows??. It is now very simple but how? Ok, again put you mouse pointer in the command windows and type in "figure,imshow(house);". Remember that my variable is house, so you have to use yours. The variable name is actually visible in workspace. PRESS ENTER and you will get the below result.

alt

Finally, to close the figure you can use command "close all" in command windows. In order to clear workspace you can type in "clear all" and to clear the entire command you can use "clc" followed by ENTER. Below is the example of the cleared workspace after done this tutorial.

alt

Next post will explain more about how to process the image (loaded in workspace) as well as how to use editor windows to start programming using MATLAB (*.m files).

More topic to cover:

Image Processing Toolbox, Programming in MATLAB is simple, Graphical User Interface (GUI) in MATLAB, and many more...

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...
 
 
 

Total Pageviews

Advertisements

Cool Text: Logo and Graphics Generator
Home