Arya's Blog

Thursday, July 24, 2008

Working with gcc in windows

OK

For the past 2 days I have been struggling with finding a fast solution to processing some images that I had. I will present some things that I learnt here. Perhaps there are hundreds of other places where these things are better described by more competent people, but I am doing this anyway.

libtiff learnings

To read tiff images you need libtiff. Most tiff images are stored in strips – so say you have a 640x480 image. Then there are 2 ways to read this image

1. Use scanline – a scanline is one line of the image – 640 pixels in our case. Then you scan 480 times. (480 is imageheight, a parameter you can query using libtiff)

2. Use rawstripscan – scan strips at a time. In my case there were 19 rows in 1 strip. Thus its equivalent of doing 19 scanline calls. But you have to arrange the data in the correct image format. Thus you fill 19 rows of your 640x480 array in 1 scan. When you use scanline, you fill 1 row at a time.

gcc for windows learnings

To get gcc you have 2 options – either get gcc.exe files from somewhere or install MinGW and MSYS. I recommend the second option.

Remember to change/check the PATH setting of Windows.

Next to compile use a make file

Here is one that I made

a.exe : tiffread.o
gcc tiffread.o -ltiff.dll -LC: \Tiffread\tifflib\lib -o a.exe

tiffread.o : tiffread.c
gcc -c tiffread.c -IC: \Tiffread\tifflib\include


Note that the -l clause asks gcc to look for the library libtiff.dll.a (note the "lib" in the front and the ".a" in the back will be added by the compiler, so you need to subtract them). -L gives the directory to look for the library. The -I gives the directory for the include files.

To compile use the

C:\>make

command

gcc for matlab learnings

This is basically setting up gnumex. However if you want to add say the tiff library, the easiest way is to copy libtiff.dll.a to the lib\ directory of your gcc installation and adding the -llibtiff to the list of commands in the mexopt.bat file

set GM_ADD_LIBS=-llibmx -llibmex -llibmat –llibtiff

dlls for gcc

If you want to use say OpenCV then a .lib file ships with it. To compile your program in gcc you need to give -lcv.lib and -lcxcore.lib in gcc. Also needed is a -LC:\Progra~1\OpenCV\lib. However, if you want to use a .dll, file, then it may not work sometimes (don’t ask me why not). The work around apparently is to recompile using gcc as given here.

Sunday, July 20, 2008

Still on my mind

I can't forget this Garbage Patch thing.

This is from the San Fransisco Chronicle.

  • Contains PVC which is degrading - turning into dust because of the UV rays.
  • All sorts of other things - from plastics to tires
Why can't plastic be recycled?
Apparently there are some problems.
  1. The used plastic from bottles cannot be used to make new plastic bottles. This, I think, is because the recycled plastic will have to be mixed with plasticizers which will then make them unsuitable for storing food. Can used plastic be lined with poly-ethylene like metal cans are lined? This will surely separate the reused plastic (with the plasticizers) from the virgin plastic and the food will be safe.
  2. The chasing arrow symbol with the number in it does not necessarily mean that the plastic can be recycled. - This I did not know.
  3. I wonder what kind of plastics can be recycled? Seems like PP, LDPE, HDPE, PET, PVC, PS can all be recycled. Only the ones with "7" in the chasing arrow cannot be recycled.
  4. Also it seems that less than 1/4 of the plastic is recycled in most cases.
Need some strategy.

Saturday, July 19, 2008

What can we do.

The greatest garbage dump the Great Pacific Garbage Patch is twice the size of the US.

Apparently the plastic bags we have been dumping in the sea were not beeing used by the mer-people to do their grocery shopping.

They have been collecting in the middle of the ocean for the last 30 years.

What a nightmare!!!














Here is some more information.

Thursday, July 17, 2008

Love this song

ये नयन दरे दरे, ये जाम भरे भरे
ज़रा पीने दो
कल की किस्को खबर, इक रात होके निदर
मुझे जीने दो
ये नयन दरे दरे

रात हसीन ये चान्द हसीन
पर सबसे हसीन मेरे दिल्बर
और तुझसे हसीन, और तुझसे हसीन तेरा प्यार
तु जाने ना
ये नयन दरे दरे

प्यार मे है जीवन की खुशी
देती है खुशी की गम भी
मैं मान भी लू, मैं मान भी लू कभी हार
तु माने ना
ये नयन दरे दरे

and here is the original Bengali version

Ant & Grasshopper

Someone sent me this story:

Ant & Grasshopper

U.S. VERSION:

The Ant works hard in the withering heat all summer building its house and laying up supplies for the winter.

The Grasshopper thinks the Ant is a fool and laughs & dances & plays the summer away.


Come winter, the Ant is warm and well fed. The Grasshopper has no food or shelter so he dies out in the cold.


INDIAN VERSION:


The Ant works hard in the withering heat all summer building its house and laying up supplies for the winter.

The Grasshopper thinks the Ant's a fool and laughs & dances & plays the summer away.

