Thursday, 8 September 2011

Ways of writing code in MATLAB.

After telling about three basic commands, i felt that before starting any  further i should first let all of you know about the convinient ways of writing and executing a code as i have also mentioned in my last blog the demerits of writing code directly in command window. Today i'll tell you
1..How to write a code in EDITOR window (Go to FILE option then select NEW and select BLANK m-FILE).and,
2..How to create any function so that you can write whole code under that function and the by just typing the name of the FUNCTION on command window the whole code under the function will be executed.

First open the EDITOR WINDOW by going on to FILE option then select NEW and select BLANK m-FILE,then
First of all i'll tell you about the simple writing and execution of  code in editor window.
After opening the editor write the exact same code which we did in last blog

i=imread('C:\Users\RISHI\Pictures\certificates\MIT.jpg'); 
{Reading image from hard disk location}

d=im2bw(i); 
{Converting image into BINARY format and store that BINARY image into variable d}

e=rgb2gray(i); 
{Converting image into GRAY format and store that GRAY image into variable e}

figure
{This FIGURE command is used to open the image in different window , you have to write it before the imshow command}
imshow(i);


figure

imshow(d);

figure

imshow(e);

After writing the above code in editor window click on to the RUN logo which looks like this


The above code will results into the outputs three images open in three different windows.Every window contain an image first window is of orignal image and other two images will be of GRAY and BINARY format respectively.

The other technique is by making a function and name the function according to your choice and the write the above code under that function.

function avrobotics

i=imread('C:\Users\RISHI\Pictures\certificates\MIT.jpg');

d=im2bw(i);

e=rgb2gray(i);

figure

imshow(i);

figure

imshow(d);

figure

imshow(e);
end
After writing the code SAVE the above code as usual. And after saving it, write the NAME of the function in command window then the above code will be executed and give the same result but only the approach is different.



Result of the above code on command window.




There's another approach for making the function that is rather than selecting the Blank m-file select function m-file which is second option  and the function command will already be there you just have to change the name of function according to your choice. I have named the function as "avr" in image below as you can see it by enlarging the image.


I hope everyone will get benefit from above blog and do try the above technique as it will ease the coding process . And if you have any query kindly post and also share any idea or codes related to robotics and image processing.

Monday, 5 September 2011

MATLAB first look and some basic image processing commands for beginners

Gud evening everyone, today i'll be posting something related to MATLAB image processing coding.
After the installation of MATLAB the first look of the software is shown in image below.


As you can see in above image whole window of the software is divided in four parts.
1.Command Window
2.Workspace
3.Command History
4.Current Folder.
Command Window  is the place where you can directly write the code and get results immediately but there is also a disadvantage of this window that you can't make correction in the code if there's any error in the code you have written you have to write that code again in next line.
But, there's a solution to this problem you can work in editor of MATLAB.
Select the FILE option and then select NEW and then select M-File then an editor will open where you can write desired code.
Workspace is a place where whatever variable you declare its value will be stored there.
Command History  is space dedicated for what ever commands you are writing in command window will be saved in command history for your reusability of commands.



The very basic command of image processing is
imread
This command is used to read the image from the hard disk of your computer and display it on the matlab window using imshow comand.

Explanation of imread command , how to use tthis command in MATLAB command window to read image
step1.
Make a variable example "i" is a variable no need of declaring the type of variable in MATLAB,
i=imread('location of image on your hard disk\name of image as on your hard disk.extension of image')
LOCATION: Right click on image select properties and copy the location and paste in colons as mentioned above in command.
NAME: Whatever is the name given to the image by you on your computer.
EXTENSION: Extension of images are .jpg,.bmp,.tiff etc..

Example of the use of command.
i=imread('C:\Users\RISHI\Pictures\certificates\MIT.jpg');
The semicolon above mentions the end of the command.



The other command is conversion of the image into BINARY scale and GRAY scale.
The command are as above:
1.im2bw(variable in which the image is stored "i" as above example)- To convert image into BINARY scale.



2.rgb2gray(variable in which the image is stored "i" as above example)- To convert image into GRAY scale


The command to display the read image is imshow(name of variable in which image is stored "i" as above).
I hope everyone get benefits from this blog, tommorow i'll be posting about the robotics LED controll using microcontroller and also about webcam controll using MATLAB.

