Support Linux by Not Writing Linux-Only Software

Phoronix ran a story today about the keynote address at this year’s Fedora India Conference.  The speech can be viewed in its entirety here, but one quote in particular is drawing attention:

The number one enemy we have today is ourselves. And I mean that with all seriousness. Too many times we shoot ourselves in our own foot, by the way we act, the way we deal with people, in our narrowminded-ness that we develop.

The quote and ensuing explanation appears around the 44:00 mark.  It’s worth a watch.

This is a great quote not just for Linux developers and contributors, but for Linux users as well.  It’s especially interesting coming from a Fedora project leader, considering the Fedora project is well-known for its very myopic rules about included software.  (FYI – Fedora does not include any proprietary software, including proprietary drivers, Adobe Flash, Skype, etc.  Is that an example of “shooting yourself in the foot”…?)

In this article, I’m not going talk about the obvious “Linux is its own worst enemy” topics.  Plenty of other people are more qualified to talk about hardware support, FOSS jingoism, obnoxious users, design problems.  No, I’d like to mention something more obscure, but still deserving of attention:

Developing software exclusively for Linux.

Linux-exclusive software should be the exception, not the rule

One of the Linux-centric software projects I’ve followed over the past several years is the OpenShot Video Editor project.  I first discovered OpenShot while researching Linux video editing software in 2009 for a series of Ubuntu articles.  At the time, I considered OpenShot the best choice for default video editor in Ubuntu 10.10.  Canonical eventually went with Pitivi instead, a decision I and many others wondered about.  To quote one article on the topic:

In my view, Ubuntu is doing desktop Linux a huge disservice by putting in basic, buggy tools and then advertising its product as having “video editing” capabilities. The short point is that it hasn’t, and users moving to Ubuntu on the basis of this promise will be bitterly disappointed, tainting their overall view of Linux.

Canonical later rethought this decision; in 11.10 they removed Pitivi from the default install.  The reasoning behind the decision?  According to the linked article:

The lack of ‘polish’ and maturity to the application was also highlighted, with one attendee wondering whether its ‘basic’ nature impacted negatively on the perception of the Ubuntu desktop as a whole.

Ironic, eh?

I don’t mean to slam Pitivi.  Collabora, the company who funds Pitivi’s development, is an incredible contributor to the open-source world and they employ a team of very talented developers.  Seriously – they just released a demo of a video editor built entirely in HTML5.  They’re incredible.

But writing desktop video editing software is tough, especially video editing software provided for free.  Pitivi continues to grow and improve, but it simply wasn’t ready for the big-time in 2009.  That’s okay.

Anyway, OpenShot continues to improve at an impressive rate.  In late 2010, OpenShot crossed what I consider the “maturity line” for an open source project – it began work on a Windows port.  The response to this was mixed, as always.  Many users realized the benefits of making OpenShot cross-platform.  Some, unfortunately, did not.  As one commenter said:

When I’ve seen projects that aim to be multi OS, the Linux version is always the second hand version. More people use Windows so new features are added to the Windows version and no one gives a shit about the Linux users. I have seen it many times, haven’t you?

Why not just use all the time for the Linux version to make it as great as possible. There are already more than enough video editors for Windows anyway.

This is a valid concern.  Take Songbird, for example.  Songbird started out as a promising cross-platform media player with top-tier Linux support.  This lasted four years, until the team made the hard choice to completely drop Linux.  It was an unfortunate loss, but it’s hard to fault the Songbird developers.  They’re a small team and audio support in Linux has never been simple to work with.  (FYI, untested nightly builds are still available for adventurous users.)

But I would argue that projects like Songbird are the exception and not the rule.  While it may seem like Linux-only projects are betraying their loyal base by developing Windows or OSX versions, I would argue that cross-platform development is actually better for Linux as a whole, better for individual software projects and their developers, and ultimately better for Linux users.

Cross-Platform Software Removes One of Linux’s Biggest Barriers of Entry

It’s been said a million times before: one of the hardest things about switching from Windows to Linux is learning new software.  This has gotten easier over time; after all, modern users are probably using the same browser on Windows that they would on Linux, and mature open source projects like LibreOffice, Pidgin, GIMP and Inkscape provide a similar experience regardless of which OS you use.  As we move to a world where more and more software lives within the browser, the switch will get even easier.

But when a new Linux user can’t find a Linux version of software that he or she is used to (Adobe products, MS Office, etc), they suddenly have a very good reason to give up on the platform as a whole.  Even if a Linux alternative is better than whatever they were using before, the fact that it isn’t familiar is often enough to scare them away.

The typical answer to this is: “everything would be better if Adobe and Apple and Microsoft and everyone else just released Linux versions of their software.”  I agree.  That would be better.

But does anyone really think this is going to happen?  Do you really envision a day when you can buy a copy of Microsoft Office for Linux?  I’m afraid I don’t.

So if we can’t force companies to release their software on Linux, we have to do the next best thing – take the best of Linux software and make it available on other platforms.  In the last five years, projects like Firefox and Chrome have done way more to improve Linux adoption than the Linux-only competitors of Epiphany and Konqueror – not because either of those projects are crap (just the opposite, they’re great), but because creating software only for Linux users doesn’t help people make the switch.

Now please don’t misunderstand.  I am absolutely not saying that projects like Epiphany and Konqueror are stupid, or that they don’t serve a purpose, or that they are hurting Linux.  Both are mature, well-written, technical accomplishments from talented contributors, and they definitely fill a niche.

But when it comes to making Linux a viable competitor to OSX or Windows, Firefox and Chrome are the ones to thank.

(Note: yes, I realize that webkit came from KHTML which came from Konqueror.  This doesn’t invalidate my point.)

In the perfect world, Linux users would have access to all the same software as Windows and OSX users.  Releasing a Windows and OSX port of your awesome Linux-only project is a step toward making that happen.

As a Developer, You Will Get More Donations, Support, and Feedback from a Cross-Platform Release

Let’s return to the Songbird example.  In the team’s blog post about why they dropped Linux, they provide the following chart “for perspective”:

It’s hard to argue with those numbers.  Yes, in certain areas (like translations) Linux users contributed more on a per-user basis than Windows or Mac users.  But not that much more.  When you factor in the difficulty of working with audio in Linux, you can see why the Songbird team made the tough decision to drop Linux support entirely.

This same pattern shows up elsewhere.  For gamers, consider the Humble Indie Bundle – Linux users donated 3x more money, per user, than Windows users.  That’s an awesome statistic.  But the sad reality is that there are tons more Windows users, and for the Humble Indie Bundle that meant that revenue from Windows users as a whole was significantly larger than revenue from Linux users.

I point this out only to show that open source developers can receive many benefits – financial and otherwise – from releasing software on as many platforms as possible.  And if you as a developer get more feedback and more money, that will help you produce better software for everyone who uses your products – including your loyal Linux fanbase.

This Isn’t a Major Problem, But It’s Something to Consider

Is Linux-only software the biggest problem facing the open source community?  Hell no.  It’s probably not in the top 10 or 100 or 1000 problems.  But I do think it’s something to point out, especially for Linux projects that seem perpetually close to becoming “great”… only never quite getting there.  Several examples come to mind.

Calligra (formerly KOffice) is a promising open-source office suite developed by KDE.  Personally, I think the project is way ahead of LibreOffice in key areas, particularly the interface.  Consider their word processor, which is one of the few designed with widescreen monitors in mind:

