Search This Blog

Tuesday 17 January 2012

MATLAB Codes for Image Processing

As I had promised, I am going to upload the files to various codes related to image processing in MATLAB. Starting from the simpler, I will move on to more complex codes. I have commented wherever the need be, in order to make the code understandable to a laymen. Suggestions are always welcome. I will keep on posting the links of file-hosting sites where I have uploaded my code. A single click will enable you to download the code. The codes have been written in MS Word. All you need to do is to copy-paste the code in the MATLAB editor, unless otherwise specified.

Bit-Plane Slicing Technique
Neighborhood of a pixel
Statistical order filtering
Convolution/correlation of two images
Edge-detection using HAAR filter
Color to gray conversion

Monday 16 January 2012

MATLAB (Finally)

I've already told in the 'About me' section that I'm highly fond of Matlab. The developers at Mathworks Inc. have done a fabulous job developing this wonderful software. Various add-ons and toolboxes make it a very handy and useful tool. To study Matlab under Dr. Pawar sir, the master himself, makes it even more interesting. Image processing is one area of Matlab which is not explored as much as the others. I tell you, Matlab is a very powerful image processing tool!!

Availability of various inbuilt filters, the ease of conversion between unsigned integers and other formats, the ease of accessing the image and assigning the pixels to the variables in a matrix make it a very powerful image processing tool. Sir explained in the last lecture about the idea of accessing individual frames from a video and processing them to perform the function you want. What amazes me especially is that a simple command - imread - lets you access the pixels of the image in the form of a matrix and you can do whatever you want with the image. One important application of this technique is in encrypting and decoding secret information. Using the bit-plane slicing technique, one can embed the coded information into the lower most significant bit, covered up by the image to disguise the information as a picture. It will be almost impossible for a pedestrian to decode the information without prior knowledge. Secondly, one can even add Gaussian/Laplacian blur using simple low-pass filters to make this system even more complicated to decode. Using a suitable type of mask/neighborhood approximation technique, the information to be coded can be scrambled and sent for added security. I realize that as I start digging more and more into this wonderful software, I am able to develop more and more insight into it and imagine the possible applications of the product. Using suitable image processing softwares with MATLAB will prove to be a boon, very soon!!

Accounting for another application, I figured out that one can even combine Linux and MATLAB into an intelligent eye-detection and tracking mechanism. I googled for 'an eye detection and tracking using Matlab' and found some inefficient yet interesting stuff. We can as well use Linux to access the frames, but processing them using Matlab in Linux makes it difficult. So, I'd rather download freewares from the internet - which allow me to access individual frames from a video, which I can process as per my will. I am going to make a small project related to eye-detection and tracking once I get accustomed to the image processing toolbox of Matlab. 

As for the bit-plane slicing and averaging/masking operation, I am going to upload the code pretty soon. Keep in touch :)


Monday 9 January 2012

Glory Glory Manchester United!! Welcome back PAUL SCHOLES #18

As I said in my previous post, I was expecting the weekend to end on a positive note, and it couldn't have ended in a better way. Manchester United thrashed their 'noisy neighbors' - Manchester City (shitty!!) out of the 4th round of the FA Cup. Manchester City, the defending champions, fought out a battle which otherwise would have brought a humiliating defeat to their side. Trailing 3-0 at half time and reduced to 10 men, thanks to the red carded captain Vincent Kompany, fought out with a never say die attitude and scored twice in the second half. Just when they thought they had a glimpse of the hope, the United defense charged up to prevent them from scoring another, and eventually winning the match 3-2.

