Batch Converting jp2 to jpg

I do not know why but jp2 files are very very heavy on GNU/Linux systems. Opening a folder full of them might very likely stall your file browser or system. Even a small file below 1 M, might take its own sweet time to open in GIMP.Here is a small command to convert a bunch of em into jpg, thought resulting file is usually 1o times larger.
Use this for lossless conversion

mogrify -format jpg -quality 100 *.jp2

Source

Designing computer interface

Computers and related devices have to be designed with an understanding that
people with specific tasks in mind will want to use them in a way that is seamless with respect to their everyday work. To do this, those who design these systems need to know how to think in terms of the eventual users’ tasks and how to translate that knowledge into an executable system. But there is a problem with trying to teach the notion of designing computers for people. All designers are people and, most probably, they are users as well. Isn’t it therefore intuitive to design for the user? Why does it need to be taught when we all know what a good interface looks like?

Human Computer Interface

Known knowns, Unknown unknowns

Reports that say that something hasn’t happened are always interesting to me, because as we know, there are known knowns; there are things we know we know. We also know there are known unknowns; that is to say we know there are some things we do not know. But there are also unknown unknowns – the ones we don’t know we don’t know

Rumsfeld

After Nehru…

Longish quotes from London Review of Books from After Nehru by Perry Anderson

