Sunday, March 11, 2018

Eye strain is not caused by digital screens

What information you trust, is upto you. Either you believe the amateur 'researchers' who observe and study other people and make short-term conclusions or you believe your local story-teller and repeat whatever they say without verifying OR you believe me because I've faced this problem at it's most severe stages and know exactly what causes it and how to remedy it.

Fact 1: Whether you read a book or drive a vehicle with your eyes needing to remain focused constantly on something, your eyes will get strained. Eye strain does not get extra severe just because you are looking at a digital screen. It's the same amount of strain.

Fact 2: The strain by itself is not an issue. It happening on a daily basis is not the real issue either. The real issue is that (assuming you don't have other medical problems) no matter how much you claim that you are getting enough sleep, you actually aren't. If you get sleep your eye muscles will recover while sleeping and your strain won't build up to a stage where it hampers you.

Fact 3: When your eyes are strained, washing your eyes or looking at far away objects or exercising your eye muscles do not help AT ALL. The only thing that helps is keeping your eyes closed for 5 to 10 minutes and relaxing your neck and face muscles.


What to check for:

  • Sleep: If you are confident that you are getting enough sleep, that's your biggest mistake. Very seriously and thoroughly evaluate yourself on whether you are getting a minimum of 7 to 8 hours of continuous sleep every night. I stress on the word "continuous". Waking up at night to pee or being woken up by noise (even if you go back to sleep immediately) or sleep apnea or waking up due to stomach discomfort or waking up after 4 hours of sleep and being unable to go back to sleep etc. are signs that you aren't getting enough sleep. Keep a diary where you write the approximate time you slept and woke. You'll be surprised. Feeling sleepy many times during the daytime is a clear indication that you lost sleep at night. Being awake with your eyes closed does not count.
  • Other medical conditions: Astigmatism or deficiencies leading to dry eye or other medical conditions might be a problem, but verify your sleep sufficiency before blindly accepting what the doctor says. Getting second opinions is not guaranteed to give you the right diagnosis. I met thirteen doctors who didn't have a clue on what caused my eye strain and how to cure it. I have been shocked and disappointed at the lack of competence of doctors at diagnosing the actual cause of eye strain. That, plus their enthusiasm at making money. There are some doctors though, who actually are experienced enough to identify the problem and carefully examine your medical history and symptoms before they come to a conclusion. Find these doctors.
  • Food and water: It's medically known that stomach problems cause sleep problems and sleep problems cause stomach problems. Both of these problems wreck havoc on the rest of the body. I've listed what precautions to take with food in this post.
  • Plastic lenses: I'm not talking about contact lenses. I'm talking of the plastic/polycarbonate lenses on spectacles. They do not provide visual acuity that is as good as a glass lens. I've tried Crizal, Zeiss, few other major brands, tried lenses with special coatings...all useless when it comes to eye strain. An ordinary glass lens with no special coating gives far better clarity and visual acuity than a plastic/polycarbonate lens. Your eye faces less strain when you look through a glass lens. Even looking through a glass lens causes slight strain, but not as much as plastic/polycarbonate. You are lucky if you aren't having to wear spectacles. I haven't tried contact lenses yet.

How to fix your fatigue-induced eye strain
  • Stage 1: It'll take a while for you to verify the cause of the strain. During that time, you can use eye drops or Lacrigel (after consulting a doctor) to give you some relief. Use Lacrigel only if your strain is chronic. Remember: The eye drops or Lacrigel are only for a few weeks of use just to give you some initial relief. They won't solve your problem and they are not meant to be used forever. Make sure you close your eyes for 5 to 10 minutes every hour.
  • Stage 2: Examine what food you eat. If you eat from an office/college canteen or a stall or a restaurant, chances are high that you are eating food that is either not fully cooked or has burnt particles in it or is of poor quality. Trust me, a majority of people in this world (including you) are very very poor judges of food quality. Drinking youghurt/curd after dinner helps give some relief and your sleep will improve with time as you change your food habits to eating properly cooked home food.
  • Stage 3: Make it a point to close your eyes and relax your face muscles everytime you feel even a slight bit of strain. Don't push yourself to work harder unless you have got your rest first. If your job is demanding, find another job. No job, boss, career, pay or recognition is worth as much as your health. I learnt that the hard way.
  • Stage 4: Get a good amount of exercise. Exercising does not help reduce eye strain at all. It however does help in maintaining good health which could give you slightly improved sleep and general body function.

I see a whole lot of amateur articles and health professionals speaking (and scare-mongering) about eye strain while spreading unconfirmed and circumstantial evidence which misleads a lot of people. Some even trying to make a business out of it. All you really have to know is that unless you have some underlying medical condition, simple fatigue-induced eye strain can be cured just by getting your eight hours of sleep and a ten minute rest when your eyes are tired.  It may take a few months, but that's all there is to it. You don't have to spend a fortune on special spectacles or medication. Take care.

Sunday, February 11, 2018

Do you have to wear a suit to a wedding?

Short answer: Not really necessary, but good if you can.

Long answer:
A suit comes into the picture only after the major necessities are covered. A relative once said: "Anybody can make excuses; but for the person who really wants to attend an event, they will make sure they are there, no matter what". Although his quote seemed like words of wisdom long ago, one now realizes that it is a bit too harsh on people. When dealing with randomness and emotional beings, it isn't right to apply hard rules on anyone.

The first most important thing you can do for someone's wedding, is to attend it when you have been invited. Being there for that person.

The second most important thing is not something for you to consider. It's for the hosts and the other guests to consider. Judging others. I know of people who scrutinize every tiny bit of detail about how another person dresses and grooms themselves. It's the equivalent of burying your head in your smartphone screen during an event. When at a wedding, try to help out with whatever you can and make the day special for the families of the bride and groom. At other times, socialize with others and try making them feel special by letting them talk about what they like and encouraging them to speak about events in their life which they cherish. Do try avoiding negative comments on the appearance of other guests. He who throws mud gets his own hands dirty.
When a person has shown the courtesy of attending an event, it is your duty, whether you are the guest or the host, to make that other person feel comfortable and welcome. Remember that rituals, customs and formalities are just a conjuring that are not anywhere close to being worth as much as a person's sense of self worth and respect.

That being said, if a wedding invite specifically mentions casuals, wear casuals. Else, the best bet are formals. If you have a good suit, wear it. If you don't have one or it's at the dry cleaner's, then a well groomed appearance with a formal shirt, pant and shoes will do just fine.

Remember: Mutual respect and consideration are far more important than a suit.

Tuesday, January 23, 2018

Of cruelty mistaken as cuteness and affection

People find weird things cute. They pluck off the reproductive parts of plants, sniff it and gift it to people. They enjoy watching animals perform tricks. They keep flight-gifted creatures as pets in tiny cages.

A little digression. This isn't similar to how vegans oppose the cruelty meted out to animals. We have to eat. Even the plants are mercilessly uprooted, made to suffocate during transport, chopped, boiled and killed when still alive. The eyes of the potato watch you as you approach it with a knife :-) But basically, we have to eat. So whether you eat plants or animals, there's nothing wrong. If you still want to oppose that, then the right way to end it is by manufacturing the chemicals that constitute food, 3D printing it into food and eating it.

There is a natural order to everything. If we are meant to eat animals and plants, then so be it.
However, when it comes to gifting and pets, there are some things a sensible human can do:

1. Flowers: Gifting the dying carcass of a plant reproductive system is not a necessity.
2. Animal tricks: Unless the animal actually enjoys it (dog taught to fetch a ball), don't make animals do tricks.

3. Birds as pets: This is the main topic I was coming to. Many people, especially women and children, love the idea of keeping birds as pets. People; no matter how well you take care of your birds, I call it sadist behaviour. A pair of birds were gifted to a family member, and she wanted to breed them. So they gave rise to five more baby budgies, and she's really happy.
I've observed the behaviour of these budgies for many months now. Although they are reasonably affectionate to humans, their natural behaviour tends to finding the highest perch available and flying away from human contact as much as possible. They are independent, intelligent, curious creatures that are denied their freedom because somebody thinks it's cute to own them.

Here are some things you need to know:

  • The bait: Pet shop owners sell budgies at Rs.150 per bird. One thinks that's reasonable until one realizes that for the duration of the bird's life, one has to buy it seeds from the same shop. So each bird sold, gives them a permanent customer. Now that they know they got you hooked, they charge exorbitant prices for the seeds. In Bangalore, bird seeds that are meant for budgies and finches, are purchased by shop owners for Rs.26 per kg and sold at Rs.50 or even at Rs.100 per kg. The same people sell it at Rs.220 or Rs.300 per kg on online shopping sites. Also sold, are vitamins etc. which the birds don't really need if you simply feed them with a natural diet of greens along with the seeds. Feeling cheated already?
  • The possible scam: The pet industry in USA is worth $66 BILLION. I've known shop owners India who deliberately or unknowingly keep pet birds and fish which have parasites, so that customers who buy it would come back to buy more when the pet dies. I've also purchased plants from a local seller who said he had medicines for plants if I ever needed them. I asked what the medicines were, and he didn't know. A week after purchasing the plants, powdery mildew started growing on them and it never went away. The plants were in a constant state of death. I'd suspect they deliberately sold us diseased plants so that there would be more business via "plant medicine" sales. Would the increase in pet cancer be from something deliberately introduced into pet food? Just speculating.
  • Don't set them free: Animals and birds raised in captivity do not know where to find food and how to defend themselves. They also do not have the stamina to escape predators. They don't even know how to escape predators when pursued (I've seen it happen). If you already have a pet, keep it with you and care for it. Don't let it breed and create more of its kind that will have to live a captive life too. If you have birds, give them a larger space to fly around. Don't think you are giving them sufficient opportunity to fly if you have an aviary or allow them to fly in your room. A bird enjoys flying only when it's able to flap its wings and then glide at high speed for a long distance. Breeding a bird and keeping it caged denies it of its fundamental right to fly free.

Having a pet was an old tradition. Of a time when cruelty was considered normal. Crazy behaviour was considered a normal part of a ritualistic, egoistic society. Of a time when people were a lot less civilized and immature.

We do not have to continue those practices. Please....stop buying pets. Stop breeding them. Stop forcing them to live an unhappy, bored life in captivity. If you've rescued them and are taking care of them, it's an entirely different thing. Just don't breed more captives for your pleasure/profit.

Your imagined cuteness is a heartless cruelty.

Monday, January 15, 2018

Summary: Ubuntu's 17.10 bug 1734147 which makes motherboards unusable is now fixed

The last time I tried Ubuntu 17 was on a non-Intel motherboard, so nothing happened. But there was something that I didn't like, so switched back to 16. Now I read that Ubuntu 17.10 has a bug which corrupts the BIOS and prevents USB boot.

Why it happens: This happens because Intel's SPI driver (allows the OS to rewrite firmware's flash memory) causes the firmware to become write protected. This happens only in Intel Broadwell and Haswell machines with serial flashes with SPI_NOR_HAS_LOCK set.

If your BIOS is affected: Try the fixes mentioned on this page. If it doesn't work, you may have to replace the flash memory chip or the entire motherboard, depending on how it is manufactured.

Is it fixed? Yes. This page mentions the problem, the fix and the machines affected. You can now fearlessly download Ubuntu versions higher than 17.10, and you won't have any trouble.

Lesson: Although contrary to conventional advice, it helps to not have automatic updates enabled, and to upgrade to a new version of an OS only after some time has elapsed since its release.

Wednesday, December 13, 2017

An open letter to hospitals that make patients relatives run around to get blood

A relative of mine was being treated at a hospital, and I heard the hospital was making his friends and relatives run around, to arrange for replacement blood donors. Since he was undergoing plasmapheresis and dialysis, there was a huge demand for blood. Moreover, even though they brought blood donors and paid the donors, they still had to pay extra for blood units that the hospital gave. That was a shame. Especially for a hospital that claimed to treat its patients well.

I wrote a letter to them. The links in the letter are important. They will take you to a whole new level of knowledge.


I know there's no point in taking you on a guilt-trip of making relatives of patients running around trying to find blood donors, so let's get down to some facts:

I understand hospitals have their own logistics to worry about, but when you have a marketing term that claims to treat people well, the hospital's word-of-mouth advertising will definitely improve when people know that this is one hospital that does not inconvenience people. Apart from the blood donation aspect, I really appreciate other procedures that are followed well in the hospital.

Kindly forward this to the person who can take decisions on organizing blood donation drives. Meanwhile, I hope your hospital could immediately stop inconveniencing people and instead organize for processed blood units to be brought to the hospital from other blood banks (which follow strict guidelines). You could of course charge a premium on it.


For the reader: If you can organize for donors, then please do. There is indeed a shortage of blood. But be aware that you are not obligated to.
Bangalore itself needs an average of 800 units of blood everyday!!! Do encourage and participate in blood donation drives. It's the best way to ensure there is safe blood available for everyone in need. Encourage hospitals to organize frequent blood donation camps instead of just complacently indulging them with replacement donors.


Some points from the links above:
  • With no official complaints raised by the public, corporate blood banks have no incentive to walk away from replacement blood. “Grievances can be filed at the PM’s portal,” Centralised Public Grievance Redress and Monitoring System (CPGRAMS), “which collates grievances from multiple sources and forwards them to the state government, nodal officer, or blood bank concerned,” says Dr Shobini.
  • Shobini Rajan, assistant director general, National Aids Control Organisation (NACO), said the blood policy doesn't say it is illegal for hospitals to ask for donors but it is undesirable.

More on blood donation:
And volunteering:

Saturday, December 9, 2017

Forgot BIOS password and removing CMOS battery does not work?

In the "good old days", if you forgot your BIOS password, all you had to do was open up the computer, remove the CMOS battery or remove the jumper near the battery and your CMOS password would get reset to no password.

That's changed now. I recently reset my laptop to CMOS factory default settings, saved and exited, and it asked for a password the next time I wanted to enter the CMOS settings. I had not even set a password!!!

Opening up the laptop and finding the CMOS battery was an interesting proposition, so I did just that. Removed the battery, replaced it after 30 seconds, put back all components, started the laptop and it still asked for a password. Darn! Going through the laptop manual showed that the battery had to be removed and kept aside for at least an hour.
Ok good. So I did that. Waited for more than an hour, put back all components, started the laptop and bang. There was the password prompt again!
Turns out that there was a person who even kept the battery aside for three months and yet the password didn't reset. It's likely to be stored in a more permanent location in memory in today's computers.

The solution:
After a lot of anxious searching, I found this website. The ultimate guide to resetting the BIOS password.
Turns out that when you take your computer to the official service people, they don't need to know your BIOS password or hack into it with brute force techniques.
They simply use a default password that the manufacturer programs into the motherboard. These are called backdoor codes.

So all you have to do is try out some of the openly available backdoor codes on the website, and if that doesn't work, then try entering some random password three times and your BIOS password prompt will show you a number. Enter that number into this website and it'll show you the backdoor password for your BIOS.

That's it! I was able to access my CMOS settings screen again and this time I set my own password.
Do try this before you take your laptop to some service person who'd use the same simple technique and then charge you a bomb because you'd think they used some super secret hacking technique to elegantly solve your problem for you.

Monday, October 30, 2017

You can check your voter details online

The draft electoral rolls for Bangalore are out already, and voters can now check/edit their details online.

There is a regional website where the backend didn't function properly, so I'd recommend going to the other regional website which takes you to the national website. Sadly, none of the websites have https, so anything you enter there could be viewed by someone else. Your browser will inform you about this the moment the webpage opens.

Once on the national website, you can search for your existing voter information. I typed in my details and it didn't find anything, but on clicking the Search by EPIC number tab, I entered my voter ID and was shown my details which were exactly what I had entered earlier, and the backend didn't even return an exact name search match. Since the websites were powered by C-DAC, I wrote to them and hope they'd introduce HTTPS.

Still, as long as you are ok with not using https, you can use the website to submit forms online and track your application status online.
Forms are available for:
  • Inclusion of names for residents electors    
  • Inclusion of names for overseas electors    
  • Any objection on inclusion of names       
  • Correction of entries in the Electoral Rolls     
  • Transposition within Assembly

Some thoughtful person has also created a nice caricature document explaining general voter information. Do go through it and show it to kids.

Sunday, October 22, 2017

Do a 'Google Trends' on Google Books

This may actually be quite a good incentives for scholars and literature enthusiasts, for uploading more books online.
Similar to how Google Trends gives you graphs to compare various Google search terms used over the years, Google Ngram viewer allows you to search and compare the usage of words and phrases used in books over the years. You can even add wildcard characters like the asterisk, and even specify if what you are searching for is a noun or an adjective etc. Two researchers, Sparavinga and R.Marazzato even wrote a paper on it.

For example, searching for "how are you" vs "how do you do" shows that "how do you do" was used more in the 1700's, but slowly the usage declined. On a side note: the reply to "how do you do" is "how do you do", and not "I'm fine".

More on how Ngram works:

If your work is primarily on Google Scholar, there are good search tools (including advanced search) and metrics information available to gauge the visibility and influence of articles published. Useful tools.

Saturday, October 21, 2017

Mostly, time spent online is time well spent

Which is better? Finding a bunch of intellectuals online, who love discussing your favourite topics on artificial intelligence, general knowledge, TED talks, research efforts worldwide or switching off your phone and computer and spending time with relatives who gossip about their neighbours, discuss cricket runs scored and discuss religious rituals? *yawn*

Have a look at this toon from Wumo.

Interacting online has the advantage of filtering out a HUGE amount of irrelevant data, awkwardness and annoyances. If you like it, there's nothing wrong with liking it. Time is precious to all of us. Let's spend it doing what we like, and with the people we like. Whether the people are online or physically present with you is irrelevant.
It's the genuineness of your connection with them that matters.

That being said, physical meetings have a flavour of their own, and should be encouraged at the comfort level that people would like it to be encouraged.

As for Simon Sinek's narrow observation...'s easy to use the pointing finger to highlight "what's wrong with this generation", but one has to know that this is what every generation has been saying about the next generation for the past millenia.

The truth is, there's nothing ever wrong with a generation. There's nothing ever wrong with how people do things. Some people build good relationships, some don't. Some people adopt and use technology in specific ways, some don't. Some people will always be less confident and unhappy, some won't. That's how we are meant to be as a population. There's nothing wrong in that.

Every single species on this planet was not meant to live and behave in a certain way forever. We evolve. We are meant to evolve. When you see someone doing something different, it's because that's what they are meant to do. We as a generation, have better access to information. We know and understand relationships better. We know whom to connect with and when to run away from toxic people. We've even researched and spread awareness about addiction to social media. We learn from people all around the world.

Accept change for the good it brings. For as someone once said: There is only one constant: "Change". Rather than point fingers at a generation of people, see how these well informed, intelligent people can help you and you'll be surprised!

Tuesday, September 12, 2017

A tutorial on Differential Evolution and Otsu's method for image thresholding

The first thing you need to know before your foray into computational intelligence (CI), is that the creators of these algorithms themselves don't know how it works. CI algorithms are inherently analytical techniques that depend on randomness to give solutions that are close to optimal, but not necessarily the best solution. It's like finding a lovely house in a city and choosing it as your home, but you have not actually found out if it is the best house that you could find in the city, because you just did not have the time to explore. The fact that people come up with naming these algorithms after animals (bat algorithm), insects (ant colony, bee colony, glowworm algorithms) and bacteria (bacterial foraging algorithm) is an amusing practice because the lack of theoretical backing makes the creation and optimization of the algorithm more of an art than a science.

Still, the way these algorithms improve over the generations is very impressive. This video shows you how:

This tutorial covers the topic of finding thresholds for a grayscale image using a CI algorithm named Differential Evolution (DE). We check if the thresholds are good enough by using the Otsu criterion. The best references for DE and Otsu criterion are the original papers presented here and here.

What is image thresholding?
Consider Lena's image. When you convert the red, blue and green pixels to gray colours, you end up with colours ranging from 0 to 255. Zero is black. 255 is white and the numbers in between are shades of gray (I'm not talking of Fifty shades of gray). Now if you decide that all pixels below the shade 118 are going to be converted to black and all pixels above or equal to 118 are going to be white, you end up with an image like this:

