This is fun project based on image processing with MATLAB, here we will come accross learing how to count the number of distinguishable objects in an image. Sounds fun ,dosen’t it …So lets get started!
The following tutorial is performed with the help of MATLAB. MATLAB stands for “MATrix LABoratory” and is a numerical computing environment and fourth-generation programming language, developed by MathWorks. Using MATLAB, we can solve technical computing problems faster than with traditional programming languages, such as C, C++, and Fortran.
The tutorial can be performed by executing the commands in each step sequentially in the command window of MATLAB.
Step 1: Read the Image
An image is choosen so that it has considerable contrast with its background so that the objects can be identified. The function imread reads the image from a given location and stores it in the matrix img1. The imshow function displays the image.
Step 2: Convert the Image to Grayscale
Step 3: Threshold the image
This step thresholds the image by converting the grayscale image into an image that contains only two colors. The function im2bw() assigns black color to all the pixels that have luminosity than a threshold level and the others as white. the function graythresh() approximately calculates the threshold of the image.
Step 4: Complement the image
Step 5: Find the Boundaries of the Objects
B = bwboundaries(img2);