To be impressive, however, is not to be miraculous, as Indians and others still regularly describe the political system that crystallised after independence. There was never anything supernatural about it: terrestrial explanations suffice. The stability of Indian democracy came in the first instance from the conditions of the country’s independence. There was no overthrow of the Raj, but a transfer of power by it to Congress as its successor. The colonial bureaucracy and army were left intact, minus the colonisers.
For twenty years, across five polls between 1951 and 1971, Congress never once won a majority of votes. In this period, at the peak of its popularity as an organisation, its average share of the electorate was 45 per cent. This yielded it crushing majorities in the Lok Sabha, amounting to just under 70 per cent of the seats in Parliament. In effect, the distortions of the electoral system meant that at national level it faced no political opposition. At state or district level, this did not hold. But there, the centre had powers that could deal swiftly with any local trouble. These too were heirlooms of the Raj, eagerly appropriated by Congress.
No other system of inequality, dividing not simply, as in most cases, noble from commoner, rich from poor, trader from farmer, learned from unlettered, but the clean from the unclean, the seeable from the unseeable, the wretched from the abject, the abject from the subhuman, has ever been so extreme, and so hard-wired with religious force into human expectation.
Fixing in hierarchical position and dividing from one another every disadvantaged group, legitimating every misery in this life as a penalty for moral transgression in a previous incarnation, as it became the habitual framework of the nation it struck away any possibility of broad collective action to redress earthly injustice that might otherwise have threatened the stability of the parliamentary order over which Congress serenely presided for two decades after independence.
By the end of his life, Nehru would have liked a more presentable fig-leaf for Indian rule, but that he had any intention of allowing free expression of the popular will in Kashmir can be excluded: he could never afford to do so. He had shown no compunction in incarcerating on trumped-up charges the ostensible embodiment of the ultimate legitimacy of Indian conquest of the region, and no hesitation in presiding over subcontracted tyrannies of whose nature he was well aware.
Surrounded by mediocrities, Nehru accumulated more posts than he could handle – permanent foreign minister as well as prime minister, not to speak of defence minister, head of the planning commission, president of Congress, at various times. He was not a good administrator, finding it difficult to delegate, but even had he been, this was a pluralism too far.
Nor was Ambedkar consoled by sanctimonious plaudits for his role in drafting the constitution. He knew he had been used by Congress, and said two years later: ‘People always keep on saying to me: oh sir, you are the maker of the constitution. My answer is I was a hack. What I was asked to do I did much against my will.’
Secularism in India, it is explained, does not mean anything so unsophisticated as the separation of state and religion. Rather – so one version goes – the Indian state is secular because, while it may well finance or sponsor this or that religious institution or activity, in doing so it maintains an ‘equidistance’ from the variegated faiths before it.
As with other oppressed minorities in societies keen to advertise their pluralism, a sprinkling of celebrities – a batsman or film star here, a scientist or symbolic office-holder there – adorns, but doesn’t materially alter, the position of the overwhelming majority of Muslims in India.
What the Armed Forces (Special Powers) Act effectively does in such zones, the young Indian historian Ananya Vajpeyi has written, is ‘to create an entirely separate space within India, a sort of second and shadow nation, that functions as a military state rather than an electoral democracy, and only remains hidden because it is not, at least so far, officially ruled by a general or a dictator’. This space should ‘not be thought of as a zone of exception, but as a contradiction so extreme that it undoes the totality in which it is embedded’, which breaks down into ‘two distinct and mutually opposed regimes’ that form ‘two nations: India and non-India’.
Had the party or state been truly secular, in each case this would have been a priority, but that was the last thing it had in mind. There cannot be a genuinely secular party or state unless it is willing to confront religious superstition and bigotry, rather than truckle to them. Neither party nor state has ever contemplated doing that, because both have rested, sociologically speaking, on Hindu caste society. The continued dominance of upper castes in public institutions – administration, police, courts, universities, media – belongs to the same matrix.
After Independence, Gandhi’s doctrines were consigned to the museum, but his saturation of politics with Hindu pathos lived on.
Indian secularism of the post-independence period had never sharply separated state and religion, let alone developed any systematic critique of Hinduism.
The BJP does not oppose, but upholds secularism, for ‘India is secular because it is Hindu.’
‘Myths have a way of running away with their proponents,’ G. Balachandran, an Indian critic of this outlook, of whom there have not been that many, has remarked: ‘Belief in the essentially secular character of the modern Indian state and society can often be little more than an exercise in self-congratulation which overlooks or rationalises the sectarian religious outlook pervading large areas of contemporary social and political practice.’
Mayawati’s erection of 150,000 statues of Ambedkar, not to speak of two hundred effigies of her party’s elephant symbol and of herself (the largest 24 feet high, and like the rest covered in pink polythene as the state went to the polls in March, on the orders of the Election Commission, so as not to beguile or distract voters), at the cost of more schools and healthcare, offers an extreme case of this identity politics, which does not seek to abolish caste, as Ambedkar had wanted, but to affirm it.
Castes continue to be, as they have always been, and Ambedkar saw, one of the purest negations of any notion of liberty and equality, let alone fraternity, imaginable. That the Indian state has never lifted a juridical finger to do away with them, but in seeking only to ameliorate has if anything legally entrenched them, says more about its secularism than the omission of any reference to it in the constitution, or the belated passage of an amendment rectifying the omission to embellish the Emergency.
With it has come a large measure of convergence between Congress and the BJP in government, each pursuing at home a neoliberal economic agenda, as far as their allies will allow them, and abroad a strategic rapprochement with the United States. Culturally, they now bathe in a common atmosphere in which religious insignia, symbols, idols and anthems are taken for granted in commercial and official spaces alike.
In India democracy never extended very far from government to the parties contending for it, which were always run from the top down. Today, however, many have become something other than the oligarchic organisations into which the political scientists Ostrogorsky and Michels thought all parties must sooner or later turn. With the exception of the communists and the BJP, they have become family firms competing for market shares of the electorate and so access to public office.
Of the ensuing scenery, André Béteille, the doyen of sociologists of India, has written that the ‘abject surrender’ of Congress to a single family, corrupting all other parties, has done irreparable harm to Indian democracy, poisoning the wells of public life.
The court, now self-recruiting, is the most powerful judiciary on earth. It has acquired such an abnormal degree of authority because of the decay of the representative institutions around it. Even admirers are aware of the risks. In the graphic phrase of Upendra Baxi, India’s leading legal scholar and one of the first to bring a public interest suit before the court, it is ‘chemotherapy for a carcinogenic body politic’
Comparing India and China from another angle, one of the most lucid political minds of the subcontinent, Pratap Bhanu Mehta, has observed that in the People’s Republic, where there is no democracy, communist rule is based on output legitimacy: it is accepted by the masses for the material benefits it takes great care to deliver them, however unequally. Whereas in India, democracy allows just the opposite – an input legitimacy from the holding of free elections, that thereby excuses the political class from distributing more than confetti to the masses who have elected them.
Three years later, with typical dishonesty, the Manmohan regime renamed it as ‘Gandhian’ to fool the masses into believing that Congress was responsible for it.
Caste, not class, and alas, least of all the working class, is what counts most in popular life, at once sustaining Indian democracy and draining it of reconstructive energy.
If the poor remain divided against themselves, and workers are scattered and ill-organised, what of other sources of opposition within the political system? The new middle class has turned against mega-corruption, but is scarcely foreign to the bribe and the wink, let alone favours to kin, at its own level of advantage. Besotted with a culture of celebrity and consumption, on spectacularly vapid display in much of the media, and to all appearances hardening in collective egoism, it is no leaven in the social order. The intelligentsia is another matter. There, India possesses a range and quality of minds that perhaps no other developing society in the world, and not that many developed ones, can match. Whether working inside or outside the union, it forms an interconnected community of impressive acuity and distinction. In what kind of relationship does it stand to the country? Intellectuals are often held, quite wrongly, to be critical by definition. But in some societies, the mistake has become internalised as a self-conception or expectation, and so it probably is for most Indian intellectuals. How far do they live up to it?
A rigid social hierarchy was the basis of original democratic stability, and its mutation into a compartmentalised identity politics has simultaneously deepened parliamentary democracy and debauched it. Throughout, caste is the cage that has held Indian democracy together, and it has yet to escape.
In the 1920s the great Tamil iconoclast E.V. Ramasamy could declare: ‘He who invented God is a fool. He who propagates God is a scoundrel. He who worships God is a barbarian.’
Hindu culture, exceptionally rich in epics and metaphysics, was exceptionally poor in history, a branch of knowledge radically devalued by the doctrines of karma, for which any given temporal existence on earth was no more than a fleeting episode in the moral cycle of the soul.
‘In an overwhelmingly religious society,’ one subcontinental scholar has written, ‘even the most clear-sighted leaders have found it impossible to distinguish romanticism from history and the latter from mythology.’
Moral indignation is too precious an export to be wasted at home. That the democracy of his country and the humanity of his leader preside over an indurated tyranny, replete with torture and murder, within what they claim as their national borders, need not ruffle a loyal Indian citizen.
Nobel prizes are rarely badges of political courage – some of infamy – so there is little reason for surprise at a silence that, in one form or another, is so common among Indian intellectuals.
What is true is that no break away from the union is conceivable in this area, not because of any economic impossibility, but because Delhi can unleash overwhelming military force, as it has done for a half a century, to crush any attempt at secession, and can count on exhaustion eventually wearing out all resistance, as it cannot in Kashmir, where the alternatives of independence or inclusion in Pakistan have not left the Valley, and any free vote would prefer either to the Indian yoke.
Still, at the altar of Trimurti, costs are discounted inversely to gains. Unity, whose moral and political deadweight is heavier, is safer from reproach than democracy or secularity.
The dynasty that still rules the country, its name as fake as the knock-off of a prestige brand, is the negation of any self-respecting republic.
Congress had its place in the national liberation struggle. Gandhi, who had made it the mass force it became, called at independence for its dissolution. He was right. Since then the party has been a steadily increasing calamity for the country. Its exit from the scene would be the best single gift Indian democracy could give itself.
The political ills that all well-meaning patriots now deplore are not sudden or recent maladies of a once healthy system. They descend from its original composition, through the ruling family and its affiliates, and the venerations and half-truths surrounding these and the organisation enclosing them.

