25 September 2016

Adding existing header files in Eclipse project

I am facing a strange problem when I add existing header files to an existing Eclipse. I have added the files using Import->File System->Directories and then choosing the necessary files. This works for making the IDE aware of these files and for symbol resolution. Unfortunately, when the project is attempted to be built, there is a failure due to these included header files. I have taken a look at the forums but the only solution provided is to include these new directories in the c/c++ properties of eclipse. strangely, this problem does not happen in visual studio. I felt that Eclipse can also do this, i do not now why this is not done. This can be considered to be a "wishlist" by the respected Eclipse developers.

10 May 2015

Motion by curvature example in 2D

Here is a simple set of Octave/MATLAB files to help anyone understand or visualise motion by curvature for a 2D planar curve. I am yet to find out how to embed code in HTML; but in any case it is easier to pack and zip files in one place. The above plot shows a random curve green which has been evolved by its curvature for some iterations and the resultant curve is shown in red. 
One problem I faced was that if i increase the number of curve points to a very large number, say 150 or above, the evolution is not so stable any more and we get unexpected results. My guess is that this is a numerical stability issue rather than a bug in the code but do feel free to correct me by emailing or leaving a comment in this web-log entry or from where you downloaded the code or by emailing me.

09 May 2015

Our Lady of Alice Bhatti Quick review

I bought this book from Amazon.
Below is review:

I have read Mohammed Hanif's "A case of exploding mangos" for maybe 150 rupees. That was an amazing book; unbelievable. So I bought this book. This is also an amazing narrative of Christian suppression in Pakistan. Salute to the author. Also the protagonist is a woman; add that to her troubles as well. This is a much darker book than the Case of exploding mangoes. This is worth a read definitely. And the courage of Shri Mohammed Hanif is not to be trivialised.

Amuktamalayada translation by Srinivas Reddy

I bought the book from Amazon and posted the review below:
Amazed to read the history of this book. The original version is written by a Kannada king in Telugu language and is about a Tamil saint and describes Madurai with great zest. Amazing, that despite cut-throat warfare in the South the people still managed to praise something or the other from other regions. As a translation, obviously it looks kludgy but the author has made best effort and called this his labour of love. Praiseworthy. My prime reason for liking this book is it notes and annotations. Very nice.

02 May 2015

MICR code for SBI

Why is it so difficult to get MICR code for SBI from official SBI website? Getting teh IFS Code or IFSC is easy.

25 January 2015

ShopClue Less

This is a crib post. I frequently purchase articles online and most of the times there is promise of amazing deals from shady or semi-shady websites. i ignore and stick to the few well-known ones; even there I have received poor quality good and have had no problems returning those. Recently, I came across a websites called Shopclues dot com. There was an amazing "deal" or "offer" on CFL lamps. It seemed to be really good and I have heard about these sellers from some friends. I do not think they gave positive reviews nor necessarily negative ones either. Anyway, partly curious and partly out of, I admit the "greed" to grab a good deal, I placed the order for two CFL lamps. The photo in the shopclues website was blurry but I could decipher a brand. I was under the impression that the brand they ship might be good but they choose not to mention the name. Well, long story short; when the wretched things came; the CFLs were crushed. I do not know what went wrong and where but there was no packaging at all for the lamps. Just that they were dumped in a big cardboard box and dispatched. Also, the brand of the lamps was one which I saw for the first time ever. The courier was RedExpress; do not know if this is a shady courier service. The beauty comes now however. I went to the "returns" part of shopclues; and one has to enter the reason for return. Fine; but then the beauty is that YOU the customer has to take photos of the material and upload those. Then the jerkoffs of ShopClues would consider your case and issue a refund or whatever. I sent an email to the Shopclues wretches stating clearly the problem. I pointed out to them that they do not seem to have any quality control check in place, and tie up with the most dodgy of sellers; and doubt the integrity of the buyers who have upped their money. The regulation response came from some low IQ wretch manning the website. The buffoon merely reiterated their policy, expressed his deepest anguish, sorrow and other emotions at my troubles and then fowarded the same link as before which demands that I upload a photo. 
Anyway, I did not want to take a photo and demean myself( at least I think it is demeaning). So, the lesson is "Buyer Beware". Now that I have had first hand experience with ShopClues; the big message to you prospective customers is: be prepared to take the photo of your damaged product before you see back a rupee. Many of us do not check the returns policy before buying. I give you people a free early warning for this dodgy website.

