Monday, October 19, 2009

Twitter is Overloaded

I just signed in to twitter and I got this result :P.



Woah!! millions of tweets to millions of people

Fun with Image Processing in Python

While dabbling with Image Library in Python I came across some interesting module: ImageFilter. In here I got familiarized with edge detection, smoothing.. etc. Using various combinations I wrote a simple code that will give the following output- Looks like pencil shading


Original Image

Processed Image







A pretty simple and easy code-



import Image
import ImageFilter

im = Image.open("car.jpg")
im.load()

# Find the edges and enhance it
im=im.filter(ImageFilter.FIND_EDGES)
im=im.filter(ImageFilter.EDGE_ENHANCE_MORE)

putpixel=im.im.putpixel
pix=[0]*4

# Get the dimensions
size=im.getbbox()

# Threshold in 0-255
threshold=180
for i in range(size[2]):
for j in range(size[3]):
p=im.getpixel((i,j))
# The FIND_EDGE highlights the edges
# Check if the pixel is white and enhance it accordingly
if ( (p[0]+p[1]+p[2])/3)<(threshold):
pix[0],pix[1],pix[2]=255,255,255
else:
pix[0],pix[1],pix[2]=0,0,0

putpixel((i,j),tuple(pix))

im=im.filter(ImageFilter.SMOOTH)
im.save("new_car.jpg")

Wednesday, September 30, 2009

2-D Array in Python

For those who are having difficulty in initializing 2-D arrays in Python here is the help


cols=5
rows=5

arr = [[0]*cols for _ in [0]*rows] # arr becomes a 2-D array

arr[0][2]=10

print arr[0][2]
10

Monday, September 28, 2009

Fixing ATI drivers on Ubuntu on my HP Pavilon dv5

I am using a HP Pavilion dv5 on which I run Ubuntu 9.04. My laptop has an ATI Radeon 3450 graphics card. Recently I faced a problem with my graphic card. What happened was that- for some ambiguous reason my display drivers stopped working, as a result after booting it used to get hanged with a 'blank screen'.

I come up with a solution to fix the problem which worked perfectly.

- Restart the Ubuntu 9.04 in generic recovery mode. Once the loading is done a list will come choose - start in command prompt as root user.


- Now we have to remove the old and corrupted ATI drivers, I used the following code to uninstall the drivers.
1) Navigate to /usr/share/ati
2) Enter the command "sh ./fglrx-uninstall.sh"
3) Once un-installation is successful restart (init 6)


- On rebooting again launch Ubuntu in generic recovery mode -> command prompt.
Now we need to reinstall ATI drivers. The drivers can be downloaded from AMD site, save it on a USB drive. If already on the P.C good enough.

- Navigate to the ATI driver folder and run the following command
"sh ./ati-driver-installer-9-9-x86.x86_64.run".
The ATI setup will start follow the instructions, once done reboot your P.C and enjoy Ubuntu!!

Sunday, September 13, 2009

Dismantling my old desktop

Swine flu had stuck my college, due to which our college was shut down and we got a 12 day vacation woohoo. During that time I was mostly at home, didn't go out anywhere for the fear of catching the flu. I was getting bored sitting at home no interesting stuff to do, it was then I found my old desktop P.C lying in some corner of my house. This old desktop was catching dust for ages, since there was no use of it I got an crazy idea of dismantling it completely.
I fetched out screwdrivers and began to remove it part by part. I opened my CPU case cover and saw a complex network of digital chips and wires. I had a look at the motherboard with a huge fan right on top of the processor, big fat hard disk, CD rom, floppy drive (no one uses floopy these days), power source. I had brought this comp back in 2002, its configuration were as follows-

Processor: Pentium 4 2.3Ghz
Ram: 512 M.B
HDD: 40 G.B
Video card: On board intel 32 m.b

It was a pretty decent configuration at that time. Ripping apart my desktop brought back all my memories with that p.c playing loads of games, movies, surfing on the web and loads of other crazy stuff that i did. After removing all the main components that make the c.p.u I arranged it and took a nice picture of it.



