Creating a ‘difference’ in portraits

Image by Hamed Saber
Image by Hamed Saber

I was reading a magazine where each article had the photo of the author besides it, but in a unique way: looking like something like on the right.

How to get this effect yourself? I will show you today.

In addition to Photoshop you need Microsoft Photo Editor to get this effect. You may have this already on your system, if you have MS Office or you may not – it has been discontinued by Microsoft. If you do not, you can download it from here or here:

First, open the photo in Microsoft Photo Editor, and then go to File->Properties. In the ‘Type’ field select Monochrome (1 bit) from the drop-down, and press Ok. Save the image.

Microsoft Photo Editor
Microsoft Photo Editor

Second, open the original photo in Photoshop (or any other photo editing tool like GIMP). Also open the photo modified through the photo editor. Drag the modified photo over the original, as to form a new layer on top.

Third, (for the modified image layer) bring up the Selective Color panel, by clicking on Image->Adjust->Selective Color. For ‘Colors’, select ‘Black’ from the drop-down – and choose suitable values for the sliders (or as shown below in the screenshot).


Fourth, select a suitable blending type from the layers window, and suitable Opacity which suits. For this image, we used ‘Overlay’ and 55%.


Save the image – flatten it before saving if you want, and you are done. If there is a way to do this without using Microsoft Photo Editor, please post comments.

There are variations possible, if you prefer. One is to ‘Invert’ the original image in Photoshop before submitting it to the MS Photo Editor (by going into Image->Adjust->Invert) and then proceeding as described.

The other is to use only the unicolor image produced by the MS Photo Editor, without blending it with the original. You could use a plain single color layer as the lower one, and do the selective color on the other.

Variation I
Variation I
Variation II
Variation II
Photo by Hamed Saber
Photo by Hamed Saber

Making letter portraits

Manmohan Singh letter portrait
Having been impressed by letter portraits (see right), I wanted to figure out how to do them myself. In addition, I have shown you a lot of my own photos on this blog, without making the readers any wiser on how to do stuff. Better late than never, they say – so lets get started.

Choose a photo that you want to convert. Not every photo is a good candidate: the photo should be simple, not having a lot of detail. A bigger size say 640 x 480 should be available, and should have some contrast. For the purpose of this tutorial we will use this tree:


The result may not look very good because the photo does not have a unique recognisable shape, but will work fine for this tutorial. You may want to try yourself with this better photo of Indian PM Manmohan Singh:

Manmohan Singh

Step 1 is to open a word editor and type (or copy!) some text into it. It looks best if the text is related to the person whose photo portrait you are making. Times new roman font is preferable, Size 14, Bold. Set the zoom to 70% for good results. Take a screen print using Alt-Print Screen key on your keyboard, and bring into Photoshop. The result looks something like this:


Now crop to retain the text, and copy-paste multiple times to achieve the size you need.

Moving over to the main photo (the tree), go to Window->Show Channels. Click on each channel one by one, and see which one has the highest contrast. Retain that one, and delete the others:


Now click on Image->Mode->Grayscale and then on Image->Mode->RGB.

Finally, when your two photos are exactly the same size, drag the text over the main photo – or copy paste as a new layer. The photo with the text should be on top and the other below.

Now go back to Window->Layers, and from the blending mode (upper left corner where it says Normal), select Screen. Things should look like this:


Flatten the image by going to Layer->Flatten Image.

What you want to do after this is up to you. You may want to do Image->Adjust->Threshold for complete B&W look. For, as for example with the PM photo above, you may need to do some cleanup using the Eraser tool for a ‘clean’ look.

If all this is too much work, being a lazy person like me – try this website:
Upload a photo, and it creates a colored text portrait. Its beautiful and you can choose the characters. Take a screenshot (using Alt-Print Screen) of the result and crop in Photoshop, to save as an image.

If something is hard to follow, please post in comments and I will simplify. The Manmohan Singh photo is by ‘ahinsajain’.


Making scores comparable

How to compare scores rated under different tests, or by different people? Find out, and use the ready spreadsheet to crunch your own numbers.

Assume that we have feedback on team members from two different project managers.

People-> U V W X Y Z
Managers |
A 70 63 82 91 56 77
B 68 60 80 80 55 60

Can we say that W performs better in team A compared to team B? It looks like yes, he works better but analyse the scores a bit deeper. Project manager B has rated all team members lower than manager A. It may be that he is using tighter scoring.