Calligra Words screenshot. Note the very nice use of horizontal real estate. (image courtesy of http://www.calligra-suite.org/words/)

I’m not a Linux software developer, but I would love to contribute to the Calligra project as a tester.  My problem?  I spend most of my time in Windows, and I need a word processor that works in both OSes.  Calligra’s Windows version is in a perpetual state of disarray, and I don’t want the hassle of running my word processor in a VM.  How many testers and contributors is this very cool project missing out on because there is no Windows port?  Would a complex piece of software like LibreOffice or Inkscape be half as good if it had remained Linux-only?  I doubt it.

As another example – Linux video editors.  We’re finally reaching a world where Linux video editors are stable and usable (kudos to the excellent Kdenlive team and OpenShot, among others), but it has taken far, far too long to get here.  In my opinion, the biggest problem is that most major Linux video projects have remained Linux-only.  Kino and Cinelerra have always been in desperate need of testing and feedback, and by ignoring Windows they aren’t doing themselves – or their faithful Linux users – any favors.

Disclaimers

Now I realize that you can’t just click a magical button that makes your Linux-only project compile under Windows and OSX.  I get that.  If you’re an individual developer who doesn’t have the time or the resources to test and compile your code for Windows, I totally understand.  Some projects don’t make sense multi-platform, and sometimes there are very good technical reasons why a project doesn’t make an OSX or Windows version available.

But if you haven’t considered cross-platform support, please do.  Look for help on developer forums or IRC.  Talk to Windows packagers of other open source projects.  Follow OpenShot’s example and ask your userbase for help.  Just don’t fool yourself into thinking that you are helping Linux by not providing Windows and OSX versions of your software.

Because you’re probably not.  By releasing your software for as many OSes as possible, you are not betraying Linux or open source.  You are helping it.  If people think Linux represents a small fraction of overall users now, imagine how much worse it would be if less cross-platform software were available.

As for my fellow Linux users: please don’t troll developers when they decide to go cross-platform.  FOSS is not just about developing for Linux.  Open source can – and should – work to increase the freedom of all users, everywhere, regardless of what operating system they use.  When your favorite piece of Linux software decides to release a Windows version, don’t think of it as betrayal.  Think of it as a way to advertise the benefits of open source to your heathen, Windows-using friends.

As always, I am extremely grateful to the talented individuals that use their time and talents to provide open-source software for free.  Thanks for all your hard work.

Song: Find You (March Remix)

Download song: mp3 Ogg FLAC MIDI

Note: The original version of “Find You” can be found here.

Today’s download digs deep into the archives of an old video game project I was involved in (circa 2002). The original version of this song is a simple orchestral theme led by an oboe melody (linked at the top of this article). The game called for an action sequence using the original song, but it didn’t really fit; the original mix is slow and unassuming, which isn’t generally what you want accompanying an action sequence.

As an alternative, I put together this demo of the theme remixed as an orchestral march. It retains the instrument mix of the original, but the oboe is moved to a supporting role while the melody is taken over by a trombone.

Because this was just a demo, it’s only two short movements separated by a key change. Though the video game project dissolved before reaching completion, I enjoyed the opportunity to show off the versatility of the original theme.

Creative Commons License

"Find You (March Remix)" by Tanner Helland is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Permissions beyond the scope of this license may be obtained here.

This site - and its many free downloads - are 100% funded by donations. Please consider a small contribution to fund server costs and to help me support my family. Even $1.00 helps. Thank you!

How to Access Science and Medical Research without Paying an Arm and a Leg for It

In past articles, I’ve mentioned that I spend much of my career poring over scientific and medical research.  This is equally parts invigorating and frustrating.  On the one hand, the Internet makes it possible to track down just about any research paper imaginable, whether it’s a paper from the turn of the century or one in pre-publication stages.

Unfortunately, this excitement is often tempered by frustration because access to most research papers costs a ridiculous amount of money.  More and more journals are adding free, open-access options, but many of the big hitters (Science, Nature) continue to charge exorbitant amounts for one-time access to individual articles.  As an example – I clicked on the first article from this month’s issue of Nature: “Verbal and non-verbal intelligence changes in the teenage brain.”  This sounded like an interesting article, the kind of thing many laypeople would be interested in, especially parents and teachers of teens.  Unfortunately, the cost for accessing that article is $32 USD.  For that price, you may as well buy a 330-page non-fiction book on the topic (which was published late last year, so it’s even up-to-date).

Sadly, $32 is reasonable compared to some journals.  I’ve seen journals that charge more than $50 USD per research paper – even for ones 20+ years old!

Thus the impetus for this article.  There are a number of ways to legally access scientific and medical research without paying ridiculous per-paper access fees.  I’ve accumulated a lot of these strategies over years of trying to track down papers for FDA regulation purposes.  Some might be obvious (especially to grad students or other researchers), but I still think it worthwhile to mention them.  My hope is to help people – especially those researching medical issues – find the information they need without spending thousands of dollars to do it.

Note: potentially illegal methods of accessing journal articles, including torrenting, Usenet, and other file-sharing techniques, will not be discussed or endorsed.

Step 1 – Finding relevant articles

Before doing anything else, you must first locate papers relevant to your research topic.  As someone who has skipped this step before, let me warn you – few things are more frustrating than spending hours tracking down a research paper, only to find out it doesn’t actually discuss what you want.

In my experience, the best place to start is almost always PubMed.  PubMed is a free research database service provided by the U.S. National Library of Medicine.  PubMed is incredibly comprehensive; as of October 2011 it has indexed more than 21 million records going back to 1809, with another half-million articles added every year.  Because PubMed is so comprehensive, many other science and medicine search services use it to fuel their own engines (EBSCO, Google Scholar, Ovid, etc).

The PubMed homepage has a search bar at the top – type the topic of your search there, then hit Enter to see what turns up.

Sample PubMed search for Alzheimers Disease
Here is a sample PubMed search for "Alzheimers Disease." Make note of the "5580 free full-text articles in PubMed Central" box on the lower-right.

PubMed works like Google or any other search engine – generic search queries will return many articles; more targeted search queries will return a shorter, more relevant set of results.

As with a Google search, you can freely peruse PubMed’s list of articles, but I tend to go straight for a particular box on the right-hand side – the one titled “free full-text articles in PubMed Central.”  Clicking on the “See all…” link at the bottom of that box will refine your search results to show ONLY articles whose full contents are available for free.  (Note: a shortcut way to do this is to select “PMC” from the drop-down box on the PubMed homepage.  However, the two clicks required to change the drop-down box is actually more cumbersome than a single-click of “See all…” on the search results page.)

PubMed Central, or PMC, is an awesome subset of PubMed that deals only in free full-text research articles.  PMC is an outgrowth of the National Institute of Health’s goal to make all publicly funded research available to – imagine this – the public.  Originally, researchers funded by the NIH were encouraged (but not required) to make their research publicly available.  This changed in 2007, when H.R. 2764 was passed, requiring NIH-funded research to be made publicly available within twelve months of publication.  I try to avoid political commentary on my site, but I’m not afraid to say that H.R. 2764 is one of the few unilaterally great pieces of legislation George W. Bush signed into law.

If you find what you need at PMC, great!  You’re all done.  Unfortunately, while PMC’s article database is growing at a steady rate, it won’t always have exactly what you need.

For that, we need to turn to something a little broader.

Step 2 – Google Scholar

Google Scholar (scholar.google.com) is a specialized version of Google’s regular search tool.  Google Scholar indexes research articles from standard indices like PubMed, then cross-references those articles with Google’s massive database of regular web pages.  This cross-referencing comes at a trade-off – on the one hand, it will generally return many more articles than a comparable PubMed search.  However, a lot of those extra discoveries will be irrelevant websites, questionable corporate marketing materials that sound like research, alternative medicine books, and an occasional patent or legal opinion.

The big advantage Google Scholar has over PubMed, however, is if a free copy of a research article exists anywhere on the web, Google will usually be able find it and associate it with its actual paper.  Let me demonstrate.  Below is a screenshot from a Google Scholar search for “Alzheimers Disease Coffee.”  I chose this search term because a growing body of research has associated coffee intake with a reduced risk of Alzheimers Disease, and I wanted to learn more about it:

Sample Google Scholar search
Google Scholar results for "Alzheimers disease coffee."

If you look to the right of the search results themselves, you’ll notice that two lines have a additional light blue link.  The first says “[HTML] from oxfordjournals.org” and the second says “[PDF] from indiana.edu”.  These little boxes are Google’s way of notifying you that they think they’ve found a full-text version of this particular article.

The second full-text link – the one associated with “Managing care through the air” – is a fine example of how Google Scholar can help you find papers.  Trying to access that paper through its title link takes you to a “sign in to purchase this article” page.  However, clicking on the PDF link to the right of the title takes you to a PDF version of the paper, which happens to be hosted on a course website from the University of Indiana.

This kind of cross-referencing can help you find papers that would be almost impossible to otherwise locate.  Sometimes an author will chose to provide a modified copy of the paper on a personal website, or perhaps the corporation who funded a paper will choose to make a copy available on their corporate site.  I have personal experience with this; a paper I co-authored on vitamin D supplementation is still in the pre-publication stages, but a poster of the research (containing most of the relevant data) is available from the Science section of the company that performed the research.  Google Scholar can help you track down these “hidden” copies of research articles.

While Google Scholar is very useful, a caveat is in order.  Sometimes Google will link you to copies of a paper that may not have been obtained legally.  Oftentimes these are hosted on questionable non-English sites.  Whether or not you choose to access papers via that method is up to you.  The legality of something like that is questionable; the morality of it… well, a discussion of the morality of copyright is beyond the scope of this article.  :)  I’ll leave it up to you whether or not you choose to make use of those kinds of Google search results.

Step 3 – Contact the paper’s authors (or even better, the financial sponsor)

This step applies specifically to privately funded research.  Many times, the organization who funds or performs research will keep copies of the paper on hand for marketing purposes.  All companies I’ve worked for did this, and I’m certain others do as well.  When we were emailed questions about research we had performed and/or funded, we typically replied with a copy of the paper.  Some journals also give paper authors a set amount of free copies of their article, which the author rarely has use for.  (After all, they wrote the paper – they know what it says!)  Send that author a nice email, and you might be rewarded with shiny PDF for your trouble.

Step 4 – Try your local library

This step is very much a YMMV one, but it’s still worth a try.  Some community libraries have access deals with research journals or conglomerates like EBSCO.  These deals allow library patrons to access any research journals that are part of the library’s access package.  In most cases this is limited to the big journals, like Science and Nature; few public libraries have the funds to provide access to specialized journals.

Still, it’s always worth a try, and if the library doesn’t have what you need, a librarian may still be able to help you in your search.

Step 5 – Find a college student or professor

I debated leaving this step for last, since it’s probably the most foolproof way to access science and medical journals… but because it is contingent on knowing (or being) a university student or professor, it may not work for everyone.

While local libraries don’t often have funds to pay for unlimited access to thousands of medical journals, many university libraries do.  Again, this will vary from library to library, but university libraries are capable of negotiating very favorable access to a wide range of research journals.  This is obviously in their best interest – the more research students and professors have access to, the stronger their ability to learn and perform their own research.  Some have argued that library quality should be a major aspect of a student’s college selection.  I agree.

