Wednesday 7 August 2013

What Is the Image Processing Toolbox?

The Image Processing Toolbox is a collection of functions that extend the capability of the MATLAB® numeric computing environment. The toolbox supports a wide range of image processing operations, including:

  • Spatial image transformations
  • Morphological operations
  • Neighborhood and block operations
  • Linear filtering and filter design
  • Transforms
  • Image analysis and enhancement
  • Image registration
  • Deblurring
  • Region of interest operations

Many of the toolbox functions are MATLAB M-files, a series of MATLAB statements that implement specialized image processing algorithms. You can view the MATLAB code for these functions using the statement.
             
type function_name


You can extend the capabilities of the Image Processing Toolbox by writing your own M-files, or by using the toolbox in combination with other toolboxes, such as the Signal Processing Toolbox and the Wavelet Toolbox.

Read and Display an Image

Clear the MATLAB workspace of any variables and close open figure windows. 

       clear, close all


To read an image, use the imread command. Let's read in a TIFF image named pout.tif(which is one of the sample images that is supplied with the Image Processing Toolbox), and store it in an array named I.
            
            I=imread('pout.tif');


Now call imshow to display I.
              
            imshow(I)


Check the Image in Memory

Enter the whos command to see how I is stored in memory.
·         whos
MATLAB responds with
·         Name      Size         Bytes  Class
·          
·           I       291x240        69840  uint8 array
·          
·         Grand total is 69840 elements using 69840 bytes

Thursday 1 August 2013

Looping in C - Basic Level

In every programming language, thus also in the C programming language, there are circumstances were you want to do the same thing many times. For instance you want to print the same words ten times. You could type ten printf function, but it is easier to use a loop. The only thing you have to do is to setup a loop that execute the same printf function ten times. 

There are three basic types of loops which are: 

For Loop 
While Loop 
Do while Loop 


Let’s look at the “for loop” from the example: We first start by setting the variable i to 0. This is where we start to count. Then we say that the for loop must run if the counter i is smaller then ten. Last we say that every cycle i must be increased by one (i++). 

In the example we used i++ which is the same as using i = i + 1. This is called incrementing. The instruction i++ adds 1 to i. If you want to subtract 1 from i you can use i–. It is also possible to use ++i or –i. The difference is is that with ++i (prefix incrementing) the one is added before the “for loop” tests if i < 10. With i++ (postfix incrementing) the one is added after the test i < 10. In case of a for loop this make no difference, but in while loop test it makes a difference. But before we look at a postfix and prefix increment while loop example, we first look at the while loop. 

Example code :
While Loop 

“while” statement is a sentinel controlled repetition which can be iterated indefinite number of times. Number of iterations is controlled using a sentinel variable (test expression).


Let’s take a look at the example: First you must always initialize the counter before the while loop starts ( counter = 1). Then the while loop will run if the variable counter is smaller then the variable “howmuch”. If the input is ten, then 1 through 10 will be printed on the screen. A last thing you have to remember is to increment the counter inside the loop (counter++). If you forget this the loop becomes infinitive.

As said before (after the for loop example) it makes a difference if prefix incrementing (++i) or postfix incrementing (i++) is used with while loop. Take a look at the following postfix and prefix increment while loop example:


i++ will increment the value of i, but is using the pre-incremented value to test against < 5. That’s why we get 5 numbers. ++i will increment the value of i, but is using the incremented value to test against < 5. That’s why we get 4 numbers. 

Do while Loop 


“do..while” statement is a sentinel controlled repetition which is quite different from the other two statements we covered earlier. This statement runs the code first and then checks the test-expression, so there is always a guarantee that the code runs at least once. This type of loop is generally used for password checks and menus.

Do something first and then test if we have to continue. The result is that the loop always runs once. (Because the expression test comes afterward). Take a look at an example:

Next Topics will be soon ..