/  Technology   /  Image Processing using SimpleITK and Python
Image Processing using SimpleITK and Python

Image Processing using SimpleITK and Python

In this article, we will walk in through the image processing using SimpleITK and Python.

Image processing :

Image processing is the method through which we can do a certain operation on image to enhance and to extract some useful knowledge from the image. Here the input is in the form of image and output is in the form of an image or some feature or characteristic of the image. It is nowadays one of the rapidly growing technology. It gives the platform for the research area. They are two types of image processing analog and digital. Analog image processing can be used for hard copies like print out. Digital image processing techniques help in the manipulation of the digital image by using a computer.

Simple ITK :

Simple ITK is an open-source, cross-platform system that provides developers with an extensive suite of software tools for image analysis through which we can get the characteristic of the image.

It is intended to facilitate its use in rapid prototyping, education, interpreted languages. It is one of the image processing libraries which is available in multiple programming languages including C++, Python, R, Java, c#, Lua, Ruby, and Tcl. As it is available for multiple programming languages but it is coded in C++ programming language. It contains a feature that helps in image segmentation, filtering operating, and registration.

One of the advantages of SimpleITK is that you need no to build it, you can simply download the binaries and get started with. Until now Python binaries are available on Microsoft Windows, Linux and Mac Os are some operating systems.

There is two Python binary packages choice which is available to us: Python Wheels, and Anaconda packages for the Anaconda Python distribution.

Installing the Simple ITK :

Form the below command line we can install the Simple ITK

pip install SimpleITK

 conada base distributation :

from the command line promt  we and execute

conda install -c simpleitk simpleitk

There are various file formats support by SimpleITK’s image readers and writers. A specific ImageIO  class handles the particular format of file.A list of ImageIO is listed below:


Now we are going to see how to read and write the image using  the Simple ITK and Python :

First, we need to import the Simple ITK library

import SimpleITK as sitk

so to read and write whole code is given below:

import SimpleITK as sitk


reader = sitk.ImageFileReader()
image = reader.Execute();


writer = sitk.ImageFileWriter()

Gaussian smoothing :

We can blur the image by fallowing code:

import SimpleITK as sitk
import sys

if len(sys.argv) < 4:    
    print("Usage: SimpleGaussian <input> <sigma> <output>") 

reader = sitk.ImageFileReader()
image = reader.Execute()

pixelID = image.GetPixelID() 

gaussian = sitk.SmoothingRecursiveGaussianImageFilter()
image = gaussian.Execute(image) 

caster = sitk.CastImageFilter()
image = caster.Execute(image) 

writer = sitk.ImageFileWriter()




Leave a comment