If you know a college student or professor, provide them a reference to the research articles you’re interested in and see if they can help you track down a copy.  If you live close to a university – especially a public one – see if the school’s library allows non-students to sign up for library cards.  Most state schools have provisions for this.

Finally, if you are an alumni of a university or college, you may still have certain access rights to the school’s library.  A phone call or email may be all it takes to get a copy of a research article for personal use.

Conclusion

We live in a golden age of scientific and medical research.  Each year, tens of thousands of top-quality articles are published in peer-reviewed journals.  Many of these articles are directly funded by your tax dollars, or indirectly funded by your patronage to a particular business or institution.

It saddens me that most of this knowledge is kept out of the public’s reach by poorly built websites and ridiculously overpriced journal subscriptions – subscription costs that don’t go toward funding more research, but paying for outmoded things like printed copies of thousand-page medical journals that will sit, dust-covered and unread, on the back of some library shelf.  It is even more frustrating that the laypeople most inclined to search through medical literature – those currently suffering from illness or injury – are often the least capable of affording what many scientific journals charge.

As a researcher myself, I am certainly interested in researchers being paid for their hard work – and they are, by the universities and companies that employ them.  When you pay $30-50 USD for a journal article, that money does not go to the researcher.  Even worse, it has even been argued that such subscription costs lead to sensational science instead of good science.  I strongly recommend reading the linked article if you are interested in the dynamics of science publication.

Anyway, I hope this article helps anyone interested in scientific or medical research.  Additional suggestions are always welcome; feel free to use the comments section or my contact page.

Seven grayscale conversion algorithms (with pseudocode and VB6 source code)

I have uploaded a great many image processing demonstrations over the years, but today’s project – grayscale conversion techniques – is actually the image processing technique that generates the most email queries for me.  I’m glad to finally have a place to send those queries!

Despite many requests for a grayscale demonstration, I have held off coding anything until I could really present something unique.  I don’t like adding projects to this site that offer nothing novel or interesting, and there are already hundreds of downloads – in every programming language – that demonstrate standard color-to-grayscale conversions.   So rather than add one more “here’s a grayscale algorithm” article, I have spent the past week collecting every known grayscale conversion routine.  To my knowledge, this is the only project on the Internet that presents seven unique grayscale conversion algorithms, and at least two of the algorithms – custom # of grayscale shades with and without dithering – were written from scratch for this very article.

So without further ado, here are seven unique ways to convert a full-color image to grayscale.  (Note: I highly recommend reading the full article so you understand how the various algorithms work and what their purposes might be, but if all you want is the source code, you’ll find it past all the pictures and just above the donation link.)

Grayscale – An Introduction

Black and white (or monochrome) photography dates back to the mid-19th century.  Despite the eventual introduction of color photography, monochromatic photography remains popular.  If anything, the digital revolution has actually increased the popularity of monochromatic photography because any digital camera is capable of taking black-and-white photographs (whereas analog cameras required the use of special monochromatic film).  Monochromatic photography is sometimes considered the “sculpture” variety of photographic art.  It tends to abstract the subject, allowing the photographer to focus on form and interpretation instead of simply reproducing reality.

Because the terminology black-and-white is imprecise – black-and-white photography actually consists of many shades of gray – this article will refer to such images as grayscale.

Several other technical terms will be used throughout my explanations.  The first is color space.  A color space is a way to visualize a shape or object that represents all available colors.  Different ways of representing color lead to different color spaces.  The RGB color space is represented as a cube, HSL can be a cylinder, cone, or bicone, YIQ and YPbPr have more abstract shapes.  This article will primarily reference the RGB and HSL color spaces.

I will also refer frequently to color channels.  Most digital images are comprised of three separate color channels: a red channel, a green channel, and a blue channel.  Layering these channels on top of each other creates a full-color image.  Different color models have different channels (sometimes the channels are colors, sometimes they are other values like lightness or saturation), but this article will primarily focus on RGB channels.

How all grayscale algorithms fundamentally work

All grayscale algorithms utilize the same basic three-step process:

  1. Get the red, green, and blue values of a pixel
  2. Use fancy math to turn those numbers into a single gray value
  3. Replace the original red, green, and blue values with the new gray value

When describing grayscale algorithms, I’m going to focus on step 2 – using math to turn color values into a grayscale value. So, when you see a formula like this:

Gray = (Red + Green + Blue) / 3

Recognize that the actual code to implement such an algorithm looks like:


For Each Pixel in Image {

   Red = Pixel.Red
   Green = Pixel.Green
   Blue = Pixel.Blue

   Gray = (Red + Green + Blue) / 3

   Pixel.Red = Gray
   Pixel.Green = Gray
   Pixel.Blue = Gray

}

On to the algorithms!

Sample Image:

Promo art for The Secret of Monkey Island: Special Edition, ©2009 LucasArts
This bright, colorful promo art for The Secret of Monkey Island: Special Edition will be used to demonstrate each of our seven unique grayscale algorithms.

Method 1 – Averaging (aka “quick and dirty”)

Grayscale - average method
Grayscale image generated from the formula: Average(Red, Green, Blue)

This method is the most boring, so let’s address it first.  “Averaging” is the most common grayscale conversion routine, and it works like this:

Gray = (Red + Green + Blue) / 3

Fast, simple – no wonder this is the go-to grayscale algorithm for rookie programmers.  This formula generates a reasonably nice grayscale equivalent, and its simplicity makes it easy to implement and optimize (look-up tables work quite well).  However, this formula is not without shortcomings – while fast and simple, it does a poor job of representing shades of gray relative to the way humans perceive luminosity (brightness).  For that, we need something a bit more complex.

Method 2 – Correcting for the human eye (sometimes called “luma” or “luminance,” though such terminology isn’t really accurate)

Grayscale generated using values related to cone density in the human eye
Grayscale generated using a formula similar to (Red * 0.3 + Green * 0.59 + Blue * 0.11)

It’s hard to tell a difference between this image and the one above, so let me provide one more example.  In the image below, method #1 or the “average method” covers the top half of the picture, while method #2 covers the bottom half:

Grayscale methods 1 and 2 compared
If you look closely, you can see a horizontal line running across the center of the image. The top half (the average method) is more washed-out than the bottom half. This is especially visible in the middle-left segment of the image, beneath the cheekbone of the background skull.

The difference between the two methods is even more pronounced when flipping between them at full-size, as you can do in the provided source code.  Now might be a good time to download my sample project (available at the bottom of this article) so you can compare the various algorithms side-by-side.

This second algorithm plays off the fact that cone density in the human eye is not uniform across colors.  Humans perceive green more strongly than red, and red more strongly than blue.  This makes sense from an evolutionary biology standpoint – much of the natural world appears in shades of green, so humans have evolved greater sensitivity to green light.  (Note: this is oversimplified, but accurate.)

Because humans do not perceive all colors equally, the “average method” of grayscale conversion is inaccurate.  Instead of treating red, green, and blue light equally, a good grayscale conversion will weight each color based on how the human eye perceives it.  A common formula in image processors (Photoshop, GIMP) is:

Gray = (Red * 0.3 + Green * 0.59 + Blue * 0.11)

Surprising to see such a large difference between the red, green, and blue coefficients, isn’t it?  This formula requires a bit of extra computation, but it results in a more dynamic grayscale image.  Again, downloading the sample program is the best way to appreciate this, so I recommend grabbing the code, experimenting with it, then returning to this article.

It’s worth noting that there is disagreement on the best formula for this type of grayscale conversion.  In my project, I have chosen to go with the original ITU-R recommendation (BT.709, specifically) which is the historical precedent.  This formula, sometimes called Luma, looks like this:

Gray = (Red * 0.2126 + Green * 0.7152 + Blue * 0.0722)

Some modern digital image and video formats use a different recommendation (BT.601), which calls for slightly different coefficients:

Gray = (Red * 0.299 + Green * 0.587 + Blue * 0.114)

A full discussion of which formula is “better” is beyond the scope of this article.  For further reading, I strongly suggest the work of Charles Poynton.  For 99% of programmers, the difference between these two formulas is irrelevant.  Both are perceptually preferable to the “average method” discussed at the top of this article.

Method 3 – Desaturation

Grayscale generated from a Desaturate algorithm
A desaturated image. Desaturating an image takes advantage of the ability to treat the (R, G, B) colorspace as a 3-dimensional cube. Desaturation approximates a luminance value for each pixel by choosing a corresponding point on the neutral axis of the cube.

Next on our list of methods is desaturation.

There are various ways to describe the color of a pixel.  Most programmers use the RGB color model, where each color is described by its red, green, and blue components.  While this is a nice way for a machine to describe color, the RGB color space can be difficult for humans to visualize.  If I tell you, “oh, I just bought a car.  Its color is RGB(122, 0, 255),” you probably can’t picture the color I’m describing.  If, however, I say, “I just bought a car.  It is a bright, vivid shade of violet,” you can probably picture the color in question.  (Note: this is a hypothetical example.  I do not drive a purple car.  :)

For this reason (among others), the HSL color space is sometimes used to describe colors.  HSL stands for hue, saturation, lightnessHue could be considered the name of the color – red, green, orange, yellow, etc.  Mathematically, hue is described as an angular dimension on the color wheel (range [0,360]), where pure red occurs at 0°, pure green at 120°, pure blue at 240°, then back to pure red at 360°.  Saturation describes how vivid a color is; a very vivid color has full saturation, while gray has no saturation.  Lightness describes the brightness of a color; white has full lightness, while black has zero lightness.