The first half was a nightmare for the petromoney mongers, with Wayne 'Wazza' Rooney scoring from a fabulous header in the 10th minute. To add to the pain, Vincent Kompany was sent off for a two-footed tackle on Nani and City were reduced to ten men. They looked in utter dismay when Danny Welbeck scored from a screamer, a world class finishing from the young striker, to make the score 2-0. Welbeck played his role again, when he was brought down in the City penalty area leading to a penalty. Rooney, who normally doesn't miss any, hit it straight to the goal keeper who couldn't hold it, and Rooney scored from a rebound to make the score 3-0. With the triplet of Rooney-Welbeck-Valencia looking deadly and City reduced to 10 men, a massacre looked on the cards. To my disappointment, however, City put in a blistering performance in the second half. A fabulous free kick (mark my words, you won't see many like those) from Alexander Kolarev made the score 3-1. He shoot in a fabulous inch-perfect banana, the ones we normally see only in FIFA, to score for his team. No goalie in the world would have been able to stop it, trust me! Than a slip from United defense saw Sergio 'Kun' Aguero scoring to make the score 3-2. United and its fans had their hearts in their mouths for a while, but a calm and composed United side regrouped, to keep the scoreline 3-2 and eventually winning the game.

United played as worse in the second half as they played good in the first half. It was disappointing to be honest. However, amongst the glorious and heart warming news was the return of the United midfield maestro, the living legend, Paul Scholes. Scholsey, who retired 7 months back, was ready to answer calls to united's midfield woes/crisis, mostly due to injuries to key players. Scholes, who is 37 already, has signed a contract which extends until the end of the season and he will wear the #22 jersey. I couldn't be more happier, to see him play again for united. It was his 668th appearance for the club, 4th highest for any player in history. Welcome back, Scholsey!! We missed you.

Amongst other new, it was good to see Chris Smalling back from injury. Tom Cleverly is expected to train from Monday. Hence, we are going to have a pretty strong squad soon, with players recovering from injuries. Hail Alex Ferguson, hail Scholsey, hail Manchester United. GGMU!!

Friday 6 January 2012

Emotions, Emulations, Evaluations - Life is nothing but a roller coaster

It's been a pretty busy and long week. But I'm going to end it with a wonderful weekend. Off to Ahmedabad to rock the city with my cousin. As I always say - 'Work hard, party harder' Well, as they say - All is well if the end is well - so the week gone is gonna end up on a positive note.

It all started on Monday - the most boring day of the week (indeed!!). Back to back three lectures for the first time in last semester - that was like 'man, gimme a break!' And than the laboratory session for the widely ridiculed (coz of the faculty who's teaching this subject) Advanced Microprocessors. First laboratory session and we were hooked up for about an hour, which we aren't normally used to!! Off went the Monday in a flash, fortunately.

Tuesday was no different than the boring Monday. Usual stuff - college, gossiping, chit-chat and back home. I found the laboratory session of Image Processing pretty informative to be honest (I know most of my classmates will be wanting to kill me after reading this, but I can't help it.. Programming is in my blood!!)

Wednesday, oh gosh, had a silly argument with mom in the morning and she suffered from severe headache in the noon. Emotions turned up, topsy-turvy situation, but it ended on a positive note; only after getting to know from the doc that it was due to cold and nothing else.

Thursday, well, a day of evaluating ourselves as to where we stand. It was the day of much awaited inter-college badminton tournament of GTU. Lost in the semifinals to SVIT, but we could have gone through to be honest. Only if we had enough practice and fitness to do so. Sorry guys, I couldn't take the revenge!!

Then came the most tedious day of the week so far, Friday. While most of my colleagues were enjoying day-in and out, 4 of us who work on a project were called up for the same at 8:30 am in the morning. With the chilling winter winds blowing, waking up at 7 seemed to be the most difficult task of the week. But that perception of mine was broken soon, when the project guide told that we'll be having presentations at 5, thereby implying that we were supposed to stay there and work our hearts out till 5. Oh my gosh, hell of a day!! Emulations using JTAG, circuit simulations, programming and what not!! 

Thursday 5 January 2012

Automated Energy Metering

Okay, so here is my first attempt at jotting down the details of one of my projects for you. This one is one of my personal favorites and I expect an extremely reliable energy meter once I finish reviewing the coding part of the meter.

Basically, I have used an ASIC chip from Texas Instruments, which measures apparent energy (power rather!) instead of energy delivered to the consumer. Due to inherent losses of a transmission line, a part of the electrical energy generated at the power station is reflected back, while the part that remains is delivered to the household. The traditional meters measure the energy delivered/consumed by the consumer, and not the energy generated. Hence, the actual cost of generation of energy is never recovered. It is estimated that India has lost trillions of rupees due to this faulty meters.

The chip from TI is MSP430FE427, which has an inbuilt embedded system processor (ESP), 16-bit hardware multiplier, three 16-bit sigma-delta ADCs, inbuilt LCD driver, UART/USART comm ports and an arrangement to interface the JTAG emulator.

While designing the circuit, following points have to be taken care of:

1. Measuring the voltage and current from the source as accurately as possible
2. Providing the +3.3 V to the digital circuitry for its proper functioning
3. See to it that the 230V from the source doesn't reach/affect/overload the digital circuitry in any form
4. Displaying the apparent power (kVAh) on the LCD
5. Measure the current and voltage in both - the phase and the neutral lines, to ensure no tampering has been done with circuit and prevent theft of electricity

(As a further extension to this project, I have also thought of interfacing it with a bluetooth/zigbee module in order to enhance the ease of using the meter)

So the entire project has been divided into 5 different modules for ease of implementation:

1. Power supply section - To provide 3.3 V to the circuit and ensure that the supply from the mains does not affect the circuit
2. Analog Section - To provide the voltage and current from the mains for measurement purpose to the current transformers
3. Controller Section - Interpret the measured values, multiply them, process them taking care of the calibration parameters and display the result on the LCD
4. PCB Design - All the 3 circuits above should be properly integrated into a single chip, which facilitates further entension to the project as I described earlier
5. Coding of the ESP and the ASIC chip - The heart of the entire project, this part contains codes pertaining to different tasks that need to be performed in the processor

I am using IAR Embedded Workbench for the coding part. The cracked version is easily available for download. I downloaded part of the code from a blog, but didn't find it much useful. I am using it as a reference and develop my own code altogether.

I have finished the design, PCB design as well as part of the coding. I will try and upload the snaps of the circuit and the PCB design asap. The code is going to take atleast another 3 months to finalize. I will keep updating about my progress. Stay tuned!!

(P.S.: I know most of you might not understand what I've written here, for its pretty incomprehensible. But this was the best I could write. And perhaps, this project is too big to write it on a blog, so all I have done is given a bird's eye view)

I'd appreciate further suggestions/queries from you all. Do not hesitate to write me on varunshah444 at gmail dot com

Wednesday 4 January 2012

The defeat will make us stronger. GGMU!

A disappointing start to the much awaited 2012. Saw my dream team Manchester United losing 3-0 to the Magpies, and arch rivals Manchester City climb to the top of the table with 3 points over Manchester United. Goals by Demba Ba (the bargain buy of the season), a gorgeous free-kick, and an unlucky own goal from the versatile Phil Jones saw Newcastle home with a humiliating 3-0 defeat for the Red Devils. One can not ignore the fact that the injury problems at Old Trafford are starting to cause problems, and if the manager does not reinforce any his midfield with new signings this transfer season, we can kiss good bye to the Premier League title. I, however, trust Sir Alex Ferguson and his philosophies. Win, Lose or draw, Red Devil for life!! GGMU.

P.S.: Eagerly awaiting the Sunday clash against Manchester City
I am not much of an extensive blogger, this being my first attempt to write a blog. I'd try and make this blog as interesting as possible. This being the first post, I'll try and describe myself.

I am a student of Electronics Engineering at BVM Engineering College. I love programming (yes, I am a geek!). I love to code in MATLAB (unfortunately!). I also like OpenCV, Image Processing, Cryptography - although I am a newbie in these fields. I am going to further my career in the field of Robotics and Intelligent Systems.

As for life apart studies, I follow football and tennis. I am a die hard fan of Manchester United as I am of Roger Federer. I hate so see them lose. I support them whatever the scenario be, and I believe 'Form is temporary, class is permanent.' Watching sports has taught me an important aspect of life - that winning and losing is part and partial of life. What matters is how you get up after being knocked down once. Never say die. Apart from this, I (used to!!) play badminton regularly.

I laugh a lot. I speak a lot. I write. I read. I party. I sing. I dance. I adore. I hate. My idea of bliss is a dark room with a television set, and watching Manchester United play. I love my enemies and hate my friends (Yes, you read it right!!) To some people, I am a Rockstar, to some I am a sweet kaminaa. Some think of me as simply incomprehensible, while some adore my simplicity. I love my mom above everything in the world. I firmly believe that you never really know how strong you are, until being strong is the only option you have. Last but not the least,

'If it were not for Physics and law enforcement, I would have been uncontrollable'

Hope you like tis post, and I'd appreciate any comments to improve it. See you soon, till than - All izz well!!!