Upload
others
View
0
Download
0
Embed Size (px)
Citation preview
Medical Image Analysis and Medical Image Analysis and Programming ToolsProgramming Tools
Magnus Gedda Magnus Gedda [email protected]@cb.uu.se2005042820050428
1
Lecture 10 – part 2,Lecture 10 – part 2,
No suggested problem...No suggested problem...
Programming for Image Programming for Image Analysis/ProcessingAnalysis/Processing
2
• Tools and guidelines for writing your Tools and guidelines for writing your own image analysis/processing own image analysis/processing applicationsapplications– What is needed when you start a projectWhat is needed when you start a project– Tools to help you along the wayTools to help you along the way
What you need to startWhat you need to start
• Choice of environment depends onChoice of environment depends on– Image formatImage format– Algorithm(s)Algorithm(s)– Data structuresData structures– Graphical user interface (GUI)Graphical user interface (GUI)– Performance requirementsPerformance requirements
3
Image formatImage format
• FileFile– TIFF, JPG, GIF, PNG, BMP, ...TIFF, JPG, GIF, PNG, BMP, ...– Raw filesRaw files– ““Exotic” formatExotic” format
• DimensionsDimensions– 2D2D– 3D3D– More (colour, time, features, ...)More (colour, time, features, ...)
4
Algorithms and data structuresAlgorithms and data structures
• Typical data structuresTypical data structures– Arrays (images)Arrays (images)– Stacks and queues (e.g., region growing)Stacks and queues (e.g., region growing)– Graphs, trees, lists, ...Graphs, trees, lists, ...
• Typical algorithmsTypical algorithms– ConvolutionConvolution– Numerical (e.g., integration)Numerical (e.g., integration)– Transforms (e.g., FFT)Transforms (e.g., FFT)– Geometry (e.g., convex hull)Geometry (e.g., convex hull) 5
GUIGUI
• Does the application require user Does the application require user interaction?interaction?
6
Some available toolsSome available tools
• Survival kit for “nonserious” image Survival kit for “nonserious” image processingprocessing
• MatlabMatlab• ITKITK• ImageJImageJ
• There are a There are a lotlot of other possibilites out of other possibilites out there (often customized for application)there (often customized for application)
7
Survival kitSurvival kit
• ViewView– XV (*nix freeware)XV (*nix freeware)– IrfanView (Win freeware)IrfanView (Win freeware)
• ConvertConvert– ImageMagick (Mac/*nix freeware)ImageMagick (Mac/*nix freeware)
• Manipulate, create (and convert)Manipulate, create (and convert)– Adobe Photoshop (Win/Mac commercial)Adobe Photoshop (Win/Mac commercial)– Paint Shop Pro (Win shareware)Paint Shop Pro (Win shareware)– The Gimp (Win/Mac/*nix open source)The Gimp (Win/Mac/*nix open source)
8
The GimpThe Gimp
• PhotoshoplikePhotoshoplike• www.gimp.orgwww.gimp.org• Open source with big communityOpen source with big community• PluginsPlugins• Developed on Unix platform. Windows Developed on Unix platform. Windows
version is a port.version is a port.• No real CMYK handling (bad for Desktop No real CMYK handling (bad for Desktop
Publishing)Publishing)9
MatlabMatlab
• MATrix LABoratoryMATrix LABoratory– Optimized for matrix computationsOptimized for matrix computations– ““No for loops”No for loops”
• www.mathworks.comwww.mathworks.com• Image Processing ToolboxImage Processing Toolbox• CommercialCommercial
– Matlab 8.000 SEKMatlab 8.000 SEK– IP Toolbox 3.500 SEKIP Toolbox 3.500 SEK– Complete Matlab 30.000 SEKComplete Matlab 30.000 SEK 10
Matlab IOMatlab IO
• File formatsFile formats– JPG, TIFF, GIF, PNG, BMP, ...JPG, TIFF, GIF, PNG, BMP, ...– Support for DICOMSupport for DICOM– Raw filesRaw files
• imread, imwriteimread, imwrite– I=imread('imagename.tif','tif')I=imread('imagename.tif','tif')
– imwrite(I,'imagename.tif','tif')imwrite(I,'imagename.tif','tif')
• Image acquisition toolboxImage acquisition toolbox– Direct feed from cameras, microscopes, ...Direct feed from cameras, microscopes, ...
fid=fopen(‘file.raw','r')img=fread(fid_in,'uchar');img=reshape(img,x,y,z);
11
Matlab – Basic functionsMatlab – Basic functions
• Image arithmeticsImage arithmetics– Operate directly on matrices: +, , ...Operate directly on matrices: +, , ...– Work with uint8, uint16 data: Work with uint8, uint16 data: imaddimadd, , imsubstractimsubstract, …, …
• Image enhancementImage enhancement– Change brightness/contrast: Change brightness/contrast: imadjustimadjust
– Histogram equalisation: Histogram equalisation: histeqhisteq
12
Matlab – Basic functionsMatlab – Basic functions
• Geometric transformationsGeometric transformations– imrotate, imcropimrotate, imcrop
– imtransform (affine, projective, ...)imtransform (affine, projective, ...)
• Resizing, interpolationResizing, interpolation– imresizeimresize
– Interpolation methodsInterpolation methods• Nearest (neighbour)Nearest (neighbour)• Bilinear (2x2), bicubic (4x4)Bilinear (2x2), bicubic (4x4)• Spline (if Spline toolbox installed)Spline (if Spline toolbox installed)
13
Matlab – Basic functionsMatlab – Basic functions
• Feature extractionFeature extraction– Linear filtering: Linear filtering: filter2filter2
– Classical edge operators: Classical edge operators: edgeedgef=fspecial('gaussian');bilg=filter2(f,bil));
bilEdge=edge(bil,'sobel');
14
Matlab AdvancedMatlab Advanced
• Filtering (FIR filter creation – SP toolbox)Filtering (FIR filter creation – SP toolbox)• Inverse filtering (restoration)Inverse filtering (restoration)• Image transforms (FFT, PCA, ...)Image transforms (FFT, PCA, ...)• Binary and greyscale morphologyBinary and greyscale morphology• SegmentationSegmentation
– Watershed (also on color images)Watershed (also on color images)
15
Matlab VisualizationMatlab Visualization
• 2D display2D display– imshowimshow
– imagescimagesc
• 3D surface rendering3D surface rendering– isosurface, patchisosurface, patch
– isocaps, isonormalsisocaps, isonormals
– ......
16
Matlab GUIMatlab GUI
17
Matlab MoreMatlab More
• Integration capabilitiesIntegration capabilities– Matlab C compilerMatlab C compiler– JAVAJAVA
• Pros and consPros and cons + + Easy to learnEasy to learn
++ All basic tools in IP toolbox All basic tools in IP toolbox
++ Multiplatform (*.m scripts) Multiplatform (*.m scripts)
++ Ndimensional Ndimensional
18
Memory handling (double) [Matlab7 uses single]
Only optimal for “vectorizable” algorithms
Matlab UsageMatlab Usage
• Prototyping of programsPrototyping of programs
• Easy for advanced 2DEasy for advanced 2D
• Simple 3DSimple 3D
19
ImageJImageJ
• Originally developed on Mac for cell Originally developed on Mac for cell analysis of microscopic images (NIH analysis of microscopic images (NIH image)image)
• rsb.info.nih.govrsb.info.nih.gov• Open source (public domain)Open source (public domain)
20
ImageJ IOImageJ IO
• File formatsFile formats– TIF (even 16 bits), GIF, JPG, Raw, ...TIF (even 16 bits), GIF, JPG, Raw, ...– Support for DICOM via pluginSupport for DICOM via plugin
• Lots of plugins for different Lots of plugins for different microscopesmicroscopes
21
ImageJ – Basic functionsImageJ – Basic functions
• Image enhancementImage enhancement• Image measurementsImage measurements
– ROI tools: draw, count, measureROI tools: draw, count, measure
• Edge extraction, binary & grayscale Edge extraction, binary & grayscale morphologymorphology
22
ImageJ ExtensionsImageJ Extensions
• Add plugin in JAVAAdd plugin in JAVA– TransformJ: geometric transformationsTransformJ: geometric transformations– FeatureJ: gradient, 2FeatureJ: gradient, 2ndnd derivative, … derivative, …– VolumeJ: volume rendererVolumeJ: volume renderer– ......
• Scripting language (record function + Scripting language (record function + edit script)edit script)
• Use ImageJ as a toolbox within another Use ImageJ as a toolbox within another appletapplet
23
ImageJ – Pros and consImageJ – Pros and cons
++ JAVA: easy to learn JAVA: easy to learn ++ JAVA: runs on all platforms JAVA: runs on all platforms ++ Open source: FREE Open source: FREE ++ Extensions by JAVA plugins or scripting Extensions by JAVA plugins or scripting Data type not originally meant for 3D Data type not originally meant for 3D
24
ImageJ UsageImageJ Usage
• Complete userinterfaced solutionComplete userinterfaced solution
• Easy for midadvanced 2DEasy for midadvanced 2D
• Simple 3DSimple 3D
25
ITKITK
• NLM Insight Segmentation & NLM Insight Segmentation & Registration ToolkitRegistration Toolkit
• Project at the National Library of Project at the National Library of Medicine (at NIH)Medicine (at NIH)
• GoalsGoals– Support the Visible Human ProjectSupport the Visible Human Project– Create a repository of fundamental algorithmsCreate a repository of fundamental algorithms– Develop a platform for advanced product Develop a platform for advanced product
developmentdevelopment– Grow a selfsustaining community of software Grow a selfsustaining community of software
users and developersusers and developers 26
ITK – PrinciplesITK – Principles
• The data pipelineThe data pipeline
• Generic programming with templatesGeneric programming with templates– ITK images are NdimensionalITK images are Ndimensional– ITK handles arbitrary pixel typeITK handles arbitrary pixel type
ReaderImage
FileGaussian
ImageWriter File
27
ITK – Available algorithmsITK – Available algorithms
• Binary and grayscale morphologyBinary and grayscale morphology– WatershedWatershed
• Partial differential equations methodsPartial differential equations methods– Anisotropic diffusion filtersAnisotropic diffusion filters– Level sets, fast marchingLevel sets, fast marching
• Advanced data structuresAdvanced data structures– Mesh, point clouds, vector imagesMesh, point clouds, vector images
See IA MN2
28
ITK – ExtensionsITK – Extensions
• Write new filtersWrite new filters• GUI: fltk, QT, Windows MFCGUI: fltk, QT, Windows MFC• Visualisation: Visualisation: VTKVTK• Scripting: Tcl, Python, JAVAScripting: Tcl, Python, JAVA
29
ITK – Pros and consITK – Pros and cons
++ Growing and very active community Growing and very active community ++ Can handle Ndimensional data Can handle Ndimensional data ++ Open Source: FREE Open Source: FREE ++ Very advanced algorithms Very advanced algorithms Steep learning curve Steep learning curve No builtin GUI No builtin GUI
30
ITK – UsageITK – Usage
• Serious IA/IP needsSerious IA/IP needs
• Multidimensional algorithmsMultidimensional algorithms
• Speed (C++ on image buffers)Speed (C++ on image buffers)
• Prototyping IA/IP programs using scripting Prototyping IA/IP programs using scripting languageslanguages
31