View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Medical Image Processing Toolbox

4.1 | 7 ratings Rate this file 124 Downloads (last 30 days) File Size: 166 KB File ID: #41594 Version: 1.3
image thumbnail

Medical Image Processing Toolbox


Alberto Gomez (view profile)


01 May 2013 (Updated )

Classes and functions for N-dimensional medical image processing, inspired by ITK

| Watch this File

File Information

This package contains a collection of classes and functions, which allow to comfortably work with medical images and meshes. It provides a intuitive and transparent way of dealing with spacing, origin, image orientation, etc. The package includes functions for input-output with common image formats (mhd, gipl) and mesh formats (vtk, stl), and basic (although not necessarily simple) image processing operations such as image resample, image reslice and image transform.
Please do not hesitate to propose new features, examples or any constructive comments!


Read Medical Data 3 D inspired this file.

This file inspired Simple Viewer 3 D.

Required Products Control System Toolbox
Image Processing Toolbox
Signal Processing Toolbox
Statistics and Machine Learning Toolbox
MATLAB release MATLAB 8.0 (R2012b)
MATLAB Search Path
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (23)
10 Jan 2017 R Lin

R Lin (view profile)

I tried to load mhd files, it was going well but I got the following error for some mhd files:
Undefined function or variable 'zlibdecode'.

Error in read_mhd>read_raw (line 75)
rawData =zlibdecode(uint8(rawData));

Error in read_mhd (line 20)
data = read_raw([ path filesep info.DataFile ], info.Dimensions,info.DataType,'native',0,ndims, info);

Did I do something wrong?

Comment only

I try to write mhd/mha image using the write_mhd() function, but it fails.
My image is a 3D matrix of double values.
I get this type of error: Attempt to reference field on non-structure array.
Because my image is not a struct, then it fails to reach the image.size and image.orientation fields.

Is there any restriction on the input data? And which format should I use?

Thank you

15 Jun 2016 abdulrahman alturh

in this awesome tool box you're depending on Frustum as an already built class.
But unfortunately I couldn't find it.
any one has can help me find the frustum class?
Best Regards

22 Oct 2015 hosse


I have data format as .img and .hrd. and i want to use this tool (

But it support .bin and .header format.

Would you let me know how to convert .img and .hrd or .raw and .mhd to .bin and .header format so that i can use the above mentioned tool for my data for 3d to 3D rigid image registration. I have knee MRI data, not brain MRI

Comment only
08 Aug 2015 revathi t

Will this toolbox work with my matlab2014a?

Comment only
07 Aug 2015 ANGAJA K

Can we use this for mha files??

18 Jul 2015 mehdi

mehdi (view profile)

how can i trannsform mhd image by 4*4 matrix??
my code:
matrix=[ -0.9357 0.2129 0.2815 -424.3918
0.2370 -0.2120 0.9481 -329.0604
0.2615 0.9538 0.1479 363.3647
0 0 0 1.0000];

outputImage = transformImage(matrix,volinputImg,volreferenceImage,'debug' );

% % % Error is appeared in ImageType(referenceImage) function; inputImg=Vol_moving;
% % % Error is appeared in sub function ImageType(referenceImage);referenceImage=Vol_fixed;

Comment only
01 Apr 2015 Alberto Gomez

You can currently import meshes in VTK ASCII format. For vtk images, you need to convert them to mhd first. You can use Paraview for that.

Comment only
31 Mar 2015 AMol

AMol (view profile)

Hi Guys, I have to import data from VTK file to Matlab and show them. Do you have some tutorial for it ? Thx

Comment only
10 Mar 2015 Anna Varfolomeeva


06 Mar 2015 Alberto Gomez

Alberto Gomez (view profile)

The toolbox currently supports gipl and mhd only.

I have added some mising files like vtkMathPerpendiculars.m

Thanks for rating

Comment only
05 Mar 2015 Anna Varfolomeeva

And is it possible to open analyze(.hdr and .img)? NiFTi (.nii) and .nrrd files with your code?

Comment only
05 Mar 2015 Anna Varfolomeeva

Hi! Thanks for sharing code!
When I try to run test_image.m I get a message "Undefined function 'vtkMathPerpendiculars'". Where I can get it?

Comment only
27 Jan 2015 Alberto Gomez

you can display the image by doing imshow(


Comment only
22 Jan 2015 Shruti naik

hi alberto, thanks! :) do we directly need to run read_mhd and how exactly display the .mha files using imshow()? do revert :) waiting!! regards

10 Dec 2014 RÜZGAR YANIK

first of all thanks sharing code

i want to ask a question

i have dwi brain image .gipl format.i want to tick on .gipl image with roi and then want to make logic one in roi area and logic zero outside of roi area

if someone knows how it is done, kindly help me

waiting feedback


06 Oct 2014 Alberto Gomez

Alberto Gomez (view profile)

Hi Noha,
You do not need to change paths for this package in particular. You will need to add the files to your matlab path (as you would do for any other package) or put the file in your working directory. Usually it is enough to right click in the folder where the files are from the matlab file browser and click on "add to path"-> "selected folders and subfolders".

Comment only
04 Oct 2014 Noha Asas

How could I deploy that package, so as to use the functions immediately without the need to change paths??

Comment only
11 Apr 2014 Alberto Gomez

Unfortunately it currently reads/writes ASCII vtk mesh files only. Mhd binary files are supported though.

Comment only
10 Apr 2014 Arso

Arso (view profile)

Can it read binary VTK?

Comment only
20 Nov 2013 Alberto Gomez

Yes Akshay, among several other functionalities that is exactly what it does

Comment only
20 Nov 2013 Akshay Gore

Akshay Gore (view profile)

Is this function used to read raw/mhd file?

Comment only
03 Jul 2013 Bo Sun

Bo Sun (view profile)

Could this toolbox read and write '.mha' files? Since i only found the function used to read and write '.mhd' files.Thanks

06 Mar 2015 1.2

Some bug fixing
Added some missing functions

27 Jun 2016 1.3

* Some bug fixing and extended features for neighbourhood operations
* Extended image I/O
* Improved visualization

Contact us