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