via After Nehru | LRB

Lists with LaTeX

While writing documents one needs lists. Usually the lists are either numbered or with bullet. The standard enumerate option in LaTeX by default provides Arabic-Hindu numbers for the list.
The standard syntax is as under:

\begin{enumerate}
\item First item
\item Second item
.
.
\end{enumerate}

This will produce a list with Arabic-Hindu numbers with the items at each head.
In case one wanted a list with bullets, we can use the itemize environment.

\begin{itemize}
\item First item
\item Second item
.
.
\end{itemize}

This will produce a list with with bullets
There is yet another environment description which can take user supplied options for list headings.
For example:

\begin{description}
\item[First] First item
\item[Second] Second item
.
.
\end{description}

In this case the descriptors in square brackets after the \item will be used as the item titles. So when I required any alphabetical list, I used to make list in the description environment and put the alphabets/ descriptors manually.
So far so good.
Recently I had to make a list with Roman numerals instead of Arabic ones. The list was fairly long so manual option seemed to be a very un-LaTeX kind of thing to do. Just a little googling and I found a treasury of options that can be used with the standard enumerate environment. This was the enumitem package.
The package provides various options for the enumerate environment like label and its formatting, style, alignment,  indent, vertical and horizontal spacing etc.
The label options that are available are \alph, \Alph, \arabic, \roman and \Roman,
These can be intialised by using
\begin{enumerate}[label=\emph{\alph*})]
After this the regular \item will produce list with alphabets, numbers or roman numerals.
Please see the documentation for more details.
Suppose you have a list which is split in many parts. You can use resume function to continue with numbering left off in the last part of the list. The resume function can be named and you can have different lists to resume.

