Autokontrast Help

  1. What is Autokontrast?
  2. Installation
  3. Using Autokontrast

What is Autokontrast?

Autokontrast is a perl-skript that reads ditabis image files from the ditabis-scanner for transmission electron microscopes (TEM). It can be used to: For further information take a look at the "Using Autokontrast"-section

Installation

Because Autokontrast is a perl-Skript, using Perl-Tk for the graphical user interface, a version of Perl and the Perl-Tk module must be installed. The Program have been tested with Perl 5.8.1 and Perl-Tk 800.024 on a linux machine and with Perl 5.8 from www.active-state.com on WindowsXP but other versions of Perl newer than 5.6 should also work. For speed reasons the calculation of histograms and the conversion of the whole files are done by the c-programs ak_histogramm and ak_umwandeln. Therefore the sources of the programs must be compiled. The following sections describe the installation-steps for Windows and Linux. Mail to bquast@zoosyst-berlin.de if you have any trouble with installing the programs.

Windows

  1. If you don't have installed Perl, download and install a version of Perl, perhaps from www.activestate.com.
  2. Compile the programs ak_histogramm and ak_umwandeln with a (ANSI) C-compiler. I prefer the bloodshed c-compiler from BROKEN bloodshed but most other C-compilers should work.
  3. Copy the files in the autokontrast_en Folder to a folder you like. Put the compiled ak_histogramm.exe and ak_umwandeln.exe files in this folder too.
  4. Create a link on Your Desktop to the autokontrast_withpath.pl-script. Its important to take the _win-version. Perhaps You like to take one of the icon-images in the folder for the link-icon.

Linux

  1. If you don't have installed Perl, install a version of Perl and the Perl-Tk module, both should be contained in Your distribution. If not download a version from www.cpan.org.
  2. Compile the programs ak_histogramm and ak_umwandeln with a (ANSI) C-Compiler. With gcc just compile with:
    gcc -o ak_histogramm ak_histogramm.c
    gcc -o ak_umwandeln ak_umwandeln.c
    respectively.
  3. Copy compiled programs and the files in the autokontrast_en folder to a folder You like.
  4. If You have root permissions and want to be able to start the program with a link from anywhere in Your System You can do the following:
    Put the compiled ak_histogramm and ak_umwandeln files in a folder which is in Your PATH-variable eg. /usr/local/bin and try whether it runs by typing:
    ak_histogram
    The output should be as follows:
    Falsche Parameterzahl,
    usage:
    ak_histogramm +11 Parameter
    Copy the ListSelAuto2_en.pm and the WriteTifIFD.pm to the folder where Your Perl-modules are, eg. /usr/lib/perl5/5.8.1.
  5. Create a link on Your Desktop to the autokontrast_nopath.pl-script. Perhaps You like to take one of the icon-images in the program-folder for the link-icon.
  6. Else if You dont have root-permissions leave all programs and modules in one folder. In this case You have always to change into this folder when starting the program, eg.:
    cd autokontrast_folder
    ./autokontrast_withpath.pl
    
    You can rename this script with a more comfortable name.

Using Autokontrast

After starting Autokontrast it shows the main menu. The main menu is ordered by the steps, You will normally use in the conversion of images. First, the File-Button allows You to select the ipl or pgm files You want to convert. It is possible to choose more than one files, and You should do so. Its one of the features of the program that all selected files will be opened in one window.

After selecting the images, You have to press the Preview-Button to manipulate and preview the files. Depending on the number of files and the CPU of Your machine it may takes a while to load all the previews. I have tested the program with about 40 images, so it is possible to convert a lot of TEM images at one time. The progress-bar and the console-output tells You the progress of loading and calculating the image previews.

The preview-window shows to previews per image, on the right the image when the contrast is not changed, on the left the image after cutting out uninformative graylevels and scale the image-graylevels over the whole range of possible graylevels.

Explaination: The ditabis ipl-files save 16 bit-values for each pixel. Thus each pixel can have a value between 0 and 65535. 0 is interpreted as black, 65535 is interpreted as white. Normally, the scanned TEM-images have a range of about 5- to 10-Thousand graylevels. Thus, most of the possible 65535 graylevels are not used. If You look at such an image (eg. in the right preview) it appears very gray and with really flat contrast. This is because the lowest graylevels in the image will not reach the 0-value (black) and the highest graylevels will not reach the 65535-value (white).

