Here is a very detailed and interactive tutorial for designing digital filters in MATLAB. I have to say,this is the best form of interactive tutorial I found on the internet till date. Highly optimized for low bandwidth internet connections so the viewers can enjoy it uninterrupted. If you have no idea about MATLAB, you might wanna consider viewing the preliminary tutorial about the basics of MATLAB here.
Showing posts with label MAtlaB. Show all posts
Showing posts with label MAtlaB. Show all posts
Sunday, November 13, 2011
Saturday, October 29, 2011
Saturday, July 23, 2011
Wednesday, February 23, 2011
Getting started with MATLAB in 5 Minutes
For all those who are not that good at matlab or don't know anything about what it offers, here is a 5 min tutorial of the basics of matlab. It gives enough information for you to get started with coding in matlab and one may learn many other concepts by exploring various toolboxes.
Here is the amazing tutorial
Wednesday, February 16, 2011
My childish try at Mimicry (.aka modelleing the Human voice box)
I am a huge fan of S.P. Balasubramaniam, been listening to his songs ever since i started hearing. I mean who isn't. Always wished to sing like him, but never could as I was not gifted with it . But now things have changed so much over the years since my last thought that I can create any thing that I can virtually think of ( at least can attempt to do so) .Hence, the will to sing like S.P.B struck a chord in my mind and out came an idea, an idea to mathematically model S.P.B's voice. I am very excited as this idea would allow me to sing through his voice. Not just me,but anyone who wanted to have a gifted voice can get a feeling of having one by singing words from one's mind through S.P.B voice.
Now, how am I going to make this happen ? That's where the excitement ends with the technical stuff silently creeping in. Here's the giant that's gonna make it all happen, the mighty "Digital Signal Processing".On a serious note which is not going to end so soon, the idea to replicate the structure of a human voice box (of one particular person) is a tedious task. The approach for now would be to examine the voice signal samples of a person from various perspectives ( domains ). The next step would involve finding a commonality between all the samples that makes his or her voice so unique.
MATLAB is the preferred platform to perform all of these studies as it provides the most flexibility ( slow though be the processing). The ultimate goal is to provide a mathematical model (a digital system ) capable of rendering in real time words from our mind through S.P.B's voice( our voice is fed through a mic to the PC).
FIRST STEP :
Working with audio input within the matlab environment is something that I am unaware of. Hence that would be the best area to start this project
Just as matlab allows importing image data into it's environment, it can also render real time analog data from various sources.But it requires the suitable hardware via which the analog signals from the outside can be brought in to the computer itself.Hence, if the computer has has the hardware , matlab takes care of the rest via the Data Acquisition Toolbox. Since I have already mentioned that the project demands real time signal processing , real time data ,which is voice in our case , is going to be imported continuously into the matlab workspace via the PC's audio input device (microphone).
>>ai=analoginput('winsound'); //this command creates an analog input object referred to via variable 'ai'
//winsound is the default driver to access the PC's sound input hardware (mic)
//the analog input is being imported into a digital environment in the form of samples at some sampling rate
// it depends on the driver hardware the sampling rate of the signal. All details are a part of object constructor //which in our case is 'ai'
>>ai;
Display Summary of Analog Input (AI) Object Using 'Integrated Microphone Array (ID'.
Acquisition Parameters: 8000 samples per second on each channel.
20000 samples per trigger on each channel.
Inf sec. Of data to be logged upon START.
Log data to 'Memory' on trigger.
Trigger Parameters: Inf 'Immediate' trigger(s) on START.
Engine status: Waiting for START.
513515 samples acquired since starting.
453515 samples available for GETDATA.
AI object contains channel(s):
Index: channelname: hwchannel: inputrange: sensorrange: unitsrange: Units:
1 'Mono' 1 [-1 1] [-1 1] [-1 1] 'Volts'
>> daqhelp('daq/audioinput'); //gives a list of all attributes of the analog input object that you can set.
//you can explore a lot from there and know more about it
////out put too huge hence not shown. Most of the attributes are self commenting,not much explanation needed
//set(object_name,'PropertyName',PropertyValue) //example say:
>> set(ai,'TriggerRepeat',Inf); //sets number of times the object may be triggered to infinity
One thing one must be clear with when working on some real time code is the process how the data is being acquired in real time. The following statements mostly concentrate on those areas.
//whenever a real time data is being manipulated, there is a lot of stress on the processor as data is //continuously being fed to it . Hence one must be careful not make a messy code with loops (matlab doesn't //understand loops as good as it understands arrays) . Try to use arrays wherever and whenever possible.
//whenever a real time data acquisition object is created and its properties aptly set to your need, it needs to be started.
//for example,consider you digital camera.. I suppose one needs to start it by clicking the ON button before //he can start clicking some snaps
>>start(obj1); //hence this command which starts the object for data/image acquisition.
//once the object's started ,it doesn't immediately start acquiring data/images.There is something similar to a CLICK button on a camera to begin acquiring data.
For an object, say an image acquisition object ( a webcam connected to PC ), if the trigger configuration is set to automatic, the object starts acquiring data /images the moment it starts. Instead if it is set to manual, object upon starting via the 'start' command does nothing until it is triggered. Each time a trigger occurs on the object, it logs data into the memory .The image below best illustrates the process.
>>trigger(ai); //triggers data acquisition from the analog input object 'ai'
// the above figure illustrates a case of image acquisition, but audio data acquisition may also be understood //on similar lines
//once an object's been triggered, the data is logged to the memory and can be accessed via the getdata //command
>>dat=getdata(ai,20000); //the second parameter defines the no of samples of the data to be imported //from memory to the workspace for further manipulation.
//In this case the 20000 samples of data are extracted and saved into 20000 x 1 array 'dat'
// the data can now be accessed by the array itself.
>>>>>>>>>>>>>>>>>>>>>>that's it for now<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
COMINGUP: Better understanding the analog input object and it's various attributes.
LIVEXample: changing you voice in real time to sound like.
DO COMMENT IF THERE ARE ANY SHORT COMINGS IN THE EXPLANATION
I think.Hence I drive people nuts
Tuesday, February 15, 2011
Image Processing on matlab
Many people might face some trouble getting started with machine vision on Matlab . They might be well aware of the finer nuances of microcontrollers,their programming..interfacing them with other devices....and what not. But Matlab is an entirely different field to conquer. The following code preforms some basic image processing and tracks a red object placed in front of the camera. It worked for me. Go through the code. I hope it doesn't work for you. At least that would get some of you to post queries and learn rather than performing a naive Copy >>Paste operation . I hope to reply to the posts as quickly as possible.
OBJECT TRACKING IN MATLAB
imaqhwinfo % to view all the cameras connected to the pc
a=imaqhwinfo('winvideo',2); % to get a detailed note on the winvideo adapter with index '2'
a.SupportedFormats %gives the list of all supported formats of winvideo
obj1=videoinput('winvideo',2,'RGB24_320x240'); % set the format based on the output you get from previous statement
triggerconfig(obj1,'manual'); %to set the triggering mode to manual
set(obj1,'FramesPerTrigger',1); % to set the frames per trigger propert of obj1 to '1'
set(obj1,'TriggerRepeat',Inf); % to set number of such triggers to infinity
preview(obj1); %command to preview the output from the video input object obj1;
start(obj1); %starting the image acquisition
sr=strel('disk',8); %defining a structuring element
pause(5);
%%
while 1 % infinite loop
trigger(obj1); %triggering the obj1 vid input object
%(this is like clicking camera button to snap a photo)
dat=getdata(obj1); % capturing frames from the video stream after triggering and saving them in 'dat' variable
i=dat(:,:,:,1); %getting the first frame the resulatant stream of clips
%%% THE ACTUAL IMAGE PROCESSING
bw=(i(:,:,1)>200)&(i(:,:,2)<150)&(i(:,:,3)<150); %extracting the regions where the red is more than 200 but not blue and green
imshow(bw); % it is a black and white image
% cleaning up the image and removing unwanted noise
bw=imclose(bw,sr); % performing a morphological close operation
bw=imfill(bw,'holes'); %removing small white spots here and there
bw=bwareaopen(bw,900); % filtering out all white blobs less than 900 pixels in area
L=bwlabel(bw); %labelling the blobs
S=regionprops(L,'Centroid','Area'); % extracting the information from the labelled items
cent=S(find(([S.Area] == max([S.Area])))).Centroid;% finding the centroid of the blob with the maximum
area
text(cent(1),cent(2), 'centroid'); % placing a text at the point(the centroid) on the image where the red
object is present
% code to send the data based on the centroid co-ordinates
% values to be sent via a serial port to micro
end % end of the while loop
% use ctrl + break to stop the infinite loop
CAPTURED IMAGE |
FILTERED IMAGE MASK |
Centroid of the image overlaid on live cam feed |
Subscribe to:
Posts (Atom)