Imaging concepts: Encrypting images

Share

DES in Electronic Code Book (ECB) mode is a particularly poor choice of cryptography for image files. This is because ECB mode implements a look up table between the unencrypted value and the encrypted value. This results in a known input value turning into the same output value over and over. This can have some interesting blurring effects, but wont obscure the image contents. An example will help this make more sense — the first figure is the logo for the company I am currently working for. I took this image, and ran it through some DES ECB code and produced the second figure.

You can see that whilst the image has certainly changed, the contents of the image has not really been obscured.

We should note that ECB mode is not commonly used anyway. If you use something like PGP or blowfish, then you should be much happier…

Share

Imaging concepts: Anti Aliasing

Share

Imagine that you are drawing a triangle across an image (or on the screen for that matter). The triangle is sometimes going to cross pixels in a way which makes them not totally turned on. Have a look at the figure below to see what I mean…

If we only have a black and white image, then we’ll end up with an image like the one in the figure below. I am sure you’ll agree that this isn’t a very good representation of the side of the triangle.

Anti-aliasing is when we try to correct for this problem by inserting some gray pixels. In the figure below, we have given some of the pixels a gray value which is based on how much of the pixel is “filled” with the triangle.

The triangle might be a little clearer without the grid lines.

If you compare that with the triangle we started with above, then you can see the obvious difference.

So, in summary, anti-aliasing is the process of turning on some extra gray scale pixels to improve the look of shapes we are drawing… Now, whether you actually like anti aliasing or not is another matter. A lot of people, especially those with LCD screens, complain that anti aliased text is “fuzzy” and hard to read. That’s the reason you can turn anti aliasing off in more recent versions of Microsoft Windows.

[tags: tutorial antialias]

Share

Assumed knowledge

Share

There are some things which I assume you know, and which are outside the scope of this tutorial.

C

This tutorial discusses code. Almost all of the code discussed is written in C. It is therefore safe to assume that if you don’t have a good working knowledge of C, then you’re likely to get a lot less out of this tutorial as those who do know some C. On the other hand, don’t worry about the more esoteric syntax, I’ll explain this as we need it.

It should also be noted that the code samples in this tutorial are not optimal. They have been written to be as readable as possible, and not necessarily the most efficient possible. Please bear this in mind before blindly copying them.

How to compile and link on your chosen operating system

It is outside the scope of this document to teach you how to compile and link source code into an executable form on your chosen architecture and operating system. You will need to understand this before you will be able to use any of the code in this document.

For those of you using gcc on a Unix (or Unix-like) operating system, then the following points might be all you need to know. If you need more information, then a http://www.google.com search will serve you well.

  • Libraries are added to the link command using the -l command line option. For instance, to compile and link the source file foo, with the tiff library, you would use a command line along the lines of gcc foo.c -o foo -ltiff -lm.
  • You need to include -lm almost always. When you compile a c program using gcc without specifying any libraries, you get a -lm for free. As soon as you start specifying any libraries (for instance in this case -ltiff), then you also need to explicitly specify the math library as well.
  • You will almost certainly also need to add the library and include paths for the installed version of the relevant library to the compile command line as well. Directories are added to the library search path using the -L command line option. Include directories are added with the -I option.
  • The make files included with the samples in this tutorial a probably a bad place to look for introductory compile examples, as they use automake and autoconf to try to detect where the various required libraries are installed…

[tags: tutorial]

Share

An experiment in online authoring — my image programming tutorial

Share

I don’t view myself as an author — I’m a programmer. I have however written a few articles and conference papers in my time. Here are the ones relevant to this topic area:

I’ve also written a bunch of imaging software, including lots that uses libtiff, some libpng tools, and my own PDF generation library. They’re all open source, and available at at this site.

Back in 2002 I put a fair bit of effort into writing up an imaging tutorial for the annual AUUG conference. The tutorial was subsequently cancelled as not enough people enrolled, but by then I had written the documentation. I talked about getting a publisher for the work, even as recently as a couple of months ago. I’m not convinced that I have the time to polish and update the manuscript to the point that it’s ready for publication though.

Here’s what I said at the time that I first wrote the manuscript:

    “This document is the manual associated with my tutorial on imaging programming presented at the Australian Unix User’s Group 2002 Winter Conference in Melbourne Australia. It is intended to serve as the basis for discussions during this day long tutorial, as well as being a reference for the attendees once they return to their every day lives.”

So here’s what I propose to do. I’ll write a book in this topic on my blog, and in return I would like people who read it and have comments to let me know. Together perhaps we can come up with something which is ready for real publication. If you’re a publisher, and would like to play this game too, then feel free to let me know…

I can be contacted, as ever, at mikal@stillhq.com.

Boring stuff

All of this work is Copyright (c) Michael Still, 2002, 2003, 2004, and 2005. It remains copyright me, and republication of this content elsewhere without my permission is expressly not allowed. Feel free to quote and deep link and stuff, and please please comment, but don’t steal my content. Portions of this content were first published by the kind folk at IBM DeveloperWorks and they deserve heaps of credit for giving me a go.

[tags: tutorial]

Share