Desaturating an image works by converting an RGB triplet to an HSL triplet, then forcing the saturation to zero. Basically, this takes a color and converts it to its least-saturated variant.  The mathematics of this conversion are more complex than this article warrants, so I’ll simply provide the shortcut calculation.  A pixel can be desaturated by finding the midpoint between the maximum of (R, G, B) and the minimum of (R, G, B), like so:

Gray = ( Max(Red, Green, Blue) + Min(Red, Green, Blue) ) / 2

In terms of the RGB color space, desaturation forces each pixel to a point along the neutral axis running from (0, 0, 0) to (255, 255, 255).  If that makes no sense, take a moment to read this wikipedia article about the RGB color space.

Desaturation results in a flatter, softer grayscale image.  If you compare this desaturated sample to the human-eye-corrected sample (Method #2), you should notice a difference in the contrast of the image.  Method #2 seems more like an Ansel Adams photograph, while desaturation looks like the kind of grayscale photo you might take with a cheap point-and-shoot camera.  Of the three methods discussed thus far, desaturation results in the flattest (least contrast) and darkest overall image.

Method 4 – Decomposition (think of it as de-composition, e.g. not the biological process!)

Decomposition - Max Values
Decomposition using maximum values
Decomposition - Minimum Values
Decomposition using minimum values

Decomposing an image (sounds gross, doesn’t it?) could be considered a simpler form of desaturation.  To decompose an image, we force each pixel to the highest (maximum) or lowest (minimum) of its red, green, and blue values.  Note that this is done on a per-pixel basis – so if we are performing a maximum decompose and pixel #1 is RGB(255, 0, 0) while pixel #2 is RGB(0, 0, 64), we will set pixel #1 to 255 and pixel #2 to 64.  Decomposition only cares about which color value is highest or lowest – not which channel it comes from.

Maximum decomposition:

Gray = Max(Red, Green, Blue)

Minimum decomposition:

Gray = Min(Red, Green, Blue)

As you can imagine, a maximum decomposition provides a brighter grayscale image, while a minimum decomposition provides a darker one.

This method of grayscale reduction is typically used for artistic effect.

Method 5 – Single color channel

Grayscale - red channel only
Grayscale generated by using only red channel values.
Grayscale - green channel only
Grayscale generated by using only green channel values.
Grayscale - blue channel only
Grayscale generated by using only blue channel values.

Finally, we reach the fastest computational method for grayscale reduction – using data from a single color channel.  Unlike all the methods mentioned so far, this method requires no calcuations.  All it does is pick a single channel and make that the grayscale value, as in:

Gray = Red

…or:

Gray = Green

…or:

Gray = Blue

Believe it or not, this shitty algorithm is the one most digital cameras use for taking “grayscale” photos.  CCDs in digital cameras are comprised of a grid of red, green, and blue sensors, and rather than perform the necessary math to convert RGB values to gray ones, they simply grab a single channel (green, for the reasons mentioned in Method #2 – human eye correction) and call that the grayscale one.  For this reason, most photographers recommend against using your camera’s built-in grayscale option.  Instead, shoot everything in color and then perform the grayscale conversion later, using whatever method leads to the best result.

It is difficult to predict the results of this method of grayscale conversion.  As such, it is usually reserved for artistic effect.

Method 6 – Custom # of gray shades

Grayscale using only 4 shades
Grayscale using only 4 shades - black, dark gray, light gray, and white

Now it’s time for the fun algorithms.  Method #6, which I wrote from scratch for this project, allows the user to specify how many shades of gray the resulting image will use.  Any value between 2 and 256 is accepted; 2 results in a black-and-white image, while 256 gives you an image identical to Method #1 above.  This project only uses 8-bit color channels, but for 16 or 24-bit grayscale images (and their resulting 65,536 and 16,777,216 maximums) this code would work just fine.

The algorithm works by selecting X # of gray values, equally spread (inclusively) between zero luminance – black – and full luminance – white.  The above image uses four shades of gray.  Here is another example, using sixteen shades of gray:

Grayscale using 16 shades of gray
In this image, we use 16 shades of gray spanning from black to white

This grayscale algorithm is a bit more complex. It looks something like:


ConversionFactor = 255 / (NumberOfShades - 1)
AverageValue = (Red + Green + Blue) / 3
Gray = Integer((AverageValue / ConversionFactor) + 0.5) * ConversionFactor

Notes:
-NumberOfShades is a value between 2 and 256
-technically, any grayscale algorithm could be used to calculate AverageValue; it simply provides
 an initial gray value estimate
-the "+ 0.5" addition is an optional parameter that imitates rounding the value of an integer
 conversion; YMMV depending on which programming language you use, as some round automatically

I enjoy the artistic possibilities of this algorithm.  The attached source code renders all grayscale images in real-time, so for a better understanding of this algorithm, load up the sample code and rapidly scroll between different numbers of gray shades.

Method 7 - Custom # of gray shades with dithering (in this example, horizontal error-diffusion dithering)

Grayscale - four shades, dithered
This image also uses only four shades of gray (black, dark gray, light gray, white), but it adds full error-diffusion dithering support

Our final algorithm is perhaps the strangest one of all.  Like the previous method, it allows the user to specify any value in the [2,256] range, and the algorithm will automatically calculate the best spread of grayscale values for that range.  However, this algorithm also adds full dithering support.

What is dithering, you ask?  In image processing, dithering uses optical illusions to make an image look more colorful than than it actually is.  Dithering algorithms work by interspersing whatever colors are available into new patterns - ordered or random - that fool the human eye into perceiving more colors than are actually present.  If that makes no sense, take a look at this gallery of dithered images.

There are many different dithering algorithms.  The one I provide is one of the simpler error-diffusion mechanisms: a one-dimensional diffusion that bleeds color conversion errors from left to right.

If you look at the image above, you'll notice that only four colors are present - black, dark gray, light gray, and white - but because these colors are mixed together, from a distance this image looks much sharper than the four-color non-dithered image under Method #6.  Here is a side-by-side comparison:

Side-by-side of dithered and non-dithered 4-color grayscale images
The left side of the image is a 4-shade non-dithered image; the right side is a 4-shade image WITH dithering

When few colors are available, dithering preserves more nuances than a non-dithered image, but the trade-off is a "dirty," speckled look.  Some dithering algorithms are better than others; the one I've used falls somewhere in the middle, which is why I selected it.

As a final example, here is a 16-color grayscale image with full dithering, followed by a side-by-side comparison with the non-dithered version:

Grayscale image, 16 shades, dithered
Hard to believe only 16 shades of gray are used in this image, isn't it?
Grayscale, 16 shades, dithered vs non-dithered
As the number of shades of gray in an image increases, dithering artifacts become less and less noticeable. Can you tell which side of the image is dithered and which is not?

Because the code for this algorithm is fairly complex, I'm going to refer you to the download for details. Simply open the Grayscale.frm file in your text editor of choice, then find the drawGrayscaleCustomShadesDithered sub. It has all the gory details, with comments.

Conclusion

If you're reading this from a slow Internet connection, I apologize for the image-heavy nature of this article.  Unfortunately, the only way to really demonstrate all these grayscale techniques is by showing many examples!

The source code for this project, like all image processing code on this site, runs in real-time.  The GUI is simple and streamlined, automatically hiding and displaying relevant user-adjustable options as you click through the various algorithms:

GUI of the provided source code
GUI of the provided source code. The program also allows you to load your own images.

Each algorithm is provided as a stand-alone method, accepting a source and destination picturebox as parameters.  I designed it this way so you can grab whatever algorithms interest you and drop them straight into an existing project, without need for modification.

Comments and suggestions are welcome.  If you know of any interesting grayscale conversion algorithms I might have missed, please let me know.

(Fun fact: want to convert a grayscale image back to color?  If so, check out my real-time image colorization project.)

 

DISCLAIMER: These download files are regularly scanned to ensure they remain free from malicious content. Unfortunately, some virus scanners will flag these .zip files as suspicious simply because they contain source code and/or executable files. I have submitted my projects to a number of companies in an attempt to rectify these false-positives. Some have been cooperative. Others have not. If your virus scanner alerts you regarding these files, please allow the file to be submitted for further analysis (if your program allows for that). This should help ensure that any false-positive warnings gradually disappear for all users.

This site - and its many free downloads - are 100% funded by donations. Please consider a small contribution to fund server costs and to help me support my family. Even $1.00 helps. Thank you!

Norway

“Vi er så få her i landet, hver fallen er bror og venn”

– Nordahl Grieg

Terrible news out of Norway today:

Norway came under deadly attack Friday with a massive bombing in the heart of its power center and a shooting at the ruling party’s youth camp on an island outside the capital…

Though I’m born and raised American, my grandparents were first-generation Norwegian immigrants, and I have many friends and family back in beautiful Norge.  Please keep the country in your thoughts (and prayers, if you believe in that sort of thing) as they deal with the aftermath of these terrible attacks.

(If anyone has links to sites where individuals can contribute money or time or anything else to help, please let me know and I’ll repost it here.)

Real-time Diffuse (Spread) Image Filter in VB6

One brand of camera diffusion lenses
A set of camera diffusion lenses.

In traditional photography and film, a diffusion filter is used to soften light from a flash or stationary lamp.  Specialized lenses are available for this purpose, but the effect can be cheaply replicated by smearing petroleum jelly over the light (seriously) or by shooting through a sheet of nylon.

In image processing, a diffusion filter often means something else entirely.  Photoshop’s “Diffuse” filter randomly rearranges pixels within a set radius.  (GIMP can do the same thing, but the effect is more accurately titled “Spread.”)  This effect can be animated for a cheap explosion effect – something a number of SNES, Genesis, and DOS games used to great effect.

This project demonstrates a simple, real-time method for replicating such an effect.  All code is commented and reasonably optimized, and an animated “special effect” version is provided for those interested.  Unlike Photoshop, this routine allows you to specify separate horizontal and vertical max random distances, as well as the ability to wrap pixels around image edges.

LittleBigPlanet mini poster
Here's the original image (a poster for LittleBigPlanet)
Here is the same image with a diffuse filter applied (max distance=5)
...and here is the image again, but with max distance = 50
...and one more example. This time, edge wrapping has been enabled. Note the bleed of planet pixels at the top and black pixels at the bottom.

 

DISCLAIMER: These download files are regularly scanned to ensure they remain free from malicious content. Unfortunately, some virus scanners will flag these .zip files as suspicious simply because they contain source code and/or executable files. I have submitted my projects to a number of companies in an attempt to rectify these false-positives. Some have been cooperative. Others have not. If your virus scanner alerts you regarding these files, please allow the file to be submitted for further analysis (if your program allows for that). This should help ensure that any false-positive warnings gradually disappear for all users.

This site - and its many free downloads - are 100% funded by donations. Please consider a small contribution to fund server costs and to help me support my family. Even $1.00 helps. Thank you!

Ten Ways I Would Have Changed the Wii U Launch

It’s no secret that the Wii U launch could have gone better. Investors are confused, analysts are confused, gamers are confused, and even Nintendo itself has admitted that the launch was confusing.

After having some time to digest the Wii U launch, I still find myself with a huge list of things I wish Nintendo had done better at E3.

10. Called the system something other than “Wii U”

In the week leading up to E3, the name of the PS Vita leaked. [See kotaku’s story, for example] Everyone made fun of the name. Obviously Nintendo had already solidified the name of Wii U by this point – but if they hadn’t, coming out with a new console with a cool name would have been a great way to upstage the competition.

Instead, they launched with the Wii U name… possibly the only name on earth that makes “Vita” look brilliant. Even a code name would have been preferable to using the actual name.

9. Explained the concept of a “base station” and a “controller”

It’s true that anyone watching E3 should have realized that the Wii U controller wasn’t actually the console. Even so, it’s a bad sign when long-time gamers have to ask themselves “so wait… does that thing run off the Wii? Or does it run on its own?” In the Nintendo link at the top of the story, Satoru Iwata himself says:

“We haven’t made any kind of blunder, but I should have shown a single picture of the new console, then started talking about the controller. The console is not drastically different, and Wii U is about the controller. The console itself will be almost invisible.”

If you’ve seen pictures of the console itself, you’ll realize it’s not exactly “invisible.” Still, since the hardware at the base station is a lot more important than the controller (since the controller is really just a screen with buttons and sensors), Nintendo was crazy to not talk about the base at all during their E3 presentation.

8. Show us something only the Wii U can do (besides play Nintendo franchise games, of course)

The vast majority of the Wii U presentation was spent showing us ways to play games that already exist, and support for games we can already play on other devices.

  • “It has a giant touchscreen!” So does an iPad. So does my phone. So does the PS Vita.
  • “It has dual analog sticks!” So does every other console controller… besides the Wii, anyway.
  • “It has cameras!” See above.
  • “It has gyroscopes!” (yawn)

Then there are the games. Many of the big launch titles – Arkham City, Darksiders II, Metro: Last Light – are already available on all other consoles and PC. Super Smash Bros. 4 was a good announcement, but we didn’t see any gameplay footage. Lego City Stories looks cute, but Lego-branded games are already everywhere.

A compelling console launch needs to explain why you, the consumer, need this console. Whether it’s because of a truly unique control mechanism, cutting-edge graphics, huge exclusives, doesn’t really matter. What matters is that the console sets itself apart from the competition.  The one thing Nintendo consoles always have – Nintendo franchise games – barely made an appearance in the Wii U presentation.

The Wii U launch was surprisingly short on surprises.

7. Announce DVD support

I wanted to add “and Blu-ray support,” but let’s keep things slightly realistic. Nintendo has clearly stated (post-E3) that the Wii U will not play DVDs or Blu-rays. The official reason?

“The reason for that is that we feel that enough people already have devices that are capable of playing DVDs and Blu-ray, such that it didn’t warrant the cost involved to build that functionality into the Wii U console because of the patents related to those technologies.”

I find this reasoning a little bizarre. First, licensing technologies for DVD playback is cheap. Dirt cheap. If Wal-Mart can sell a 1080p upconverting DVD player – with HDMI – for $24 USD (at the time of this writing) the licensing technology is not expensive.

As if that statement weren’t bizarre enough, there’s the observation that “enough people already have devices that are capable of playing DVDs and Blu-ray.” This makes even less sense. By this logic, cell phone manufacturers should not include the ability to play music or browse the web or play games. After all – people already have lots of devices that can do this. Does anyone really believe that more people would have bought PS3s if Sony turned off Blu-ray playback and cut the console price by $10? Or that Microsoft would have sold more 360’s if they removed DVD playback and cut the price by $5?

Additionally, one of the major benefits of having a controller capable of streaming video from a base console would be the ability to watch DVDs – a form of physical media – on a controller without an attached drive.

Nintendo really blew this one. I don’t think I’m alone in saying that the Wii U would be much more tempting if it had full DVD playback and streaming support.

6. Announce some kind of DSi/3DS and Wii U interaction capabilities

It seems extremely odd that Nintendo would release a home console with a big emphasis on “a controller with a screen”without mentioning their handheld devices. After all, Nintendo is no stranger to interaction between a handheld device and a console. They’ve been experimenting with that technology since the N64 days.

If a 3DS – with its dual cameras, touchscreen, gyroscopes, and wireless card – or even a DSi could be used in place of a Wii U controller (or alongside it), I imagine a lot more people would be interested in purchasing a Wii U.

Instead, Sony was the only console manufacturer to discuss console/handheld interaction. Hard to believe Nintendo had nothing to say about this.

5. Give concrete details on the Wii U’s online capabilities

In a lot of ways, the Wii U looks to be the most antisocial console in history. (Besides possibly the Virtual Boy.)

“Do other people want to watch a show? Don’t join in – instead, keep doing what you’re doing on the console!”

“Want multiplayer? Too bad! We’ve only planned for one Wii U controller per console!”

The messaging is bizarre. I really hoped Nintendo would announce great online features to make up for the antisocial nature of the Wii U controller, but what happened instead? Brief statements like this, from Katsuya Eguchi:

“I can’t go into details… We’re trying to find new experiences… In looking at the approaches on the Xbox and PlayStation – what they’ve done and what people have responded really well to – we’ve definitely considered including those kinds of experiences, and we think that our third parties also want those as well… but there are also things Nintendo does and other companies haven’t. We need to balance out what exactly what we need to bring to the user to bring the best experience possible.” [source – kotaku]

That’s an awful lot of words… that tell us nothing about the online capabilities.

A few days later, during a call with investors, President Iwata gave this longer explanation:

To start, I’ll have to say that I don’t have any materials with me today that can illustrate precisely what our online environment will be like, but I can speak generally about the direction that we are moving in.

I think, in general, the online environment is changing quite rapidly.

So, what I have come to feel lately is that the idea of saying, “we are going to create this style of online structure and that we would like you, the developers, to fit into the online structure that we are creating” is perhaps already out-of-date.

I think that Nintendo’s past console business has often included this idea of a set and fixed online structure. So, I think that, going forward, the question is really to what degree Nintendo can create a more flexible system for its consoles.

And, what we found at this point is that, as we discuss the online structure with different publishers, the things that the different publishers want to do are in fact seemingly rather different.

Our current direction is how we can take the desires of the third parties and create a system that’s flexible enough to enable them to do the types of things that they might want to do.

So, for example with the question of VoIP, I think then what we would like to do is work with them on how to enable them to do that. But, what we’re not going to do is to consider as prerequisite conditions that every game includes features like that because obviously there are some developers who may not want to do that.

As for social networks, after examining the penetration and adoption rate of social networking services like Facebook, etc., we’ve come to the conclusion that we are no longer in a period where we cannot have any connection at all with social networking services.

Rather, I think we’ve come to an era where it’s important to consider how the social graph of the social networking services can work in conjunction with something like a video game platform.

So, once we get to a point where we’re able to talk more concretely about our online plans, I think that once you hear what we’ll have to say, you’ll feel that Nintendo has a policy of adapting itself to changes in the network environment in a flexible fashion rather than the one of sticking to a rigid mechanism, or perhaps you’ll notice that we have found ways to take advantage of these types of features like VoIP and social networking, where our systems have been seen as being weak in the past. However, unfortunately, we won’t be able to share anything concrete today.” [source – andriasang]

Confused yet? I know I am. All those words tell us basically three things:

  • Nintendo “can’t afford to have no connection” to social networking services. (no kidding)
  • Nintendo is considering optional VoIP services.
  • Nintendo still isn’t sure what the Wii U’s online services will include.

Being this far into the console’s development and having nothing concrete to say about the online capabilities is concerning.

4. Announce a late 2011 launch date

I think most gamers are excited about the Wii U sharing in great exclusives like Battlefield 3 and Arkham City. However, these games are launching in 2011. The Wii U won’t launch until 2012. That means that if you want to play any of the year’s biggest multi-platform launches on the Wii U, you will have to wait a year (or more!) after the game’s release on other platforms.

Are a lot of gamers really going to purchase an additional copy of Battlefield 3 just to play it on the Wii U? I doubt it. Sharing a multi-platform library with the PS3 and 360 is awesome, but not if major games release a year late.

3. Announce support for achievements/trophies

Some gamers don’t care about achievements and trophies, but I think most care at least a little. After all – when even Minecraft adds achievements, there must be a market for it. True cross-platform support means not just releasing the same games, but releasing the same games with the same features. If the Wii U doesn’t include support for some kind of achievements/trophies, that’s one more reason to purchase them on another platform.

2. More actual Wii U gameplay footage

The announcement that the Wii U game montage was all 360 and PS3 footage wasn’t surprising, but it was disappointing. Anyone who has played Bayonetta or Bioshock on PS3 or Final Fantasy XIII on 360 knows that “multi-platform” does not necessarily mean “equal experience on all devices.” Even if two systems share relative hardware parity – like the 360 and PS3 – individual developers are still capable of releasing vastly different ports. A lot of PS3 ports in particular were not developed by the original game company, but outsourced to someone else (like the aforementioned games, and others like Orange Box).

Just because the Wii U may have comparable hardware – something we don’t actually know for certain – does not mean it will deliver a comparable experience to existing consoles, in the same way that PS3 ports of 360 games have often seen significant drops in quality.

This means that the only actual footage we have of Wii U is a simple, relatively underwhelming tech demo. Tech demos have never been indicative of actual hardware capabilities. Remember the FF7 tech demo for PS3? How many PS3 games have actually looked that good? When the game system doesn’t have to process AI, or user-controlled movement, or positional audio, or pre-loading of true open world environments, you can make very pretty graphics. Add in any of those other things – all of which are required for an actual game, and all of which require horsepower – and you have less power left for graphics.

When announcing a new console, a company needs more than just a single tech demo on display.

1. Announce a price

It’s clear that Nintendo has a price point in mind for the Wii U. I don’t blame them for waiting to announce it – after all, a lot could change by its launch in 2012. The PS3 and 360 are both likely to receive price drops between now and then, and their respective motion-control add-ons (Move and Kinect) will probably see price drops too. Nintendo must be waiting for that to happen before announcing a Wii U price.

That said, leaving people to speculate for a year isn’t a great idea either. We do know that it will cost more than the Wii. No surprise there. But if the 360 and PS3 both receive price drops, that means that Nintendo’s new console – which has similar graphical capabilities, but can’t do things like play DVDs or Blu-ray – is going to cost more money. We also don’t know what games are going to cost. We don’t know what the controller will cost. We don’t know if online will be free.

The PS Vita price announcement was very well received. Nintendo could have stolen its thunder with a great price announcement of its own. Instead, we’re left to wonder what the price might be – and while everyone is hoping for a price like $299 USD, the launch price could easily be $349 or $399. Unlike the Wii, the Wii U doesn’t look like it’ll be a “bargain console.”

Conclusion

The Wii U could be a very interesting addition to the console landscape, but so far its launch has been rough. As a Nintendo fan, I really hope they do a better job with Wii U development than they have done with Wii U marketing.

Otherwise, I’ll probably save my excitement for the Xbox 720 and PS4.

How to Colorize an Image (in VB6)

“Colorization” in image processing can refer to one of several things. Most commonly, to colorize an image is to take an image without color (like a black and white photograph) and artificially apply color to it. One example of this is the old Three Stooges movies which were originally shot in black-and-white, but re-released several years ago in color. Colorization of an entire movie is expensive and time-consuming, and a lot of human intervention is required to make things look right.

Another form of “colorization” is taking any image – including full-color ones – and colorizing the image for dramatic or artistic effect. This is the type of colorization filter provided by software like Photoshop and GIMP, and it’s also the effect my source code provides.

Enslaved poster - original
Here's the original image (a poster for Enslaved: Odyssey to the West)
Enslaved poster - blue colorization
...and here's the same poster, colorized

Colorization works by retaining certain data about each pixel’s color (luminance and possibly saturation) while ignoring other data about color (hue). In the demonstration above, each pixel in the second picture has the exact same saturation and luminance as the top picture, but all hue values have been replaced with blue.

Different programs implement colorization differently. Most require you to specify hue and saturation values, with luminance being optional. I really like the effect created when you keep the saturation values from the original image. If you force saturation values to an arbitrary number – like Photoshop or GIMP – the colorized image looks either drab or blown-out.

Enslaved poster - orange, original saturation
Here's another colorization - this time to orange. Saturation values are unchanged.
Enslaved poster - orange, 50 percent saturation
Here's the same image, but with saturation forced to 50 percent (Photoshop style). See how the characters and background blur together? The nice contrast between the background buildings and the character on the right is no longer present.
Enslaved poster - orange, 100 percent saturation
...and here's the image again, but with saturation forced to 100 percent. This looks terrible, IMO.

I think the top image in this set offers the most interesting colorization… but since I wrote this code, I could be biased… :)

Full sample code is provided, and – like all code on this site – it’s fast enough to run in real-time.

Colorize program screenshot
Here's a screenshot of the GUI attached to the sample code

Comments and ideas for improvement are always welcome.

 

DISCLAIMER: These download files are regularly scanned to ensure they remain free from malicious content. Unfortunately, some virus scanners will flag these .zip files as suspicious simply because they contain source code and/or executable files. I have submitted my projects to a number of companies in an attempt to rectify these false-positives. Some have been cooperative. Others have not. If your virus scanner alerts you regarding these files, please allow the file to be submitted for further analysis (if your program allows for that). This should help ensure that any false-positive warnings gradually disappear for all users.

This site - and its many free downloads - are 100% funded by donations. Please consider a small contribution to fund server costs and to help me support my family. Even $1.00 helps. Thank you!

PCLinuxOS 2011 KDE: A Review and Retrospective

tl;dr – PCLinuxOS is a great distro for individuals who favor rolling updates, performance, and a dedicated community. If you’re a first-time Linux user or if you favor aesthetics over technological prowess, better choices are available.

First, a bit of background. (If you want to jump straight to the review, scroll down to where the pictures start.)

In April 2010, I found myself becoming increasingly disgruntled with Ubuntu (my OS of choice since late 2008). There was no one thing that ruined Ubuntu for me; rather, it was a growing list of inconveniences (10.04 had multiple hardware and software issues on my machine) coupled with regular use of Windows 7 at my place of employment. Windows 7 was as easy to use as Ubuntu for most tasks – worse in some ways (updating every piece of software individually), better in other ways (DVRing with Windows Media Center vs MythTV). I had originally switched to Ubuntu because at the time, it provided me a better experience than Windows XP. With the release of Windows 7, this no longer seemed as obvious.

For me, my OS is primarily a tool. I’m willing to fight it on minor issues, but for the most part I want it to stay out of the way so I can get actual work done. The more I used Windows 7, the less I was willing to fight Ubuntu.

I contemplated purchasing a copy of Windows 7, but it’s expensive, and I didn’t think it was fair to leave Linux based only on my experience with Ubuntu (and limited experience with openSUSE and Linux Mint).

So I went hunting for a new distro. My requirements were fairly reasonable:

  • KDE or Gnome was acceptable, though I leaned toward KDE (out of curiosity).
  • Reliability. Updates shouldn’t break software or hardware functionality.
  • Simple install. If 95+% of my needs aren’t met out-of-the-box, I’m not going to fight it. Maybe when I was younger… but now I can’t afford to have a PC out of commission for days at a time.
  • Pleasant community. I deal with enough assholes in real life – I don’t need ’em telling me to RTFM when I post well-researched questions in official forums.
  • Large software repositories. As you can tell from my site, I work in a lot of areas (programming, music, graphic design, writing), each of which requires unique software. Niche distros don’t always support the software I need, so they’re not a good fit.

After a bit of research, I decided to try PCLinuxOS (version 2010.2). Many individuals had good experiences with the distro, and I liked some of the edgier things it had to offer (BFS instead of CFS, for example). I also liked that there was no server remix – this was a desktop-only distro, which is exactly what I needed.

First Impressions

Right off the bat, PCLinuxOS impressed by clearly displaying the guest and root passwords on the liveCD background. NICE. More distros should do this.

PCLinuxOS 2010.11 KDE liveCD default desktop
The PCLinuxOS 2010.11 KDE liveCD default desktop

The installer (based off Mandriva’s) definitely tends toward “powerful” instead of “straightforward.” I had a bit of a heart attack when the drive formatting screen loaded with a blank window titled “resizing…” At first I thought this was blindly resizing some partition… turns out it doesn’t mean anything. Phew. (Someone should do away with that window.) I liked the option to manually specify which drive would receive GRUB… unlike Ubuntu 10.04, which indiscriminately overwrites the Windows bootloader. Besides the brief formatting scare, installation was largely uneventful, as any good installation should be.

That said, I wouldn’t recommend PCLinuxOS for first-time Linux installers. Being able to manually specify bootloaders, mountpoints, and other advanced options are great for individuals who know what they’re doing – but it’s possible to eff up your install if you’re inexperienced. Consider yourself warned.

PCLOS installer GRUB configuration
Screens like this are great for linux veterans, not so great for first-time users

On first boot, some nice touches appear – the themed GRUB is much better than a stock black-and-white one. You’re asked to provide a root password, followed by a “create new user screen.”

PCLinuxOS 2010 KDE default GRUB screen
The PCLinuxOS 2010 default GRUB screen shows off its custom theme
PCLinuxOS create new user screen (first boot)
On first boot, you are presented with this create user screen
PCLinuxOS 2010.11 loading screen
The stock PCLinuxOS KDE load screen

One of my favorite moments from the boot process is the start-up sound; for some reason, it reminds me of the “sleeping” mini-tune from a PS1 era RPG (like Final Fantasy 8 or 9). I laugh every time I hear it.

An interesting PCLOS decision is not including OpenOffice.org by default. Fortunately, a “Get OpenOffice” link appears on the default desktop. This brings up an OO.org installer of sorts, which saves room on the install CD without much inconvenience to the end user.

Not including OO.org allows PCLinuxOS to include a LOT of software by default. Some will like this, some will not. I think some trimming down could be done without sacrificing quality, but I imagine someone out there is grateful for the eclectic collection of default programs. There is no real rhyme or reason to the way software is included – for example, Thunderbird is included instead of KMail or Evolution, GIMP appears (but no Krita), Synaptic is the default package manager, Pidgin is the default IM client, TVTime (a simple tv client) is included, XChat appears instead of Konversation, and Clementine is the default audio player instead of amaroK (or even Rhythmbox). This random assortment of applications from different toolkits, desktop environments, and software teams will frustrate those looking for unification… but it probably isn’t new to people coming from a Windows background.

PCLinuxOS 2010 KDE default menu
The default menu is closer to Windows 95 than a modern KDE build... but it's easily changed

One clever feature PCLinuxOS includes is a repository speed test, which will ping a list of repositories and let you select the fastest as your default. The user interface is confusing and unnecessarily terse, but once you figure out what it’s doing, you should be able to shorten your update and installation processes. Clever!

Digging Deeper

By and large, hardware support in PCLinuxOS was good. On my particular hardware, three major problems stood out – I was unable to get my Ralink 802.11n PCI card working (note: several months later, the problem corrected itself…so go figure). I was unable to find and configure a Canon MX340 printer attached to the network via a Windows 7 computer, and I could not get my Hauppauge HVR-1600 TV card working with MythTV.

All three of these issues were not present in Kubuntu 10.04 or 10.10, so I’m not sure what happened in PCLinuxOS. I primarily print and use the TV card in Windows, so I could afford to live without those. The non-functional wi-fi card was a bigger problem, but I solved it by running an ethernet port to a nearby Windows machine and sharing its wireless signal. Inelegant, but functional.

Now for the good news – PCLinuxOS was significantly more responsive than my previous Ubuntu install. (This may be to BFS…idk.) Interestingly, the biggest difference I saw was on full-screen Flash video. Out of curiosity, I also installed PCLinuxOS to my aging Compaq laptop (1.6ghz Celeron processor), which has never been able to play Flash full-screen at more than 4-5 fps in Ubuntu. On PCLinuxOS, full-screen Flash worked at 13-15 fps… so not quite as good as Windows (25-30fps), but significantly better than Ubuntu. This example is purely anecdotal and YMMV, but I was shocked – and impressed! – at the difference.

PCLinuxOS includes Mandriva’s Control Center software, which provides additional control over a variety of system settings. Also included are some handy tools for mixed-OS environments like mine, with a Windows migration tool, a Windows font installer, and a wizard for connecting to shared printers and drives. Some of these worked well (the migration tool), others did not (the printer sharing wizard). Some of the options will be confusing for new users – for example, “Configure 3D Desktop Effects,” which is great for configuring Compiz but useless for KWin (the default window manager). Additionally, many of the tools require you to install various packages before you can utilize them.

This is a prime example of what frustrates desktop Linux users like myself: there are so many great features and great ideas, but the level of polish is often closer to “beta version” than “release candidate.” Some of the tools the Control Center provides are redundant with KDE System Settings, while others are very useful and unique. Also confusing is the branding… “Mandriva” appears instead of “PCLinuxOS” in certain screens, for example.

PCLinuxOS 2010 KDE Control Center
The PCLinuxOS Control Center contains tools ranging from useful to largely irrelevant

That said, it was nice to have so many system settings available in one place, even if not all of them worked as expected.

Some of my favorite things about PCLinuxOS

PCLinuxOS is a rolling release distro, which means you get updates in an incremental manner. These updates include the usual security and bug-fix updates, as well as major updates (KDE 4.5 -> 4.6 or OO.org 2.2 -> 2.3, for example). If you like having the latest software, PCLinuxOS is an excellent choice. I often received KDE-SC updates before the final release announcement got posted to kde.org. How many other distros can claim that?

PCLinuxOS also includes a number of pre-configured kernels for various purposes. If you don’t like BFS, a CFS kernel is available via Synaptic. A PAE kernel is also available, as well as one tuned for AMD processors.

PCLinuxOS sports a very large, very impressive software collection in its supported repositories. Many small and lesser-known apps are available, though packaging can sometimes be unpredictable. (For example, I was unable to locate Rosegarden in the 2010 repositories, though I hear it was added in 2011.) If you’re looking for something not found in the official repositories, folks in the official forum often know where to find a compatible download or an explanation of why the software isn’t included.

Speaking of the forums, the PCLinuxOS crowd was universally friendly during my time with them. Questions were answered swiftly and often correctly. It was also fairly common to get responses from actual developers. Also unique is the monthly PCLinuxOS magazine – a community-run collection of tips, tutorials, testimonials, FOSS humor, and more, with articles dating back to 2006. The formatting would make a graphic designer cry (hehe) but joking aside, it provides a nice collection of information on the distro and other free software. Not many open source projects give rise to community efforts of this size and consistency.

PCLinuxOS magazine homepage
The official PCLinuxOS magazine isn't much to look at... but it provides a lot of nice information

Finally, PCLinuxOS does a solid job of providing an out-of-the-box multimedia experience. With the exception of DVD playback, most proprietary multimedia tools (including Flash, mp3, and Java) are included in the default install.

Some of my concerns with PCLinuxOS

I believe it’s a fair characterization to say that PCLinuxOS is a distro “for Linux users by Linux users.” I certainly don’t mean this as an insult (or even as a compliment, necessarily): it is what it is. The team behind PCLinuxOS knows Linux well, and they use that knowledge to put together a very unique distro with good ideas from all over the map. Some have called PCLinuxOS a Mandriva derivative, but that isn’t accurate. Recent versions contain elements from every major distro.

Unfortunately, such an approach is both a strength and a weakness. PCLinuxOS is a technical accomplishment and a well-engineered piece of machinery, but it lacks any sort of unifying design aesthetic. A prime example of this is the confusing array of branding in the project:

PCLinuxOS branding
PCLinuxOS branding is all over the place

“Dobie the bull” is the (un?) official PCLinuxOS mascot, but it appears only sporadically across the distro. A circular PC logo is used some places, but an entirely different font is used in each custom application launch screen. The official website suffers from a similar lack of branding, with only a plain text (!!) logo and a cramped, austere layout. Blue seems to be the preferred color choice, but not any particular hue – instead, a recurring gradient from neon blue to navy blue is used. A total lack of secondary colors leaves the desktop with a bleak, uninspired feel.

Making matters worse is the included artwork – for example, notice the horrible photoshopping at the top center of this wallpaper (included with every install):

PCLinuxOS black default wallpaper
Default wallpapers like this (see the photoshopping?) do a real disservice to the distro

It’s difficult to discuss aesthetics objectively, but PCLinuxOS is undoubtedly a project in need of a dedicated designer. The technical aspects of the distro are impressive, but aesthetics are largely ignored. This problem is hardly unique to PCLinuxOS, but it gives off an “amateurish” vibe that’s unfair to its strong technical underpinnings.

Similarly, the name “PCLinuxOS” is… terrible? I guess the random hodgepodge of redundant words/abbreviations mimics the eclectic nature of the distro, but the name is clearly something thought up by an engineer, not a marketer. Again, a lot of people probably don’t care about such a thing – but believe me, it’s embarrassing to share a name like that with my designer and artist colleagues.

One final point, and then I’ll be done with my aesthetics rant. :) As much as its not fair to judge a book by its cover, every Linux distro must accept that people are going to pass judgment based on little things like a name, logo, and color schemes. As a credit to the impressive technical accomplishments PCLinuxOS has achieved, it owes it to itself to package that technical prowess in a handsome package. That’s all I’m saying.