This is called "image thresholding" or "image segmentation". There are more complex ways of doing image segmentation though. The basic idea is to try and separate the image into distinct segments based on our interest. Sometimes we want to distinguish between foreground and background. Sometimes, to distinguish between parts of objects or multiple objects. If the threshold were closer to 50 or 10, the image would appear too dark. So we have to figure out which threshold will give us an optimum image. An image where the pixels are shaded in such a way that the objects in the image are well distinguished from other objects. An "optimal threshold".

So how did we find this threshold at 118?
We used the "Otsu" technique. A person named Otsu figured out that a simple and nice way to segment images was to first create a histogram of the pixels and then statistically analyze the histogram.
This is what Lena's histogram looks like:

The vertical columns are the count of the pixels of a particular shade of gray. Notice the bottom of the graph showing the shades of gray. At shade 100, the vertical column just crosses 2000. It means that the Lena image has a little more than 2000 pixels which have the gray shade of 100.  These vertical columns are called "bins".

In statistics, there is a concept of "class", which is a group of objects with a similar property. So in the above histogram, we want to find a threshold which would separate the pixels into two classes. Black pixels and white pixels.
Otsu figured out that he could statistically find the best combination of classes (and hence the location of the best threshold), by examining the mean and variances of the classes. He created a formula and called it "finding the between class variance". This between class variance will be used as a value that gives us the "fitness" of the image. Higher the value, better the threshold.
If there are two thresholds, there would be three classes. As shown in the image below, the image would be eventually shown with all pixels below grayscale 32, as white. Anything equal to or above 32 and below 106, as gray colour 32 and any pixel equal to or above 106 as white.