In a different situation, it may be that two teams (of different people) have gone through two different tests, and we want to compare the people against others. Or, a university might want to compare people passed out in 2001 with those passed out in 2009.

The question is, how do we compare people when the scores that we have do not use the same basis.

Bell Curve - CC Attribution License
Bell Curve - Created using HSB Grapher

The answer is: normalization. We fix the mean score, and the degree of deviation that we would like to see. For a 100 marks test, we may want 50 as the score and a 20% deviation. Now, we will compare this with the actual mean and the deviation of each of the sets, and modify the scores as needed. Please refer to the attached spreadsheet which helps you do this.




In the given example, A has a mean of 73, and a deviation of 13. B has a mean of 67 and a deviation of 11. Let us bring both to a mean of 70 and a deviation of 15.

People-> U V W X Y Z
Managers |
A 66.3 58.1 80.4 91 49.9 74.5
B 71.2 60 87.9 87.9 53.1 60

So we note that A is indeed better in project A, but only slightly. Also from the initial figures we might have concluded that U is better in Project A, but actually the reverse is true.

Mathematically this process is called Normalization and is useful in fitting scores to a bell curve. Read more about it here if you are interested. However the spreadsheet attached is sufficient to get you started.


Top 10 considerations when preparing a software test plan


Click on images to enlarge

-> Test the parts of the application that have changed since the last cycle / go live

This part of the test plan is very obvious: test the changes to the application. Each change needs to be tested individually if possible, or as groups if the number of changes is large, and is known by the name regression testing.

For example, if you added a new field called ‘maximum pay by date’ to the voucher batch interface, then you could test the interface for this – having both data with this date entered, and with this date set to blank.

There is nothing more to this one – its normally the facet of testing that does receive the due focus during testing.

-> Test sampled parts of the application that have NOT changed

Now we come to something that does NOT receive the due focus. The parts of the application that remained unchanged. No, you do not have to test ALL if it. If you can test all of the application (especially with automated tools, as discussed below) – nothing like it. However, at least test 10-15% of functionality that has not changed.

For example – as discussed above – if you changed the voucher batch interface, then you can test the online voucher entry. Under the online voucher entry, test at least one scenario that has not changed.

The rule of the thumb is that if in a module having 100 test cases, 40 have changed – then test those 40 that have changed, and test 6-10 of those 60 that have not changed.

-> Look at it from the end users perspective: do one full cycle end to end

Next to include in the plan is something you can call integration testing: if your application is about users entering vouchers and getting paid – perform this cycle as a user would do. Many times we IT folks test only our application – the one we are developing and forget the rest of the glue technology. It falls into the category where we want to do it, yet are lazy at – so we find some short-cuts.

Once I was asked to carry out testing for a reconciliation report that had already been tested by the developers. I uploaded the same input twice, which ended up showing double on the final report. It turned out that the developer had missed this because he tested only on the basis of data that already existed in the system, and did not upload any new vouchers.

-> Stress testing

stress testing

Stress testing should again be a very critical part of your test plan. How many users are expected to use the application? during normal hours? during peak hours? Plan for all such scenarios. Design the business process that would take place if the application does fail – the idea should be that the user’s work doesn’t get halted.

There are stress testing tools available both free and commercial that you can use to simulate users.

In one of my projects, a web application that was created for 800 users, failed under a load of 35. Increasing the number of processors, or the number of server boxes is not a guaranteed way of handling load on the application: the application has to be designed to support the load from the ground up, and tested suitably.

-> Performance testing

performance testing

How long does a file take to get processed? How long does the user expect it to take? How long it takes for the screen to open/save?

The user expectation part is sometimes ignored. Please go ask the users of your application now what their expectation is – or it might already be too late in terms of coding.

The developers might think if a process runs for one hour its good enough. However, the users might be needing to run it six times a day during the closing period. Hence one hour might not be fast enough. In such a scenario we had to run four parallel instances of a process to achieve the user specified timing.

-> Concurrency testing

Can two different instances of the new process run together? The panel you just created: can it be used by two persons at the same time? Does it cause deadlocks at the database level if 100 instances of the process are run together?

Can two different versions of the application exist on the same machine?

These are the kind of questions that you ask yourself while working on the ‘concurrency’ aspect of test plan/execution.

A team of developers once needed to clone a process, and create slightly different functionality. However, it turned out that when both the processes were run together, 1 times in 10, one of the processes would fail. This was noted after go live 🙂 Turned out the cause was incorrect use of the shared temporary tables by one of the processes.