Moving on.

I’ve already mentioned some small technical quirks with PCLinuxOS, but let me add a few more.

First, PCLinuxOS uses Synaptic as its sole package management method. (Raw use of apt-get is actively discouraged.) However, PCLinuxOS is an rpm-based distro, which leaves users stuck with an old, crufty version of Synaptic. It’s well-known in the forums that moving to a new package manager is inevitable; in fact, Texstar – the heart and soul of PCLinuxOS – had the following to say:

The reason for looking at an alternative is because we need to update our rpm package which is quite old now (4.4.6) and has become more buggy resulting in corrupted rpm databases. It won’t recompile against our current gcc/glibc and no bug patches are available. rpm is now at version (4.8.1). apt-get will work with rpm 4.8.1 but Synaptic is in pretty bad shape and crashes out often. Smart gui is not user friendly. packagekit is slower than molasses that last time I looked at it. rpmdrake to me is really not suitable for a distribution that receives daily package updates. The reason I am leaning towards Yumex is it is very close to Synaptic in terms of looks and speed. yum/Yumex works with rpm 4.8.1. The file list generated with apt or yum are compatible with each other. That makes it an easy drop in replacement.

As of this writing (February 2011) no official replacement has been named, but I hope the team settles on something soon. Package management is a core part of the Linux desktop experience, and a grossly outdated, unmaintained version of Synaptic and apt for rpms doesn’t cut it.

