Monday, November 12, 2007

Did you know that ... Part 1

1. Images are identified using Magic number. If you open a gif file in a text editor, you will notice the magic number representing gif, GIF89a. These numbers are not limited to images alone, even pdf and postscript files can be identified. In fact it can be used to identify most of the file formats

2. ImageMagick is used by for their image processing

3. The much used picture of Lena (below) for image processing is the Playboy centerfold picture of the Swedish model, Lenna Soderberg

4. Mencoder is a command line tool for editing movies much like Imagemagick is a command line tool for editing images

5. Mplayer is the close cousin of Mencoder and can be used for viewing movies

6. ffmpeg is another tool for editing movies and is believed to be used in to convert the uploaded videos in to flash video (FLV) format.

7. Google has implemented a face recognition in its search. The images of face can be seperated from google image search result by typing "&imgtype=face" at the end of the url.

Sunday, November 11, 2007

Comparing different DICOM viewers

Digital Imaging and Communication in Medicine (DICOM) is a standard format for encoding and transmitting medical CT and MRI data. This format stores the image information along with other data like patient details, acquisition parameters etc. Since DICOM standards have become popular, many image processing readers and viewers have been created to read, process and write images. There are so many such software and its details can be seen here.

Since the details of the various software can be obtained using the previous website, in this blog we will classify some of these softwares based on the user requirement and discuss accordingly.

The users might need
1. A simple viewer with limited manipulation like ezDICOM
2. A viewer with ability to manipulate images and perform rendering like Osirix
3. A viewer with image manipulation capability and also extensible with plugins like ImageJ
4. A command line reader and viewer that allows batch processing like ImageMagick

There are more softwares that can be classified under the four categories but we will limit to these software for this blog. This does not limit the number of software available for viewing and manipulating dicom image, rather helps users choose the software right for them.

It is a viewer that provides sufficient functionality that allows users to view and save dicom files without installing any software in their system. It is available only for Windows OS. It can read dicom files and save them in other file formats. It can also convert image files to Analyze format.

It is a viewer with functionality that you might generally find in expensive workstation. It works great and it is free! But unfortunately, it is available only in MacOSX.
Like other dicom viewer, it can read and store files in different file formats and as movies. It can performs Multi-planar Reconstruction (MPR), 3D surface rendering, 3D volume rendering, endoscopy. It can also view 4D dicom data. The surface rendered data can also be stored as VRML, STL files etc. In short, I would highly recommend it if you have a Mac system.

ImageJ was funded by National Institute of Health (NIH) and is available as open source. It was written in Java and users can add their own Java class or plugins. It is available in all major operating system like Windows, Linux, UNIX, Mac etc. It can read all dicom formats and can store the data in various common file formats and also as movies. The plugins allow various image processing operation. Since the plugins can be easily added, the complexity of the image processing operation is just limited by the users knowledge of Java.

If the various operations in image processing can be classified in to input, processing and output, ImageMagick provides functionalities that perform all these three operations. ImageMagick can be used in command line in almost all the common operating systems like Windows, Linux, UNIX, Mac etc by combining the read, write and image processing operations. Since ImageMagick is a command line tool, it can be used in any scripting language like perl, PHP, shell script etc. For users who are more adventurous, ImageMagick also provides APIs that allow programming low level image processing operation.

If you want to be even more adventurous and would like to program in C and C++, check out dicom toolkit.

Monday, November 5, 2007

Introduction to MevisLab

Are you one of the many who are not comfortable with C++ programming but need some tool to perform different image processing, visualization and segmentation? Then you have an answer in the form of a visual programming software called MevisLab.

Visualization and Segmentation process have a pipeline architecture as output from one step is fed as input to the next stage. The first step always involves either reading or creating a data which feeds to a processing stage like filtering, segmentation etc. The output of this stage is then fed to the output stage where the processed data is either visualized or output as a file.

Visualization Toolkit (vtk) and Insight Toolkit (itk) are libraries that perform complex image processing operation using C++. They are freeware and hence users can avoid reinventing the wheel when performing their image processing operation and instead focus on their research. They are also being actively maintained by Kitware Inc and researchers from across the globe, actively contribute new algorithms. The code can be ported to most of the common OS and for super-computing users, parallel versions are also under development.