The first thing that Autokontrast is doing, is cut off the lower and upper ranges of graylevels that are not used by the image and scale the range of graylevels of the image to the whole possible range of graylevels. The experience shows, that taking the lowest value as 0 and the highest as 65535, also results in a quite flat contrasted image. This is because there are often only a few pixels with the lowest or highest value. Thus, in most cases it is usefull to cut off a few percent of the lowest and highest graylevels to.

If You use ipl-files, the program also cuts off 0.5 percent of the lowest and highest graylevels. The two sliders under the right preview allows You to select the percentage of the cutted lower and higher graylevels. after releasing the mouse-Button from the changed slider, the program will automatically update the left preview. It is important to note that if You cut off to much percent of the levels information in the dark or bright areas will be lost. A good contrast is reached, if You have real black and white areas, but the different graylevels in dark and bright areas can be still seen.

The left preview shows a yellow frame around the image. This is the area where the grayvalues for the calculation are taken from. if You are using ipl-files it is a little bit smaller than the image in order to ommit the black edges to be invoved in the calculation. You can change the size of the frame by clicking the change framesize-Button. This is also helpfull if the EM-section is smaller than the image and there are bright areas with no information.

The last option in the preview-window is to edit the header of the file. This is sometimes necessary if the metadata are lost during the scanning-process, when the annotation of the datafile to the image files have failed. You can simply copy the missing data from the dgl-file to the end of the header in the edit-header-window. If the magnification was lost, You must write the magnification value behind the "MAGNIFICATION = " tag, with a parenthesis containing the unit µm. It should look like this:

MAGNIFICATION = 2100 (µm)
It is important to know, that due to the limitations of the ipl-header only 2048 characters are allowed in the header. If there are more characters than 2048, the odd characters will be lost. If You are saving pgm-files the whole ipl-header is stored as comment-lines in the pgm-header, else if You are storing tif-files the whole ipl-header is stored in the imagedescription tag.

After changing the things You like in the preview-window You can convert and store the images with the Convert-Button in the main-menu. It offers a dialog where You can choose the number of graylevels, the file type and the name of the converted files. Note, that due to safety for Your data Autokontrast wont overwrite the input files. Thus You have allways to choose new names for the converted files.

With the Graylevels-Radiobuttons You can choose, whether the images remain their original number of graylevels (16 bit or 8bit if it is a pgm file, formerly converted) or if they should be converted to 8-bit. The conversion to 8-bit takes place after the calculation of the new 16-bit values, this is important in order to remain as much information as possible.

The Filetype-Button allows You to choose saving the image in the original file-format, or as pgm or tif.

Warning: If You are choosing the Button for the original Filetype and work with ipl-files, You should also select the original-graylevel-Button because Autokontrast can read and write 8-bit ipl-files but neither photoshop with the ditabis-plugin nor the original ditabis-software seems to be able to read these files.

In order to make the converted images readable to most image programs I recommend to use the tif-fileformat. Unfortunately the Autokontrast-program it self is not yet able to read tif files, so if You want to use the program repeadetly I recommend to use the pgm-file format.

If You choose the Button Save only changed headers Autokontrast will produce new files with the changed headers only for this files where changes hav taken place. As for the conversion You have to choose new filenames for this files

At the bottom of the dialog is the area to choose the filenames. The dialog offers to take the Original Names of the files or to make numbered files with one basis-name. You can choose to append characters before or behind the original name or the numbers. As mentioned above, You must add something to the original filenames because Autokontrast will not overwrite them.

The left list shows only the directories within the actual folder. Unfortunatly it is not yet possible to create a new folder within this dialog.

To start the conversion and saving of the new files You habe to press the Ok-Button in the lower middle of the dialog. Autokontrast now starts to convert the images.

This may take a while, and the progress again can be controlled by progress bar and the output of the console.

I hope You have some advantages by using my Autokontrast program!

If there are any questions about it, mail bquast@zoosyst-berlin.de