Sunday, 4 September 2011

MATLAB(Image processing)

Hi everyone,
As i have also added MATLAB(IP) to the name of my blog so i am starting with MATLAB(image processing) today.
MATLAB is a multipurpose technical computing language  and contains many toolboxes dedicated to one particular technology, i'll be focusing on image processing and image aquisition toolbox. In MATLAB toolbox the image is considered ad a matrix and each pixel of image as a each element of the matrix, the desired operations are done on each pixel to get desired results.
Example- To convert image into binary image (Contains only two colors BLACK and WHITE).
You can download the MATLAB from torrent install it as the installation guide pdf  file comes with the setup.
Tomorrow i'll be starting with very basic image reading ,writing and conversion code and webcam control using  MATLAB.
If you face any problem during downloading and installation of MATLAB kindly mail me the  queries. 

Saturday, 3 September 2011

Online Artificial intelligence course from STANDFORD UNIVERSITY(Include robotics and image and video processing)

Hi everyone, there's a golden opportunity for those who are interested in ROBOTICS, IMAGE AND VIDEO PROCESSING  and ARTIFICIAL INTELLIGENCE.
The ONLINE course duration is from 10th october  to 16th december 2011.  Course have two modules
Basic and Advance.
After the completion of the online course the students will get certificate from STANDFORD UNIVERSITY but students have to complete every assignments given by the faculty.
To enroll for the course and read the course details kindly visit
http://www.ai-class.com/
To read the course details visit
http://robots.stanford.edu/cs221/online.html
THE LAST DATE FOR ENROLLMENT IS 9TH OCTOBER.
 I hope you enroll and get benefits.

ROBOTICS event in NIT JALANDHAR techniti 16-18th september 2011

The techfest have many different events related to robotics like

Intelligent line follower

Vision controlled color and shape detection robot

Robowar

and many other different exciting events, visit this link for more information and participate to explore your robotics knowledge.
http://techniti.org/index.php/techniti/robotics/robotics#&panel1-2

Friday, 2 September 2011

How to start with BASCOMM software.

If you are done with downloading and installation of BASCOMM software,in this post we'll move further.
First appearence of BASCOMM software once after installation.



 Now, go to File then new option and a new file will open where you can write your programs.




After you are  done with this.In BASCOMM programming there are certain code lines which are always required in the beginning of the program.

These lines are as follows:

$regfile = "m16def.dat"
$crystal = 4000000
Config Lcd = 16 * 2
Config Lcdpin = Pin , Db4 = Portb.4 , Db5 = Portb.5 , Db6 = Portb.6 , Db7 = Portb.7 , E = Portb.3 , Rs = Portb.2
Config Adc = Single , Prescaler = Auto , Reference = Avcc
Config Timer1 = Pwm , Pwm = 8 , Prescale = 1 , Compare A Pwm = Clear Down , Compare B Pwm = Clear Down

These lines have very important functionalities like
1. Loading the register files for microcontroller( Atmega16 or Atmega32 )
2. Deciding the clock speed of microcotroller.
2. Configuring some hardwares like:
    LCD,ADC(Analog to Digital Convertor).Timer and microcontroller ports( A,B,C,D) 




For getting better description of each pin of  microcontroller you can go to VIEW option and select PIN LAYOUT and there'll be a popout on extreme right as you can see in above image . Now you can scroll your cursor on each pin of the microcontroller and see description of each pin.
If any query kindly post on the blog.

Thursday, 1 September 2011

Software which are required for programming

Hi, everyone, this post is about the softwares one require to create a program for atmega16 controller.
1. AVR Studio
2. BASCOMM
Two of the above software are used generally for programming and among of the above two software BASCOMM is easier and basic one, for someone who's new in robotics.
And AVR studio is totaly based on C language, use of C increase the scope of creating programs.
I'll be posting programs made in both avr studio and BASCOMM.
For start you can visit this link
http://download.cnet.com/Bascom-AVR/3000-2212_4-10498130.html
 download the setup of  BASCOMM  then install it for initial programming. In next post i'll be discussing the installation of BASCOMM and creating new project for writing the program.
For further query post me or mail me.
And for query related to any other robotics project mail me or post here.