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.
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:
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.
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.
The 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.
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.
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