Main purpose of the educational sector

The main purpose of the health sector is not to provide other sectors with workers in good health. By the same token, the main purpose of the educational sector is not to prepare students to take up an occupation in some other sector of the economy. In all human societies, health and education have an intrinsic value: the ability to enjoy years of good health, like the ability to acquire knowledge and culture, is one of the fundamental purposes of civilization.

via Thomas Piketty’s Capital in the 21st Century

Time Lapse Film Using Scanner

In this post we will see how to make  a time-lapse animation of something which changes over time, with a scanner. Most probably you have seen some amazing time -lapse photography of different objects. Common examples include the ever changing skyscape, blooming flowers, metamorphosing insects etc. I wanted to do a similar stuff, but due to my lethargy and other reasons I did not. Though the cameras have intervelometer, and I have used it once to take photos of a lunar eclipse, (moon changing position which I was supposed to merge later, but never did), and wanted to do the same with a blooming of a flower. But as Ghalib has said, they were one of those हज़ारों ख्वाहिशें…
The roots of the idea what follows are germinated long back, when I had a scanner. It was a basic HP 3200 scanner. That time I did not have a digital camera, (c. 2002-2003), but then I used the scanner as a camera. I had this project lined up for making collages of different cereals. Though I got a few good images from botanical samples (a dried fern below) as well and also fractals from a sheet of rusting iron. Then, I sort of forget about it.
white-fern-00
Coming to now, I saw some amazing works of art done by scanning flowers. I remembered what had been done a few years back and combined this with the amazing time-lapse sequences that I had seen , the germ began can we combine the two?
http://vimeo.com/22439234
Can we make the scanner, make scans at regular intervals, and make a animation from the resulting images. Scanning images with a scanner would solve problem of uniform lighting, for which you may require an artificial light setup. So began the task to make this possible. One obvious and most easy way to do this is to scan the images manually, lets say every 15 minutes. In this case you setup the scanner, and just press the scan button. Though this is possible, but its not how the computers should be used. In this case we are working for the computer, let us think of making the computer do work for us. In comes shell scripting to our rescue. The support for scanners in GNU/Linux is due to the SANE (Scanner Access Now Easy) Project. the GUI for the SANE is the xsane, which we have talked about in a previous post on scanning books and scanimage is the terminal option for the sane project.
The rough idea for the project is this :
1. Use scanimage to acquire images
2. Use some script to make this done at regular time intervals.
3. Once the images are with use, combine them to make a time-lapse movie
For the script part, crontab is what is mostly used for scheduling tasks, which you want to be repeated at regular intervals. So the project then became of combining crontab and scanimage. Scanimage has a mode called --batch in which you can specify the number of images that you want to scan and also provides you with renaming options. Some people have already made bash scripts for ADF (Automatic Document Feeders), you can see the example here. But there seems to be no option for delay between the scans, which is precisely what we wanted. To approach it in another way is to introduce the the scanimage command in a shell script, which would be in a loop for the required number of images and you use the sleep command for the desired time intervals, this approach does not need the crontab for its operation. But with I decided to proceed with the crontab approach.
The first thing that was needed was to get a hang of the scanimage options. So if your scanner is already supported by SANE, then you are good to go.
$scanimage -L
This will list out the devices available for scanning. In my case the scanner is Canon Lide 110, which took some efforts to get detected. For knowing how to install this scanner, if it is not automatically supported on your GNU/Linux system, please see here.
In my case it lists out something like this:
device `genesys:libusb:002:007' is a Canon LiDE 110 flatbed scanner
If there are more than one devices attached to the system the -L option will show you that. Now coming to the scan, in the scanimage programme, we have many options which control various parameters of the scanned picture. For example we can set the size, dpi, colour mode, output type, contrast etc. For a complete set of options you can go here or just type man scanimage at the terminal. We will be using very limited options for this project, namely the x, y size, mode, format, and the resolution in dpi.
Lets see what the following command does:
$scanimage -d genesys:libusb:002:006 -x 216 -y 300 --resolution 600dpi --mode Color --format=tiff>output.tiff
-d option specifies the device to be used, if there is nothing specified, scanimage takes the first device in the list which you get with -L option.
-x 216 and -y 300 options specify the size of the final image. If for example you give 500 for both x and y, scanimage will tell us that maximum x and y are these and will use those values. Adjusting these two values you will be able to ‘select’ the area to be scanned. In the above example the entire scan area is used.
--resolution option is straight forward , it sets the resolution of the image, here we have set it to 600dpi.
--mode option specifies the colour space of the output, it can be Color, Gray or Lineart
--format option chooses the output of the format, here we have chosen tiff, by default it is .pnm .
The > character tells scanimage that the scan should be output to a file called “output.tiff”, by default this will in the directory from where the command is run. For example if your command is run from the /home/user/ directory, the output.tiff will be placed there.
With these commands we are almost done with the scanimage part of the project. With this much code, we can manually scan the images every 15 minutes. But in this case it will rewrite the existing image. So what we need to do is to make sure that the filename for each scan is different. In the --batch mode scanimage takes care of this by itself, but since we are not using the batch mode we need to do something about it.
What we basically need is a counter, which should be appended to the final line of the above code.
For example let us have a variable n, we start with n=1, and each time a scan happens this variable should increment by 1. And in the output, we use this variable in the file name.
For example, filename = out$n.tiff:
n =1 | filename = out1.tiff
n = n + 1
n = 2 | filename = out2.tiff
n = n + 1
n = 3 and so on…
We can have this variable within the script only, but since we are planning to use crontab, each time the script gets called, the variable will be initialized, and it will not do the function we intend it to do. For this we need to store variable outside the script, from where it will be called and will be written into. Some googling and landed on this site, which was very helpful to attain what I wanted to. Author says that he hasn’t found any use for the script, but I have 🙂 As explained in the site above this script is basically a counter, which creates a file nvalue. starting from n=0, values are written in this file, and each time the script is executed, this file with n=n+1 is updated.
So what I did is appended the above scanimage code to the ncounter script and the result looks something like this:
#!/bin/bash
nfilename="./nvalue"
n=0
touch $nfilename
. $nfilename
n=$(expr $n + 1)
echo "n=$n" > $nfilename
scanimage -x 80 -y 60 --resolution 600dpi --mode Color --format=tiff>out"$n".tiff

What this will attain is that every time this script is run, it will create a separate output file, depending on the value of n. We put these lines of code  in a file and call it time-lapse.sh
Now to run this file we need to make it executable, for this use:
$chmod +x time-lapse.sh
and to run the script:
$./time-lapse.sh
If  everything is right, you will get a file named out1.tiff as output, running the script again you will have out2.tiff as the output. Thus we have attained what we had wanted. Now everytime the script runs we get a new file, which was desired. With this the scanimage part is done, and now we come to the part where we are scheduling the scans. For this we use the crontab, which is a powerful tool for scheduling jobs. Some good and basic tutorials for crontab can be found here and here.
To edit your crontab use:
$crontab -e
If you are using crontab for the first time, it will ask for editor of choice which has nano, vi and emacs. For me emacs is the editor of choice.
So to run scans every 15 minutes my crontab looks like this:
# m h  dom mon dow   command
*/15 * * * * /home/yourusername/time-lapse.sh

And I had tough time when nothing was happenning with crontab. Though the script was running correctly in the terminal. So finally the tip of adding in the cronfile
SHELL=/bin/bash
solved the problem. But it took me some effort to land up on exact cause of the problem and in many places there were sermons on setting PATH and other things in the script but, I did not understand what they meant.
Okay, so far so good. Once you put this script in the crontab and keep the scanner connected, it will produce scans every 15 minutes. If you are scanning in colour at high resolution, make sure you have enough free disk space.
Once the scans have run for the time that you want them , lets say 3 days. You will have a bunch of files which are the time lapse images.  For this we use the ffmpeg and ImageMagick to help us out.

Book Hunting in Boston – Week 2

Book Hunting in Boston

Week 2

MIT Coop

I went to MIT COOP opposite the MIT Press store to check for any affordable items to carry back home. But there were none. 🙁 Most of them were over budget for me. But then I checked their basement for stuff. And there I saw one of the most extensive line up for science books that I have seen. They were not just a minor section in the store which usually is the case, but were the major part.
All the interesting ones lined up in shelves. But sadly no discount and hence no buy 🙁
IMG_9077IMG_9079IMG_9081

IMG_9083
Dover at MIT Coop

IMG_9082
Dover at MIT Coop

IMG_9080 IMG_9085
Also they have all the Dover Publications books in print at one place, sorted according authors. Wow! Too many for me to handle. 😀 But for display only for me did not buy anything. But sure was overwhelming to look at them, all at the same place.

Boston Public Library

This was unplanned for. We were just roaming around the downtown area. And came out near the Boston Public Library established in 1852. The outside decoration is in form of the various authors in all fields of study. A few glimpses of the library
IMG_9221
Inscriptions on the building

McKim chose to have monumental inscriptions, similar to those found on basilicas and monuments in ancient Rome, in the entablature on each of the main building’s three façades. On the south is inscribed:
MDCCCLII • FOUNDED THROUGH THE MUNIFICENCE AND PUBLIC SPIRIT OF CITIZENS“;
on the east:
THE PUBLIC LIBRARY OF THE CITY OF BOSTON • BUILT BY THE PEOPLE AND DEDICATED TO THE ADVANCEMENT OF LEARNING • A.D. MDCCCLXXXVIII“;
and on the north:
THE COMMONWEALTH REQUIRES THE EDUCATION OF THE PEOPLE AS THE SAFEGUARD OF ORDER AND LIBERTY“.
Another inscription, above the keystone of the central entrance, proclaims:
FREE TO ALL“.
IMG_9226
Below each second-story arched window on the three façades are inscribed lists of the names of great historical writers, artists, scientists, philosophers, and statesmen.
 
Across the street from the central entrance to the library is a twentieth-century monument to the Lebanese-born poet and philosopher Kahlil Gibran who as a young immigrant educated himself in the Boston Public Library. The monument’s inscription responds to the McKim building reading
IT WAS IN MY HEART TO HELP A LITTLE, BECAUSE I WAS HELPED MUCH“.
The text is excerpted from a letter enclosed with Gibran’s generous bequest to the library.

The quote from Gibran definitely resonates with the experience that I have had with Internet Archive and GP (now sadly dead).
I lament that I did not go inside the library for the lack of time 🙁

Barnes & Noble, Prudential Tower

This was again unplanned for. We went to visit to Prudential Tower, the store just comes out as soon as you enter. Since I had heard about it, I did go in. They had some wonderful collections of books, but I did not get anything from there.
IMG_9264
 

Rodney Book Store

Now this one was on the cards as per the original recommended list. I visited this one just before the day of departure. I could not get a photo of the entrance but only of the inside. The store is well stocked and well categorised.
IMG_9311 IMG_9314 IMG_9317 IMG_9323 IMG_9324 IMG_9325 IMG_9326 IMG_9327
I wish I had more time at this store
 
IMG_0504
I got the above books at the store. With this one on M. C. Escher by Escher collection of classics is almost complete.
 

The Worst Get to the Top

Yes, you read that correctly: democratic government invariably leads to the rule by “demagogues” who manipulate the most immoral segments of society.
The core of this immoral coalition consists of “the lowest common denominator” – the “‘mass[es]’ in the derogatory sense of the term.” The masses consist of the least “educated” and least “intelligent” driven by “primitive instincts.”
The unethical leaders add to this core the “docile and gullible.” They are easily manipulated by propaganda that creates “a ready-made system of values if it is only drummed into their ears sufficiently loudly and frequently.”
Their “passions and emotions are readily aroused” by demagogues “who will thus swell the ranks of the totalitarian party.”
The third component of the totalitarian troika is the “most important negative element.” These are the murderous bigots motivated by “hatred of an enemy … the envy of those better off.”

via Bill Black: How Hayek Helped the Worst Get to the Top.