The top left is my hard disk, below that is the LAN card, in the center is the RAM, bottom center lie the brain of the pc- 'The microprocessor' even though its the smallest part its the most important part of the computer.
While I was dismantling it I had a close look at the intricate network of wiring, it looked so complex to me. It was like number of silicon chips connected by criss-cross wires, all working together in a perfect harmony to make it work as a computer. Thoughts raced across my mind, even though computer is so common these days but its basic construction is ultra complicated. We just use the computer as any other tool for entertainment purpose without realizing the complexity that lies behind. Imagine the number of computer scientist and engineers have worked their whole lives on researches on computer. Without them we would have never got the luxury of computer.

Wednesday, August 26, 2009

The golden side of Recession

‘Oh god my business went bankrupt’ says a businessman, ‘I won’t get placed in any company’, says a B.Tech pass out, ‘Shit!! I lost my job’, says an IT man. Their is big hue and cry related to recession. You go anywhere, talk to anyone, everywhere there are cries of recession. One day I was sitting in CafĂ© Coffee Day there was a group of business men sharing their depressing stories as how recession has burdened their lives with debt. It’s like an epidemic spreading all over the world affecting every single person, its like worse than any flu it not only affects humans but companies, economies.. blah. Sometimes I feel that earth’s dooms day is right across the corner (that’s too much exaggeration).
I agree that recession has affected our lives but, have you ever tried to look at the brighter side of this epidemic? Have you wondered this recession might benefit our lives in the long run? The tense atmosphere all over the world has forbidden our logical thinking. The way I look at this recession is a time to rectify our mistakes and let the old give way to new ones. This statement might sound absurd, for the time being, by the end of the article you will get the hidden meaning of this statement. So lets begin:-

“Downturn marks the beginning of a new era” -Prabhat Godse. (I just made that up :P).

There are many practical examples of the above statement- the end of World Wars marked the beginning of new age, the atomic bombing of Hiroshima and Nagasaki destroyed Japan but look at Japan today- the leader of technology. If the Europeans and the Japanese had just mourned over their losses, then they could never have risen from their ashes.
Nothing is constant in the world everything that comes to us has an expiry date. Every thing has to depart the world one day or the other, big or small empires of the world meet their end one day, boom times of the economy cannot last for ever this means even the recession cannot last forever. As of now, i.e 2009, it is recession time but it will not last for ever. The boom time is not dead its just lying dormant waiting to be resurrected.

Prior to the advent of this recession the economy had show signs of a set back. The main reason for recession was the faulty policies of government and reckless lending by banks. Like the news of Lehman Brothers getting bankrupt was a jaw dropping news. "How could a huge multinational banking company collapse?" was questioned by everyone. Yes! even big companies have got faults in them. Lehman Brothers had a policy of high risk mortgage loans, which means that this bank use to lend money to those people who were not in a strong position to return the money. They also had a loan scheme of 'No job, No income and No asset' loan often referred to as Ninja loan, borrowers with no job, income or asset were offered loans. When they failed to pay back the banks money was lost. This type of lending system continued for a long time as a result the bank started losing money and their debt kept piling up which lead to bankruptcy.

Its not just banks even the government had loose interest rates and economic policies. Many countries had kept their interests rates low to ease the borrowing. A decrease in interest rates and increase in the rate of borrowing rate pumps money into the economy. Borrowers can get money at a very cheap rate, household are the major borrowers. Initially it will appear that the economy is growing since everyone has disposable money which will lead to an abrupt increase in spending the consumer market will grow. This is actually an artificial growth because the economic growth powered by spending, what boosts the economy is investment, infrastructure and creating jobs. Since the returns from the investment take time and the happiness obtained by spending is instant it can ruin the economy.

Hence the main fault was the capital generated by loans was diverted to spending and not towards investment. After this shock I am sure everyone must have realized their mistakes. Now many banks have tightened their lending policies and loans should not be given to high risk borrowers. Even though the old (banks that got bankrupt) have passed away they provided us with a valuable lesson. Keeping this in mind the new economic policies will be molded for the better future. The new companies that will emerge will be better of than the previous ones.

