in SimpleITK example


I installed my simpleitk for Java and gladly used the gaussian Example of it in the manual to be exact it is called problem is that I don’t know what kind of image format to use as input and output. I tried png format for input and it complained about vector of 8 bit image is not acceptable. then I tried dicom format and for the output I used png still not working for the output. does anybody know what formats are acceptable?



Hello @sag,

Welcome to SimpleITK!

Are you referring to this example?

In SimpleITK when you do not explicitly set the image IO format it is deduced by trying all options when reading, and from the file name extension when writing.

I ran the program with a color png and it worked for me, so not sure if this is an issue with your input or you are referring to a different example.

If you are comfortable translating between Python and Java, we have extensive usage examples and workflows in Python using Jupyter notebooks. This notebook introduces the image class and how to do IO.

If this does not solve your issue, please provide additional details and we’ll do our best to help.


Hi Ziv,
Thanks for response!
I actually used a png file format as input and png file format as output to blur the image. I used a mri brain image from vtk build I had earlier. I am not using python even though I have all the anaconda, Jupiter notebook, spider, and all that command line python stuff. I could use python, but right now I am on a fast tract to use visual studio 2017, Java, many be C# later.
point: I could not get it to work with java! I have binary version of SimpleITK java 1.2.0 and I link the external jar files for the simpleitk and it compiles. at runtime though I face problem that call to SimpleIT.discreteGaussian() cannot handle [8 bit vector unsigned char format image]!? (according to you .ipython has no such issue and it works) so I found this article to just take one channel of the vector with call to SimpleITK.vectorIndexSelecionCast(, index[0…2]); and this worked just fine so I could have png formats but it is not RGB rather it is just one color. b.t.w I did use gray scale image not colored image? may be that is the problem? any ways. then I called SimpleITK.discreteGaussian on the result of previous call and it blurred the image. this is not perfect though but I have lots of wonders about this …

  1. funny think is that I am also a full stack Java developer, C++, C#, and mobile developer but I could not fix this simple issue yet.

  2. I cannot even get one simple variable type in java version of SimpleITK to compile. no variable type is there, because the compiler complains some source file is not there, even though I have linked the extracted source files, some external *.jar file but still it complains and it is frustrating.

can you attach the colored image you have tested GaussianExample and send it to me I really appreciate it!



hi Ziv,
here is the example and installation of binary java …



Hi @sag,

OK, so we are making progress. I see you are using the discrete Gaussian and that this is not the example I was referring to. In that example we use the SmoothingRecursiveGaussianImageFilter.

The problem you are encountering is that SimpleITK does not include the discrete Gaussian filter for images with that pixel type (vector of 8-bit unsigned integer). This has nothing to do with the file format (png). Please either use the recursive Gaussian or as you did, you can do the filtering channel by channel.

This is the image I used:



Sorry to hear about your frustrations.

Unfortunately the Wiki documentation is old, and that page is missing a “NOTICE” that the docs have moved to

You can find the current example here:

This example adds a casting which may help your issue.

Hi @Ziv,
Thank you for quick response! your mentioned [filtering channel by channel], do you suggest that I could have three channel of filtered images each for each channel and then add them up? if so how to merge them into one image? may dum question…


Hi @Bradley,

Thank you for your response!
I have a question about installing java binaries on my windows 10 laptop, I diid successfully installed SimpleITK java and setup my build path on eclipse as discussed, yet I have no access to variable types of the SimpleITK, the compiler in eclipse complain that I don’t have any access to SimpleITK source code; I did linked all my *.jar files including source files in my project build path ?!
any idea what is wrong? or do you know anybody who could help me to resolve this issue of java source code fo SimpleITK?

  1. I am working on SimpleITK and ITK to catch up with 3D segmentation and also would like to color the organs in the body or sections of Brain any examples that I could segment and paint different organs in different colors and visualize it with vtk in different colors?


Hi @sag,

The inverse of VectorIndexSelectionCast is ComposeImageFilter.

This is called image segmentation. In its general form, it is an unsolved problem in science. With some restrictions (e.g. segment kidneys in 3D ultrasound acquired from lateral-back viewpoint) it becomes tractable. But even then it is still usually a hard problem.

1 Like

Hi dzenanz,

Thanks for response!
When I was in school medical image processing, I got a set of data projections(sinograms) which is reconstructed slice by slice 64 slices all together and I got a 3D reconstruction of it. now if I could segment each slice of this 64 slices and then reconstruct it, I think it would work. ITK + VTK. offcourse I did that with Matlab. Is there any example such as CT scan data set which is scanning for organs in stomach area and then I would segment each slice for say intestinal and then reconstruct the segmented area, and then for next organ until I am done and reconstruct the whole thing if I segment with water shedding then it is colorful, otherwise I could paint it with red blue and green for different organs. what do you think?

  1. do you by any chance have any ct or mri dataset in slices that I could use?


TCIA has thousands of subjects, and a variety of image modalities.

Hi dzenanz,
I have question about visualization of DicomSeriesReadImageWrite2.cxx. I did build it and I have downloaded a DICOM scan series from TCIA site. it is in a folder name is F:/BREAST-DIAGNOSIS/Breast-Dx-01-0002/11-29-2008-PET-SKULL-THIGH PLUS D-07347/3-STD-78908! inside this folder I have DICOM scan images with names like [000000.dcm, …000206.dcm].

  1. would we call the command line to run this program as follows:
    DicomSeriesReadImageWrite2.exe F:/BREAST-DIAGNOSIS/Breast-Dx-01-0002/11-29-2008-PET-SKULL-THIGH PLUS D-07347 3-STD-78908.nrrd 3-STD-78908

  2. I assume the last folder name is the DICOM series name!, I also assume the folder directory for the DICOM Series is F:…
    Error message:
    I get this exception thrown: now reading series 3-STD-78908
    warning: in itk::DicomSeriesFileNames.cxx … : no series can be found, make sure your restrictions are not too strong … at least one filename is required.

  3. IF something wrong with command line arguments? how to rearrange the command line arguments to fix the problem
    and there is a nameGenerator->AddSeriesRestriction(…) and I removed it but no change

  4. .nrrd seems to be the output name if not what output format should be chosen?

  5. what program to use to see .nrrd 3D files?

any help appreciated


The third command line argument, series name, is optional. The program will print the series in the folder, and those should be supplied as the series name if you want to. Frequently, there is just one series in a folder, so the default behavior to read the first series is good enough.

I suggest simply to omit the last command line parameter. Also, you should put a path with spaces in it in quotation marks:

DicomSeriesReadImageWrite2.exe "F:/BREAST-DIAGNOSIS/Breast-Dx-01-0002/11-29-2008-PET-SKULL-THIGH PLUS D-07347/3-STD-78908" "F:/BREAST-DIAGNOSIS/3-STD-78908.nrrd"

(assuming that exclamation mark is not part of the folder name).

To see .nrrd files, you either 3D Slicer or ITK-SNAP.

Hi @dzenanz,
Thank you it worked. I view the nrrd file in preview and it looks fine. I have a question if you don’t mind:

  1. I have two DICOM SERIES datasets and one is PET and one is CT and I would like to register them. I go slice by slice from each DICOM SERIES image and each registered pair is saved as DICOM and then I visualize it with preview, would that be correct or any flaws in that? any suggestions appreciated!