01 November 2014

Elementary 2d rotation registration

Hopefully would prove useful for someone!
Representation of rotation is angle only; and optimisation is steepest decent. metric is the sum of squared difference metric. Shared purely for pedagogical purposes. Python code is horribly unoptimised.


import numpy, cv2
import scipy
from scipy import ndimage
import matplotlib
from matplotlib import pyplot
#def rotate_correct(fixed, moving, init_angle=0):
DATA_DIR = 'your_data_path_here';
FILE_NAME = 'fixed.png';
ROT_FILE_NAME = 'moving.png';
INIT_ANGLE = 0;
#
fixed = cv2.imread( DATA_DIR + FILE_NAME, cv2.IMREAD_GRAYSCALE);
moving = cv2.imread(DATA_DIR + ROT_FILE_NAME, cv2.IMREAD_GRAYSCALE);
#
fixed_im = numpy.float32(fixed);
moving_im = numpy.float32(moving);
registered_im = numpy.copy(moving_im);
#
NUM_ITER = 25;
STEP_SIZE = 0.00001;
BORDER = 70;
N = registered_im[BORDER:-BORDER, BORDER:-BORDER].shape[0]*registered_im[BORDER:-BORDER, BORDER:-BORDER].shape[1]
INIT_SSD_COST = registered_im[BORDER:-BORDER, BORDER:-BORDER] - fixed_im[BORDER:-BORDER, BORDER:-BORDER];

INIT_SSD_COST = numpy.sum(INIT_SSD_COST**2);
print('Initial_SSD: {0}'.format(INIT_SSD_COST))
estimated_angle = INIT_ANGLE;
D = numpy.gradient(registered_im);
D0 = D[0];
D1 = D[1];
term1 = numpy.zeros_like(fixed_im);
#
prevSSD = INIT_SSD_COST;
prev_angle = INIT_ANGLE;
for iter in range(NUM_ITER):
   
    term1[BORDER:-BORDER, BORDER:-BORDER] = registered_im[BORDER:-BORDER, BORDER:-BORDER] - fixed_im[BORDER:-BORDER, BORDER:-BORDER];
    update = 0.0;
    for x in range(BORDER,fixed_im.shape[1]-BORDER): #X direction
            for y in range(BORDER,fixed_im.shape[0]-BORDER): #Y Direction
#                 rotation_matrix = numpy.array( [ [numpy.cos(angle), -numpy.sin(angle)], [numpy.sin(angle), numpy.cos(angle)] ]);
                rotation_matrix_deriv = numpy.array( [ [-numpy.sin(estimated_angle), - numpy.cos(estimated_angle)], [numpy.cos(estimated_angle), -numpy.sin(estimated_angle)] ])
                x1 = x*rotation_matrix_deriv[0][0] + y*rotation_matrix_deriv[0][1];
                y1 = x*rotation_matrix_deriv[1][0] + y*rotation_matrix_deriv[1][1];
                term2 = D0[y,x]*x1 + D1[y,x]*y1;
                update = update + term1[y,x]*term2;
    update = STEP_SIZE*update/N;
    estimated_angle = estimated_angle - update;
    D0 = scipy.ndimage.rotate(D[0], estimated_angle*180.0/numpy.pi,reshape=False);
    D1 = scipy.ndimage.rotate(D[1], estimated_angle*180.0/numpy.pi,reshape=False);
    registered_im = scipy.ndimage.rotate(moving_im, estimated_angle*180.0/numpy.pi,reshape=False);
    SSD_COST = registered_im[BORDER:-BORDER, BORDER:-BORDER] - fixed_im[BORDER:-BORDER, BORDER:-BORDER];
    SSD_COST = numpy.sum(SSD_COST**2);
    currSSD = SSD_COST;
    if currSSD > prevSSD:
        estimated_angle = prev_angle;
        print('Minima reached. Exiting loop');
        break;
    else:
        prev_angle = estimated_angle;
        prevSSD = currSSD;
        print('Iter: {0}'.format(iter+1)),
        print('Step Update: {0} Estimated Angle: {1}'.format(update*180.0/numpy.pi, estimated_angle*180.0/numpy.pi)),

        print('SSD: {0}'.format(SSD_COST/INIT_SSD_COST))
    if iter == NUM_ITER - 1:
        print('Max iter reached. Exiting loop');