Similarly, it is shocking to me that PCLinuxOS doesn’t ship with an update manager. For a distro where regular updates are such a great selling point, this seems like a bizarre choice. It’s trivial to install update-notifier from the repositories, but this is also a poor solution. Update-notifier is unable to update much of anything without throwing the following warning:

PCLinuxOS update notifier error
Get used to this error. You'll see it a lot.

(Thanks to http://www.linuxbsdos.com/2010/07/20/pclinuxos-2010-review/2/ for the screenshot.)

This error doesn’t actually mean something is wrong – it just means an update wants to remove outdated packages as part of the update process. Since this happens frequently, expect to spend a lot of time manually checking for updates in the aforementioned crufty old version of Synaptic.

So Do I Still Use PCLinuxOS?

I used PCLinuxOS as my primary desktop OS from April 2010 to November 2010.  In November 2010, my PC died (motherboard failure) and I replaced it with a new Core i5 rig from ASUS.  This was apparently a bad time to use PCLinuxOS on an Intel chipset – my dual-monitor setup failed to work, the window manager disabled all effects (including useful workflow ones, like “Present Windows”), and having a fresh Windows 7 install made this less tolerable than usual.  I kept PCLinuxOS installed on my old Compaq laptop (where it continues to run like a champ), but have not returned to using it on my desktop.  I tried reinstalling it last week to test KDE 4.6 and see if it solved my window manager problems, but PCLinuxOS repositories have been down for most of 2011 (due to ibiblio.org server moves) and I was unable to install needed updates.  Interestingly, other KDE-based distros (including Kubuntu) have worked with my chipset since last November, leaving me to wonder what quirk affects PCLinuxOS.  Perhaps I’ll give it another shot once KDE 4.6 hits the repositories.

Closing Thoughts

I have been working on this review on-and-off since last April.  I don’t like posting a full distro review after using it for only a few weeks – to me, the real measure of a distro is how it performs after months of regular use, updates, and assorted troubleshooting.

An article from last week (Is PCLinuxOS on the Ropes? by Susan Linton) prompted me to finally finish up my thoughts and get this published.

I think PCLinuxOS KDE is a massive accomplishment in many respects.  In terms of technical prowess, it ranks alongside any of the large, commercially-backed distros – no small feat for a volunteer effort.  It amazes me that such a small team can not only produce a very good KDE-based distro, but also LXDE, XFCE, Gnome, “Gnome Zen Mini,” Enlightenment, and OpenBox spins.  Each one of these is a massive undertaking in its own right. PCLinuxOS also stands out as one of the only distros to ship BFS out of the box – a testament to its focus on desktop-oriented technology.

Unfortunately, a good desktop OS requires more than just powerful underlying technology – it requires careful attention to the user interface, aesthetics, and the overall flow and feel of the desktop.  I would love to see PCLinuxOS receive some attention from trained designers who can help eliminate its many inconsistencies.

Finally, I am in no place to offer advice to a group of volunteers working on something they’re passionate about, but I’ll do it anyway.  :)  I think it would serve PCLinuxOS well to focus on a smaller set of desktop environments.  I’d love to see them polish their KDE version into the truly definitive KDE experience it’s capable of being.  With so much of the technical work already in place, it seems a shame to not put in that extra 10% effort necessary to elevate it from “good” to “great.”