In the traditional programming using vtk and itk, the user has to be knowledgeable in C++ and specifically template based programming. For the unfortunate few who are not experts in C++ programming and for people who need a quicker turnaround in their testing of image processing algorithm, visual programming is the best solution.

Visual programming consists of creating a flow chart of operation that needs to be performed. Since vtk and itk are pipeline based, they naturally lend themselves to flow chart based visual programming.

MevisLab is being developed by MeVis Research GmbH, Bremen, Germany. Since its interface was developed using Qt (TrollTech Inc), it works on Windows, Linux and MacOSX. The software is free for non-commercial use and supports various file formats like DICOM, jpeg, tiff, 3d Studio Max, STL, VRML etc. Various operations can then be performed using OpenInventor, vtk, itk etc.

Here is a simple example of a pipeline in MevisLab.

MevisLab provides various methods for reading the various file formats found in images and 3D models. The example above demonstrates one of the method, ImgLoad, that can read most of the common image formats like jpeg, bmp, png etc.
Once the image(s) are read, they can be manipulated. In this example, the processing operation is the addition of "Salt and Pepper noise." This operation could be simple as in this example or could be complex operation involving multiple stages.
Write or View
MevisLab also provides various methods for writing and viewing the images and 3D models. In this example, the view2d is used for displaying the images.

A network in MevisLab is a combination of such commands as in the example above. Users can create such networks and reuse it for different applications. The software also has many example networks that can clarify the usage of the various methods.

Introduction to Mimics

Why Mimics?
Placement of new prosthesis on a patient requires measuring the exact dimension of a patients body. Such measurement involves multiple dimensions and hence a precise method is required. Artistic rendering using manual measurements involves considerable time, effort and expense and are also prone to error. Hence conversion of precisely obtained Computed Tomography (CT) and Magnetic Resonance Imaging (MRI) data to 3D models provides a better alternative to the artistic rendering. These 3D models can then be analyzed using Finite Element Methods (FEM) or can be converted in to physical 3D model by using Rapid Prototyping (RP) for 3D printing or prosthesis creation.

There are various softwares available to perform each of these operations independently but Mimics (Materialise NV, Belgium) provides a one step interface for performing all these operations. It provides a seamless workflow platform and hence conversion from CT and MR data in to 3D models can be performed in less time. It also converts these 3D models in to FEM models and export them to different FEM softwares.

Steps in creation of 3D models
The various steps involved in the conversion of CT and MRI data in to 3D model are
1. Segment the data to obtain only the object of interest
2. Convert the segmented data in to 3D model and
3. Export the model in to various formats as required for FEM or RP.

Mimics modules
Mimics has various modules like Mimics base, STL+, FEM, Simulation, ... In this article, we will evaluate the first three modules.

Mimics base
The Mimics base module allows user to read CT and MRI data in DICOM format. The first step in the 3D model creation process is segmentation. Mimics provides standard segmentation threshold range for various parts like bone, soft tissue, ... and hence the user need not select range for most common parts. Mimics refers to each of these segmented images as “Mask”. In addition, Mimics also provides user the ability to change the threshold range. To obtain only pixels belonging to a particular part, use region growing based thresholding . A 3D model can then be generated for this particular mask.

Editing mask
To edit the mask, Mimics provides mask editors that work in both 2D slices or 3D volumes. The masking involves adding pixels that have not been included in the segmentation process or removing excess pixels which the user judges as not belonging to the part. The masking operation works by painting over pixels that need to be selected and for precise selection, a threshold range can also be set. Similarly, the 3D masking operation performs a 3D erase along a cylindrical axis.

The edited mask can then be converted in to STL format, which can then be read using other CAD packages or can be used for 3D printing using RP or can be FEM meshed using FEM module

The FEM module converts the 3D mask in to a mesh. The mesh can then be refined both globally and locally by controlling individual mesh elements. The edited mesh can then be stored in different FEM file formats that includes most commonly used FEM formats for packages like Ansys, Abaqus, Patran etc.

Please leave your comments at the bottom and if many users request, I can work on a more detailed tutorial on Mimics and post it in the future.