If you are interested in Deadlocks technically please read my posting: “Oracle Deadlocks: the What & the How“.

-> Unit test before Integration testing

Our laziness at work again: we ‘trust’ our work and want to move directly to integration testing. Partially, the waterfall model of software development is also to blame here.

99% of the times, after the developer moves directly to integration testing – the very first test case for the application fails, and the developer comes back to the unit testing phase. 🙂

Unit testing is a very critical part of your test plan – if you do it right, you will find hundreds of issues that will otherwise never get detected. Even not during integration testing.

Build ‘driver modules’ to iterate through all the ‘ifs and whiles’ that have been coded. Try out all avenues control can flow through.

-> Create test history

Creation of a test history is as important as doing the testing. Being able to, at a later date, answer such questions as: ‘what are cases we tested?’, ‘what are the problems we found?‘ etc is very helpful. Showing a clean slate (a ‘pass’ on all test cases) at the end of all our test iterations is not so helpful. In short, record the problems found, even though they may get corrected later on.

-> Automated testing

Automated testing solutions can be a big help. It does not mean that all testing be delegated to the automated testing mechanism: but it can definitely be an add-on to your manual testing.
In changing the order entry functionality, use it to enter 1000 different orders. There are several solutions available (use google) that will record the user actions, and will repeat those actions later with different data.
At a very simple level, AutoIt is a great tool for automated data entry, and is free (GPL). Its very flexible and has a great library of functions built into its scripting language. I use it all the time, and not just for testing!

-> Code review

While we focus on all these great ways of testing let us not forget our tried and tested workhorse: code review. Being humans, we are tempted to feel that by doing better testing (being easier to do) we can offset the need for a good code review, but there are hundreds of reasons to do code review.
There may be some program flows designed for rare situations which may never get tested. Code review in such a case will contribute ideas for such test cases. Documentation may not be in sync with the code, with the potential to make future changes difficult. There may be code improvements possible: for example, replacing an ‘if condition’ with a more specific check.

There are other things, depending on your scope you may also want to include them:

-> Knowledge transfer/competence testing

-> Backup & recovery testing

All the best, post your comments here.


Hiding WordPress categories

Photo by John Poyntz Tyler
Photo by John Poyntz Tyler

When I wrote my first WordPress related post, I admitted that I was only doing it to attract traffic and it would be my last post on the subject. However, I start again. This time around, however, I want to talk about something which isn’t common knowledge and neither did I get any responses on the official WordPress forum regarding this.

Suppose you do not want some of your posts to appear anywhere: not the homepage, not the RSS feeds, not the archives: nowhere. However you DO want it to appear only when its linked to, as a single post on the page. I regularly need to do this, because some part of the post is more like an ‘addendum’ or when including everything would make the post too long.

There is a standard solution available on the forums: creating a plugin and adding code to this effect:

function hs_cat_exclude($query)
if ($query->is_feed || $query->is_home || $query->is_archive ) {
$hsq = $query->gt;get('cat');
if (!isset($hsq)) {
$hsq = '-22';
else {
$hsq = $hsq . ",-22";
return $query;


Here, 22 is the category number of the category I wanted to exclude.

This code works fine, but the moment you add is_category to the ‘if‘ clause, it doesn’t work for the category page. This was perplexing to me, and I did not understand it. I spent a long time and then decided to dig deeper. I found out that the ‘wiring’ is faulty (this is what I believe). It can’t work like this for the category page. What is needed additionally is something like this:

function hs_cat_exclude_cat($where)
global $wp_query;
if ($wp_query->is_category) {
$where = $where . " AND NOT EXISTS(SELECT 1 FROM wp_term_relationships WHERE AND wp_term_relationships.term_taxonomy_id='22')";
return $where;


So far so good. What I wanted over and above this though, is for the category to not even appear on the category widget. I tried to find a way to get this done through the plugin but it did not work. Ultimately I had to ‘hack’ one of the core files to achieve this. If anyone knows of a better way to accomplish this, please add a comment. The change is to wp-includes/widgets.php. Find the line of code that looks like:

$cat_args = array('orderby' => 'name', 'show_count' => $c, 'hierarchical' => $h);

added an ‘exclude’ clause like this:

$cat_args = array('orderby' => 'name', 'show_count' => $c, 'hierarchical' => $h, 'exclude' => 22);

Thats all there is to it.

Update Jan 12th 2010: Since WP 2.8 I believe (I noticed the problem in 2.9.1), the last change above needs to be done to default-widgets.php rather than widgets.php