One more interesting fact more than half of the fortune 500 companies of 2009 originated in the recession of 1930s. So anyone with start-up plans please do not back off go ahead. As of now all we can do is to just survive the recession and wait for the good times.

Sunday, August 16, 2009

AGRICULTURE AS A MAJOR BUSINESS OPPORTUNITY IN INDIA

It is depressing to know that even after 60 years from independence India is still called as third world country. There are multiple reasons which are hindering India’s progress: corrupt politicians, education, population, terrorism. In this article I am going to focus on how to accelerate the dawdling economic progress in rural India. India has recorded a G.D.P growth of around 8% which is extremely impressive. If we analyze it further we realize that major chunk of the growth is contributed by I.T, manufacturing and industries sector. The irony is- agriculture grows at a mere rate of 1.7% and despite 60% of India’s workforce being employed in agriculture.
Certainly agriculture hasn’t proven as a boon for India. Often you will hear the news in India farmers committing suicide due to extreme debts, poor and hapless farmers turning into Naxalites. With the food prices skyrocketing Indian agriculture is spiraling downwards. So why these setbacks are being faced by farming sector, what’s wrong with it and how to improve it? Now I am going to show you how to make agriculture as a money making sector.

First lets start with the drawbacks:-

Machinery

Have a look at the two pictures shows below, there is a clear contrast between the two. One on the left is a traditional way of farming in India and on the right is a highly mechanized farming technique. Just think about it two people working in a mechanized farm can harvest the large farm (maybe the size of several hectares) within just few hours. On the other hand a traditional technique will consume several work hours on just a few acres of farm. This is certainly not fair.






Farm Size



After having a look at the above bar graph the Indian average land holding is so low that it cannot be seen in the graph, its actually 0.1 hectares. In fact the average farm size in India has been declining since 1960, in 1960 it was 0.21 hectares in 2009 its fallen to 0.1 hectares. So if a farmer has to mint money he must have a large farm in order to generate a bumper crop.

Irrigation

Now as for the irrigation part which is a very important part for the growth of green plants. Water is a useful resource and must be used wisely to minimize losses, with the help of advanced irrigation techniques such as drip irrigation the usage of water can be maximized. Drip irrigation delivers water right to the roots drop by drop, just enough to meet the demands. Where as in our country due to lack of resources and knowledge water is literally thrown in the fields, this method increases water losses, right amount of water is not delivered to the plants.



MAKING MONEY

Now getting to the main point- making money. So far I have discussed certain issues like lack of technology, machinery, farm size and irrigation: obviously its impossible for an average Indian farmer to posses such enormous amount of capital to fund all this hi-tech equipments. Then someone with loads of capital has to step down and change rural India, the answer is obvious turn agriculture as a business oportunity. Just imagine this situation:-

- A big firm or company buys large tracks of land, lets say around 1000 hectares of land, in rural places and pays a handsome price to the original land owners (to prevent any land disputes).

- They invest a huge sum of money on this land and buying large agriculture machinery, high tech irrigation facilities, genetic seeds for better yield and educate the traditional farmers into skilled farmers. These skilled farmers will be employed in the farms. We can imagine the amount of output and profit such large farms would generate. Wealth can also be earned by exporting the bumper crop. The newly turned skilled farmers will receive big fat checks thus ending the miseries of poor rural India.

- For a start it would be advisable if big giants like Reliance Industries, Tata, Birla, e.t.c start up, since they have earned a respectable brand image.

- Due to the large amount of output produced by such farms, the high food prices in India would precipitate.

- Not just rural India other sectors would benefit too, like manufacturing and bio-tech firms. How? Well there will be a demand for advanced machinery and genetic modified seeds which would fuel the economy.

- Ever since civilizations sprung up in India, crop yield has been heavily dependent of the monsoon.No rain no food, that has been the trend for centuries. Wow is the time to break free from this dependency on rains. Due to surplus funds techniques like water storage and rain water harvesting can be adopted, once these are put in practice the farms wont be dependent on rains.


I guess that's all on my mind right now, I have explained the problems of agriculture in India and the solution to turn it as a big business opportunity. I hope some entrepreneur or a company puts my idea into use to bring about a change. I thank you for reading my article feel free to leave your opinion and comments.