I will continue to use PCLinuxOS on older machines, and I strongly encourage any KDE fans out there to give the distro a try.  Many thanks to Texstar and his team for their impressive work.

You can download the latest version of PCLinuxOS at http://www.pclinuxos.com/?page_id=10.

Update 17 Feb 2011:

Several relevant comments have been made by PCLinuxOS users, which I thought I’d point out here:

  • The default software selection is apparently a community decision.  I’m not sure how formal this is… e.g. do they hold a survey, or does whoever complain the loudest get to make the decision…?  idk
  • Minimalist ISOs are available for folks who want to assemble their own software collection.  I was unaware of this when I wrote the original review.
  • PCLinuxOS users certainly come in all shapes and sizes.  :)  Some of the kinder ones have posted comments below, but I was forced to moderate several comments stating nothing more than “you are an idiot, I hope you die, blah blah blah.”  As a warning to future commenters – make a relevant point, or your comment will be deleted.
  • If you want, you can follow the conversation about this review in the official PCLinuxOS forums via this link: http://www.pclinuxos.com/forum/index.php/topic,87235.0.html.  (Note: I will no longer be posting there, so if you want me to see something, submit it in the comments here or use my contact form.)
  • Finally, as the title of this review clearly states, this is only about the KDE version of PCLinuxOS 2011.  I did not use every other spin available, so my comments may or may not relate to the other versions of PCLinuxOS.