##
SSD_COST = registered_im[BORDER:-BORDER, BORDER:-BORDER] - fixed_im[BORDER:-BORDER, BORDER:-BORDER];
SSD_COST = numpy.sum(SSD_COST**2);
print('Final_SSD: {0}'.format(SSD_COST/INIT_SSD_COST))

print('Estimated_angle: {0}'.format(estimated_angle*180.0/numpy.pi))
##
DISPLAY = 0
BORDER  = 1;
if DISPLAY == True:
    #
    pyplot.subplot(131)
    pyplot.imshow(fixed_im[BORDER:-BORDER])
    pyplot.gray()
    pyplot.title('Before image difference')
    #
    pyplot.subplot(132)
    pyplot.imshow(moving_im[BORDER:-BORDER])
    pyplot.gray()
    pyplot.title('After difference ')
    #
    pyplot.subplot(133)
    pyplot.imshow(registered_im[BORDER:-BORDER])
    pyplot.title('Registered image')
    pyplot.gray()
    #
    pyplot.show()

31 August 2014

Scary story about Monsanto in India

This is a very scary story. One can understand that there are various peculiar professions humans undertake so that they can make money. However, I cannot understand what kind of moneylust, lack of morals or ethics and shamelessness one must possess to work in such companies or the cola companies.

27 April 2014

Vignettes:corporate life

We shall not take the names of the actual characters on whom the following short conversations are based, so as not to embarrass the organisations where the incidents or conversations actually happened. However, in order to give the reader, a summarisation of one aspect of the character or mental makeup of the the people involved; we shall use nicknames entirely.

Conversation Snippet 1:
Greenhorn: Dude, I saw you wagging your head consistently throughout the conversation you had in the cabin with the Manager. What gives? Have you been declared a Role Model?

The Wise Browser: Well, we know the Flight or Fight instinct in Living organisms.

Greenhorn: Yes, but are you going to launch into one of your analogies in mythology?

The Wise Browser: I apologise. 

Greenhorn: Alright, go on.

The Wise Browser: During conversations with Managers, one cannot fight. It is futile. Therefore, the other option is flight. Unfortunately, being enclosed in a glass cabin makes that impossible as well. But the body is crying to do something; then the involuntary response is what you observed.

Conversation Snippet 2:
Greenhorn: The new computers we ordered have arrived and the ITMS have delivered them to my desk. All of these assets are in my name. Why not I transfer these to your name, and you can allocate as per user request? Also I want to move all of those to your cabin.

The Leader(TL): Why do you want to do that? Just keep them. What do you have in your cupboard?

Greehorn: Books and papers.

TL: Well you can make some space. Look at it this way, you are more powerful now. You are the "owner" of all those machines. Haha..

Greenhorn: Haha.... Going by the same logic, the watchman of the warehouse is most powerful man in this centre then. haha...

TL: Well, lets not get flippant about this.

Conversation Snippet 3:
The Manager: You have used PCA for this project; PCA is 50 years old technology. We can have any Masters student do what you are doing; why would we have PhD people for this work?

Conversation Snippet 4:
The Browser: Sir, the Optimiser is getting scary.
Greehorn: Come on, dont whine as usual.
The Browser: No, it is true. I wrote C code for xxxx(some image processing algorithm). Now the Optimiser wants it in C++.
Greenhorn: First, for this deliverable, C or C++ makes no difference. Secondly, I think you have used some feature of C++; at least you have named some of the files as cpp. Maybe that is enough to convince the Optimiser...?
The Browser: Sir.... the Optimiser is asking , "where is class"? C++ must have class.

Few days later....
Greenhorn: Sir, did you re-write everything in pure C++ as demanded?
The Browser: Well, I wrote a class and put all the functions written earlier in this one class. The Optimiser is very happy..

13 April 2014

Highly irritating song and fake lyrics

1. On the radio, a highly annoying song gets played all the time. The lyrics go 
"Tumne maari entry yaar" from movie Gunday. I think the music directors and the lyricists should be immediately executed for crimes against humanity.

2. There is one more irritating song; filled with poetic sounding urdu words. It is very clear to me that the writer has no sense of the language. The dunderhead came up with these words to sound cool or something. The moron is named Amithabh Bhattacharya and movie is Hasee to Phasee. I would not recommend outright execution, but deport the donkey to Pakistan. He can wax his Urdu there better. You may guess the song.

I feel better already!