The calculation goes like this:

The gray histogram is first normalized. Each of the 0 to 255 bins of the histogram are iterated as i.

probability of i = number of pixels in bin i / total number of pixels in image
total mean = sum of probability of i of all bins

If there are t thresholds, then there will be t+1 number of classes c the image can be segmented into. So with a threshold of t=1, there would be classes c1 and c2. Class mean values would also be computed as mean1 and mean2. Or, as shown in Figure 2.1, if there are two thresholds t1 and t2, there would be three classes and therefore three mean values calculated.

pc = probability of class occurrence c = sum of probability of i of all bins in c
class mean = sum of (i * probability of i of all bins in c) / class occurrence c

Class variances of each class c are calculated as:

class variance = sum of ((i - class mean)2 * probability of i / probability of class occurrence c)

The variance between the classes gives the fitness of the threshold. 

between class variance = sum for all bins(pc * (class mean - total mean)2

Note that the between class variance (BCV) is one single value. You don't calculate between class variances for each threshold and sum them up. You use the one formula given above to calculate it.

Ok, so now we know how to calculate the fitness of a threshold, we can write a simple for loop that places the threshold at the zero'th position in the histogram and calculates the BCV. Then move the threshold to position 1 of the histogram and find the BCV and keep going on for values 2, 3, 4 ... till 255. The threshold with the highest BCV will be the optimal threshold. For a single threshold of the Lena image, it is at 118.

Now you'd say. Hey, that's it? We just have a search space of 0 to 255? Then why do we need a computational intelligence algorithm? Couldn't we just use normal for loops?

Well, for one threshold you can do an exhaustive search from 0 to 255. For two thresholds, you'd have to run two loops nested. So that's 2552. For four thresholds, the number of iterations are 4294967296. It would take 95 days to compute on Matlab.

Enter the saviour: Computational Intelligence algorithm: Differential Evolution:

The basic idea of DE is to place thresholds randomly within 0 and 255, and keep evaluating the BCV. With some luck, you will get good thresholds which won't be the best, but will be good enough.

The secret weapon of DE is "mutation" and "crossover". Similar to how we have a population of humans and our genes undergo mutations and crossover of traits, the DE algorithm initializes a 'population' of vectors. If we are solving a problem of finding two optimal thresholds, then each vector will contain two random thresholds. During the DE algorithm, these vectors will be combined randomly with other vectors in the population to provide some variety to the result, and somehow, we end up finding near-optimal thresholds. Nobody knows how, but it works. Magic.

If there are 4 thresholds and a population of 3 vectors, the vectors would look like this:
X1 = [t1; t2; t3; t4];
X2 = [t1; t2; t3; t4];
X3 = [t1; t2; t3; t4];
Where, the t1 of X1 does not have to be the same as the t1 in X2 and so on.

This is the pseudocode for my DE algorithm:

  • Load image and convert to 8 bit grayscale
  • Generate histogram from image. Bins ranging from 0 to 255
  • Initialize DE parameters: PopulationSize, thresh, crossover probability (cr), beta.
  • Set thresh number of thresholds each, randomly within bin space for each population entity X.
  • Evaluate initial fitness of X
  • forEach generation for a defined number of iterations
  • forEach population p for PopulationSize
  • Select population entity p from X.
  • Select 3 distinct populations from X. The thresholds should not be equal to p.
  • Generate mutant Up = X1 + beta * (X2 – X3)
  • If Up == Xp, regenerate threshold at random position for Up and continue;
  • Crossover at least one threshold from X to U and other thresholds if generated rnd <= cr
  • If mutant thresholds are outside histogram range, regenerate threshold at random position
  • end for population
  • Evaluate fitness of Up
  • forEach population p for PopulationSize
  • If fittest mutants in Up are fitter than fittest Xp, replace Xp with fittest Up
  • end for population
  • decrease beta by 40-1
  • end for generation

Beta value: Ranges from 0 to 2. A high beta value ensures that the mixing of vector values have a much larger variation, so the mutated vector will end up far from the existing vectors. This is called "exploration", and helps visiting many other threshold positions within the 0 to 255 values. Smaller values of beta keep the variations of threshold values closer to the existing thresholds. This is called "exploitation", as you have found a good threshold already and are trying to exploit that area to find better thresholds in the area. Beta is also called the constant of differentiation.
The crossover probability: Ranges from 0 to 1. Having a low crossover probability like 0.2 was found to help reach an optimal threshold faster, but it does not necessarily reach the most optimal threshold. A higher value like 0.8 helps reach a more optimal threshold, but it can take three times more number of generations to do so. Setting cr=0.3 appeared to help reach an optimal threshold with a slightly higher number of generations than cr=0.2. Allows exploitation of symmetry and separability of a function.

That's all there is to it. You can have multiple thresholds and the time of execution is just around a minute or two in Matlab even for 6 or eight thresholds. This is a major advantage of CI algorithms. You could achieve the same results with genetic algorithms, particle swarm optimization, bee colony algorithm or bacterial foraging algorithms.

The code for the DE algorithm and Otsu method, I've listed here:

Monday, July 31, 2017

Creating a dual boot with Windows and Ubuntu when you have UEFI

People on many blogs say that you have to disable secure boot when you have UEFI and want to install Ubuntu alongside Windows 8 or 10.
Not necessary. You don't even have to switch to Legacy boot.

The basic concept to understand is, that if you have UEFI, you'll have to tell the boot manager where to find your boot file. That's all.

After a lot of searching and ending up at all the wrong blogs and posts, I finally found this post. Worked perfectly!

The steps are:
  • Install Windows, leaving a separate partition for Ubuntu
  • Install Ubuntu on that partition
  • Reboot and enter BIOS screen
  • Follow the steps here about selecting grubx64.efi
  • Save and exit BIOS

That's it! You've got a dual boot system. Grub will show you the options for booting into either Windows or Ubuntu.
If anything goes wrong, you can always press F12 when starting your computer to see the boot options.

Oh btw, don't disable secure boot. It's a very important feature that prevents your system from getting infected at boot time, by malware that might be in an external drive that's connected to your PC at boot time.

Thursday, July 27, 2017

Our Income Tax department has a strange maintenance message

I logged into my income tax e-filing account yesterday, and saw this message: "You are not authorized to view this page because either your bank details of your PAN and profile details are incorrect or these details have not been passed onto e-Filing. Please contact the owner of the information for details".

Needless to say, I was completely perplexed. I had filed my taxes correctly and mentioned my bank details correctly. My profile and PAN details were correct too. Why this message? Moreover, because of this message, I couldn't even access my dashboard or file a grievance.

A bit of Googling revealed that few other people had faced the same issue since 2014. One of the answers on a forum said that this message shows up when the website is undergoing some routine maintenance, and we should check back after six to twelve hours.

I logged back in the next day and sure enough, everything was back to normal.


I do hope our e-filing department changes that message to something like "Routine website maintenance ongoing. Please check back after few hours".

This is for all of you who were perplexed by this message and didn't know whom to ask. Hope it helped.

Sunday, June 18, 2017

How to download files or an entire folder from Google Drive?

I've found it very strange that a product of Google didn't have a straightforward way to download files or an entire folder in one shot.

There is a way though:
  • As shown in the image below, click the folder or file you want to download
  • Then click the menu button to open the menu.
  • Then if you don't see a download option in the menu, just click the empty area at the bottom of the menu.

You'll get your folder in zipped format.

I assume it's just a bug that the download icon isn't visible.
Another way to download is to double click the file to open it and on the top right corner of the screen you'll see the download icon.

UPDATE: I wrote to Google support about this issue, and as of August,  the CSS issue with the hidden download button is fixed. There also was another issue of people using Chrome being unable to download files. Google told me they are working on fixing that too. Until then, you could just use incognito mode to download.