Where does Microsoft make money? (Updated 2010)

THIS INFORMATION IS OUTDATED. Click here to see the updated 2012 report.

Since my previous article on this topic has received a lot of attention, I figured I should update the numbers for 2010.

Before I post these numbers (which are publicly available via Microsoft’s 10K filing), let me clearly state that I do not compile this information in order to advocate a pro- or anti-Microsoft agenda. My primary purpose in compiling this information is to help individuals discuss Microsoft with some level of objectivity.

So without further ado, here’s a simplified version of “where does Microsoft make its money (2010).”

Total Revenue and Operating Income (June 2009 – 2010)

Total Revenue: $62,484,000,000
Operating Income: $24,098,000,000

For those who don’t know, Operating Income = Operating Revenue – Operating Expenses. In other words, “Operating Income” is the profit made from normal business operations. (A more formal definition is available from Investopedia: “Operating income would not include items such as investments in other firms, taxes or interest expenses. In addition, nonrecurring items such as cash paid for a lawsuit settlement are often not included. Operating income is required to calculate operating margin, which describes a company’s operating efficiency.”)

Revenue and Operating Income by Division (June 2009 – 2010)

Microsoft’s products are divided into five divisions: Windows & Windows Live (formerly “Client”), Server and Tools, Online Services, Microsoft Business, and Entertainment and Devices. The types of products and services provided by each segment are summarized below:

Windows and Windows Live – Windows operating system: Windows 7, including Home Basic, Home Premium, Professional, Ultimate, Enterprise, and Starter Edition; Windows Vista, including Home Basic, Home Premium, Ultimate, Business, Enterprise and Starter Edition; and Windows XP Home. Windows Live suite of applications and web services.

Server and Tools – Windows Server operating system; Windows Azure; Microsoft SQL Server; SQL Azure; Visual Studio; Silverlight; System Center products; Biz Talk Server; Microsoft Consulting Services; Premier product support services; and other products and services.

Online Services Business – Bing; Microsoft adCenter; MSN; and Atlas online tools for advertisers and publishers.

Microsoft Business Division – Microsoft Office; Microsoft SharePoint; and Microsoft Dynamics ERP and CRM, as well as Microsoft Office Web Apps, which are the online companions to Microsoft Word, Excel, PowerPoint and OneNote.

Entertainment and Devices Division – Xbox 360 console and games; Xbox LIVE; Windows Phone; Windows Embedded device operating system; Zune; Mediaroom; and numerous consumer software and hardware products (such as Mac Office, mice, and keyboards); and Windows Automotive.

Microsoft’s previous fiscal year (June 2009-2010) was a particularly interesting one, with major headlines including the Windows 7 launch, Office 2010 launch, a redesigned XBox 360, Windows Phone 7, a new search and advertising agreement with Yahoo!, and the first full year of Bing-branded services. Some of these announcements came late in the fiscal year, which can indicate significant development cost without corresponding sales (keep that in mind).

The 2009-2010 Revenue and Operating Income for each division, in USD, is as follows:

Windows and Windows Live
Revenue: $18,491,000,000
Operating Income: $12,977,000,000

Server and Tools (Windows Server, Windows Azure, Visual Studio, Silverlight)
Revenue: $14,866,000,000
Operating Income: $5,491,000,000

Online Services (Bing, MSN, Hotmail)
Revenue: $2,199,000,000
Operating income: $-2,355,000,000

Business (Office, SharePoint, Dynamics ERP/CRM)
Revenue: $18,642,000,000
Operating income: $11,776,000,000

Entertainment and Devices (XBox 360/LIVE, Zune, Windows Phone, hardware)
Revenue: $8,058,000,000
Operating income: $679,000,000