Come winter, the shivering Grasshopper calls a press conference and demands to know why the Ant should be allowed to be warm and well fed while others are cold and starving.

NDTV, BBC, CNN show up to provide pictures of the shivering Grasshopper next to a video of the Ant in his comfortable home with a table filled with food. The World is stunned by the sharp contrast. How can this be that this poor Grasshopper is allowed to suffer so?

Arundhati Roy stages a demonstration in front of the Ant's house.

Medha Patkar goes on a fast along with other Grasshoppers demanding that Grasshoppers be relocated to warmer climates during winter.

Amnesty International and Koffi Annan criticizes the Indian Government for not upholding the fundamental rights of the Grasshopper.

The Internet is flooded with online petitions seeking support to the Grasshopper (many promising Heaven and Everlasting Peace for prompt support as against the wrath of God for non-compliance) .

Opposition MPs stage a walkout. Left parties call for "Bharat Bandh" in West Bengal and Kerala demanding a Judicial Enquiry.

CPM in Kerala immediately passes a law preventing Ants from working hard in the heat so as to bring about equality of poverty among Ants and Grasshoppers.

BJP wants Sonia Gandhi's apology.

Lalu Prasad allocates one free coach to Grasshoppers on all Indian Railway Trains, aptly named as the 'Grasshopper Rath'.

Finally, the Judicial Committee drafts the 'Prevention of Terrorism Against Grasshoppers Act' [POTAGA], with effect from the beginning of the winter.

Arjun Singh makes 'Special Reservation' for Grasshoppers in Educational Institutions & in Government Services.

The Ant is fined for failing to comply with POTAGA and having nothing left to pay his retroactive taxes, it's home is confiscated by the Government and handed over to the Grasshopper in a ceremony covered by NDTV.

Arundhati Roy calls it 'A Triumph of Justice'.

Lalu calls it 'Socialistic Justice'.

CPM calls it the 'Revolutionary Resurgence of the Downtrodden'.

Koffi Annan invites the Grasshopper to address the UN General Assembly.

.
.
.
.
.
.
.

Many years later...

The Ant has since migrated to the US and set up a multi-billion dollar company in Silicon Valley ..

100s of Grasshoppers still die of starvation despite reservation somewhere in India ...

As a result of losing lot of hard working Ants and feeding the Grasshoppers, India is still a developing country!!!

Cheers to India




Now the question is is this a correct approach to have? I am an Indian studying in the US. I got a good education while I was in India, and after that I was able to get into a good US college.

Most of the other people of my immediate family - cousins etc. who have also been able to obtain an US education were able to do so primarily because their parents were rich. I can trace back affluence in our family as far back as my grandfather, who I believe was the first one to become relatively well off after India's independence. He was able to do so because he had some education. My maternal grandfather was highly educated (a doctor) and his son, my maternal uncle, went to a good college and immigrated to the United States in the 60's (I think).

What I am trying to say is that unlike this version of the story where it is liberals against the conservatives, the above version denounces the entire Indian political system. I am sure that the political system is broken in India, but I do not think that all the masses that are really suffering because of their incompetence or laziness. I donot think that the huge masses who live in poverty, in want are doing so because of their laziness as the story seems to be trying to point out. Its true that they are being exploited by the system and that its the politicians who are to blame, but the grasshopper in India is working hard. Harder than any grasshopper in the US does anyway.

These so called hundreds of masses that are "still dying of starvation" are being forced to do so not because they were frolicking all summer, but because a summer's worth of hard sweat cannot buy you enough for winter if you are a lowly grasshopper.

Monday, July 07, 2008

Now professors?

IITs are going to have 50% reservation for professors. Does this even make sense? How can you say that a person who is a PhD is from a backward class?

Who is forward then - if someone with the highest possible qualification is backward? How can you say that this teacher is going to teach not because he knows the subject and is hence highly qualified to teach it, but because he was born a SC or ST?

The question is why. Why not ability. Why does this person need reservation. To achieve what? What is that achievement worth then? If he is not able to get a teaching position by virtue of his education was that education worth it?

I feel helpless in the face of this stupidity. I feel helpless - just as helpless as any patriotic person feels when he sees his country being raped by aggressors. Even the patriots have a last choice - to take up arms. When your own do this to you, there is nothing to be done. I alone cannot change the government, but I know that the government is doing something wrong. And worse still is that the law is on their side. The Supreme Court has allowed this to happen. How can we stop this destruction, how can the John Galt come to save us? When will the best minds go on strike.

They say that IIT is a brand. It sure is - its a brand recognized the world over, from US schools to Wall Street to Silicon Valley. This will destroy that brand. I know the counter arguement - what good is a student who goes to USA - we want students who will stay in India. The answer is not to have students who will not be able to get into US Colleges or Companies, but to build jobs in India which will be able to employ them.

I am sad and depressed bu this. Politically motivated it maybe, but the results are disastrous. I really hope that there is a way to stop it.