├── CMakeLists.txt ├── Documents ├── Art │ ├── KitwareFocusAreas.png │ ├── OpenCVITKex1-ans.png │ ├── OpenCVITKex1.png │ ├── OpenCVLogo.png │ ├── OpenCVex1-GUI.png │ ├── OpenCVex1-ans-GUI.png │ ├── OpenCVex2-ans-GUI.png │ ├── OpenCVex2-ans-save.png │ ├── Screenshot-CMakeGUI-01.png │ ├── Screenshot-CMakeGUI-02.png │ ├── Screenshot-CMakeGUI-03.png │ ├── Screenshot-CMakeGUI-04.png │ ├── Screenshot-CMakeGUI-05.png │ ├── Screenshot-ITKDoxygen-01.png │ ├── Screenshot-Nautilus.jpg │ ├── Screenshot-OpenCV-ITK-VirtualBox-01.png │ ├── Screenshot-OpenTerminal.jpg │ ├── Screenshot-Terminal.jpg │ ├── Screenshot-VirtualBox-OSE-01.png │ ├── Screenshot-VirtualBox-OSE-02.png │ ├── Screenshot-mandrillgray-01.png │ ├── Screenshot-mandrillgrayCanny-01.png │ ├── Screenshot-mandrillgrayMean-01.png │ ├── Screenshot-mandrillgrayMedian-01.png │ ├── Tux.png │ ├── asus.jpg │ ├── blackeubuntulogo.png │ ├── hart.png │ ├── ibanez.png │ ├── itkLogo.png │ ├── leotta.png │ ├── mandrilgray.png │ ├── perera.png │ └── reynolds.png ├── CMakeLists.txt └── Tutorial │ ├── CMakeLists.txt │ ├── ITKIntroduction.tex │ ├── ITKOpenCVBridge.tex │ ├── ITKOpenCVBridgeTutorial.tex │ ├── ITKOverview.tex │ ├── ITKVideoFilters.tex │ ├── OpenCVIntroduction.tex │ ├── SoftwareEnvironment.tex │ ├── SoftwarePreparation.tex │ ├── SoftwarePreparation1.tex │ └── SoftwarePreparation2.tex ├── Exercises ├── CMakeLists.txt ├── ITKIntroduction │ ├── CMakeLists.txt │ └── exercise1 │ │ ├── BasicImageFilteringITK.cxx │ │ ├── BasicImageFilteringITKAnswer1.cxx │ │ ├── BasicImageFilteringITKAnswer2.cxx │ │ ├── CMakeLists.txt │ │ └── build.sh ├── ITKOpenCVBridge │ ├── CMakeLists.txt │ ├── exercise1 │ │ ├── BasicFilteringITKOpenCVBridge.cxx │ │ ├── BasicFilteringITKOpenCVBridgeAnswer.cxx │ │ └── CMakeLists.txt │ └── exercise2 │ │ ├── BasicVideoFilteringITKOpenCVBridge.cxx │ │ ├── BasicVideoFilteringITKOpenCVBridgeAnswer.cxx │ │ └── CMakeLists.txt ├── ITKVideoPipeline │ ├── CMakeLists.txt │ ├── exercise1 │ │ ├── CMakeLists.txt │ │ ├── ITKVideoSingleFrameFilters.cxx │ │ └── ITKVideoSingleFrameFiltersAnswer.cxx │ └── exercise2 │ │ ├── CMakeLists.txt │ │ ├── ITKVideoMultiFrameFilters.cxx │ │ ├── ITKVideoMultiFrameFiltersAnswer.cxx │ │ └── ITKVideoMultiFrameFiltersAnswer2.cxx └── OpenCVIntroduction │ ├── CMakeLists.txt │ ├── exercise1 │ ├── BasicFilteringOpenCV.cxx │ ├── BasicFilteringOpenCVAnswer.cxx │ └── CMakeLists.txt │ └── exercise2 │ ├── BasicVideoFilteringOpenCV.cxx │ ├── BasicVideoFilteringOpenCVAnswer.cxx │ └── CMakeLists.txt └── README /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8 FATAL_ERROR) 2 | 3 | project(ITK-OpenCV-Bridge) 4 | 5 | set(CMAKE_MODULE_PATH ${ITK-OpenCV-Bridge_SOURCE_DIR}/CMake ${CMAKE_MODULE_PATH}) 6 | 7 | 8 | file(GLOB_RECURSE CXX_FILES "*.cxx") 9 | 10 | 11 | add_subdirectory(Exercises) 12 | 13 | 14 | option(BUILD_PRESENTATION "Build the PDF Presentation." ON) 15 | 16 | if(BUILD_PRESENTATION) 17 | add_subdirectory(Documents) 18 | endif() 19 | -------------------------------------------------------------------------------- /Documents/Art/KitwareFocusAreas.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InsightSoftwareConsortium/ITK-OpenCV-Bridge-Tutorial/0c47e0a06d61f21acd27ad4339ce0e42c8260a0c/Documents/Art/KitwareFocusAreas.png -------------------------------------------------------------------------------- /Documents/Art/OpenCVITKex1-ans.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InsightSoftwareConsortium/ITK-OpenCV-Bridge-Tutorial/0c47e0a06d61f21acd27ad4339ce0e42c8260a0c/Documents/Art/OpenCVITKex1-ans.png -------------------------------------------------------------------------------- /Documents/Art/OpenCVITKex1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InsightSoftwareConsortium/ITK-OpenCV-Bridge-Tutorial/0c47e0a06d61f21acd27ad4339ce0e42c8260a0c/Documents/Art/OpenCVITKex1.png -------------------------------------------------------------------------------- /Documents/Art/OpenCVLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InsightSoftwareConsortium/ITK-OpenCV-Bridge-Tutorial/0c47e0a06d61f21acd27ad4339ce0e42c8260a0c/Documents/Art/OpenCVLogo.png -------------------------------------------------------------------------------- /Documents/Art/OpenCVex1-GUI.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InsightSoftwareConsortium/ITK-OpenCV-Bridge-Tutorial/0c47e0a06d61f21acd27ad4339ce0e42c8260a0c/Documents/Art/OpenCVex1-GUI.png -------------------------------------------------------------------------------- /Documents/Art/OpenCVex1-ans-GUI.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InsightSoftwareConsortium/ITK-OpenCV-Bridge-Tutorial/0c47e0a06d61f21acd27ad4339ce0e42c8260a0c/Documents/Art/OpenCVex1-ans-GUI.png -------------------------------------------------------------------------------- /Documents/Art/OpenCVex2-ans-GUI.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InsightSoftwareConsortium/ITK-OpenCV-Bridge-Tutorial/0c47e0a06d61f21acd27ad4339ce0e42c8260a0c/Documents/Art/OpenCVex2-ans-GUI.png -------------------------------------------------------------------------------- /Documents/Art/OpenCVex2-ans-save.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InsightSoftwareConsortium/ITK-OpenCV-Bridge-Tutorial/0c47e0a06d61f21acd27ad4339ce0e42c8260a0c/Documents/Art/OpenCVex2-ans-save.png -------------------------------------------------------------------------------- /Documents/Art/Screenshot-CMakeGUI-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InsightSoftwareConsortium/ITK-OpenCV-Bridge-Tutorial/0c47e0a06d61f21acd27ad4339ce0e42c8260a0c/Documents/Art/Screenshot-CMakeGUI-01.png -------------------------------------------------------------------------------- /Documents/Art/Screenshot-CMakeGUI-02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InsightSoftwareConsortium/ITK-OpenCV-Bridge-Tutorial/0c47e0a06d61f21acd27ad4339ce0e42c8260a0c/Documents/Art/Screenshot-CMakeGUI-02.png -------------------------------------------------------------------------------- /Documents/Art/Screenshot-CMakeGUI-03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InsightSoftwareConsortium/ITK-OpenCV-Bridge-Tutorial/0c47e0a06d61f21acd27ad4339ce0e42c8260a0c/Documents/Art/Screenshot-CMakeGUI-03.png -------------------------------------------------------------------------------- /Documents/Art/Screenshot-CMakeGUI-04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InsightSoftwareConsortium/ITK-OpenCV-Bridge-Tutorial/0c47e0a06d61f21acd27ad4339ce0e42c8260a0c/Documents/Art/Screenshot-CMakeGUI-04.png -------------------------------------------------------------------------------- /Documents/Art/Screenshot-CMakeGUI-05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InsightSoftwareConsortium/ITK-OpenCV-Bridge-Tutorial/0c47e0a06d61f21acd27ad4339ce0e42c8260a0c/Documents/Art/Screenshot-CMakeGUI-05.png -------------------------------------------------------------------------------- /Documents/Art/Screenshot-ITKDoxygen-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InsightSoftwareConsortium/ITK-OpenCV-Bridge-Tutorial/0c47e0a06d61f21acd27ad4339ce0e42c8260a0c/Documents/Art/Screenshot-ITKDoxygen-01.png -------------------------------------------------------------------------------- /Documents/Art/Screenshot-Nautilus.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InsightSoftwareConsortium/ITK-OpenCV-Bridge-Tutorial/0c47e0a06d61f21acd27ad4339ce0e42c8260a0c/Documents/Art/Screenshot-Nautilus.jpg -------------------------------------------------------------------------------- /Documents/Art/Screenshot-OpenCV-ITK-VirtualBox-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InsightSoftwareConsortium/ITK-OpenCV-Bridge-Tutorial/0c47e0a06d61f21acd27ad4339ce0e42c8260a0c/Documents/Art/Screenshot-OpenCV-ITK-VirtualBox-01.png -------------------------------------------------------------------------------- /Documents/Art/Screenshot-OpenTerminal.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InsightSoftwareConsortium/ITK-OpenCV-Bridge-Tutorial/0c47e0a06d61f21acd27ad4339ce0e42c8260a0c/Documents/Art/Screenshot-OpenTerminal.jpg -------------------------------------------------------------------------------- /Documents/Art/Screenshot-Terminal.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InsightSoftwareConsortium/ITK-OpenCV-Bridge-Tutorial/0c47e0a06d61f21acd27ad4339ce0e42c8260a0c/Documents/Art/Screenshot-Terminal.jpg -------------------------------------------------------------------------------- /Documents/Art/Screenshot-VirtualBox-OSE-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InsightSoftwareConsortium/ITK-OpenCV-Bridge-Tutorial/0c47e0a06d61f21acd27ad4339ce0e42c8260a0c/Documents/Art/Screenshot-VirtualBox-OSE-01.png -------------------------------------------------------------------------------- /Documents/Art/Screenshot-VirtualBox-OSE-02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InsightSoftwareConsortium/ITK-OpenCV-Bridge-Tutorial/0c47e0a06d61f21acd27ad4339ce0e42c8260a0c/Documents/Art/Screenshot-VirtualBox-OSE-02.png -------------------------------------------------------------------------------- /Documents/Art/Screenshot-mandrillgray-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InsightSoftwareConsortium/ITK-OpenCV-Bridge-Tutorial/0c47e0a06d61f21acd27ad4339ce0e42c8260a0c/Documents/Art/Screenshot-mandrillgray-01.png -------------------------------------------------------------------------------- /Documents/Art/Screenshot-mandrillgrayCanny-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InsightSoftwareConsortium/ITK-OpenCV-Bridge-Tutorial/0c47e0a06d61f21acd27ad4339ce0e42c8260a0c/Documents/Art/Screenshot-mandrillgrayCanny-01.png -------------------------------------------------------------------------------- /Documents/Art/Screenshot-mandrillgrayMean-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InsightSoftwareConsortium/ITK-OpenCV-Bridge-Tutorial/0c47e0a06d61f21acd27ad4339ce0e42c8260a0c/Documents/Art/Screenshot-mandrillgrayMean-01.png -------------------------------------------------------------------------------- /Documents/Art/Screenshot-mandrillgrayMedian-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InsightSoftwareConsortium/ITK-OpenCV-Bridge-Tutorial/0c47e0a06d61f21acd27ad4339ce0e42c8260a0c/Documents/Art/Screenshot-mandrillgrayMedian-01.png -------------------------------------------------------------------------------- /Documents/Art/Tux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InsightSoftwareConsortium/ITK-OpenCV-Bridge-Tutorial/0c47e0a06d61f21acd27ad4339ce0e42c8260a0c/Documents/Art/Tux.png -------------------------------------------------------------------------------- /Documents/Art/asus.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InsightSoftwareConsortium/ITK-OpenCV-Bridge-Tutorial/0c47e0a06d61f21acd27ad4339ce0e42c8260a0c/Documents/Art/asus.jpg -------------------------------------------------------------------------------- /Documents/Art/blackeubuntulogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InsightSoftwareConsortium/ITK-OpenCV-Bridge-Tutorial/0c47e0a06d61f21acd27ad4339ce0e42c8260a0c/Documents/Art/blackeubuntulogo.png -------------------------------------------------------------------------------- /Documents/Art/hart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InsightSoftwareConsortium/ITK-OpenCV-Bridge-Tutorial/0c47e0a06d61f21acd27ad4339ce0e42c8260a0c/Documents/Art/hart.png -------------------------------------------------------------------------------- /Documents/Art/ibanez.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InsightSoftwareConsortium/ITK-OpenCV-Bridge-Tutorial/0c47e0a06d61f21acd27ad4339ce0e42c8260a0c/Documents/Art/ibanez.png -------------------------------------------------------------------------------- /Documents/Art/itkLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InsightSoftwareConsortium/ITK-OpenCV-Bridge-Tutorial/0c47e0a06d61f21acd27ad4339ce0e42c8260a0c/Documents/Art/itkLogo.png -------------------------------------------------------------------------------- /Documents/Art/leotta.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InsightSoftwareConsortium/ITK-OpenCV-Bridge-Tutorial/0c47e0a06d61f21acd27ad4339ce0e42c8260a0c/Documents/Art/leotta.png -------------------------------------------------------------------------------- /Documents/Art/mandrilgray.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InsightSoftwareConsortium/ITK-OpenCV-Bridge-Tutorial/0c47e0a06d61f21acd27ad4339ce0e42c8260a0c/Documents/Art/mandrilgray.png -------------------------------------------------------------------------------- /Documents/Art/perera.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InsightSoftwareConsortium/ITK-OpenCV-Bridge-Tutorial/0c47e0a06d61f21acd27ad4339ce0e42c8260a0c/Documents/Art/perera.png -------------------------------------------------------------------------------- /Documents/Art/reynolds.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InsightSoftwareConsortium/ITK-OpenCV-Bridge-Tutorial/0c47e0a06d61f21acd27ad4339ce0e42c8260a0c/Documents/Art/reynolds.png -------------------------------------------------------------------------------- /Documents/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | find_package(LATEX) 2 | 3 | if(NOT PDFLATEX_COMPILER) 4 | message("pdflatex compiler was not found. Please pass to advanced mode and provide its full path" FATAL_ERROR) 5 | endif() 6 | 7 | file(GLOB_RECURSE PNG_FILES "*.png") 8 | file(GLOB_RECURSE JPG_FILES "*.jpg") 9 | 10 | add_subdirectory(Tutorial) 11 | 12 | -------------------------------------------------------------------------------- /Documents/Tutorial/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(ITKOpenCVBridgeTutorialPresentation) 2 | 3 | 4 | # 5 | # Copy the tex files to the binary build directory 6 | # 7 | file(GLOB TEX_FILES *.tex) 8 | 9 | file( 10 | COPY ${TEX_FILES} 11 | DESTINATION ${ITKOpenCVBridgeTutorialPresentation_BINARY_DIR} 12 | ) 13 | 14 | 15 | # 16 | # Copy the .cxx files to the binary build directory 17 | # to make easier to source them as code snippets. 18 | # 19 | # This CXX_FILES variable is populated in the top CMakeLists.txt file 20 | # 21 | file( 22 | COPY ${CXX_FILES} 23 | DESTINATION ${ITKOpenCVBridgeTutorialPresentation_BINARY_DIR} 24 | ) 25 | 26 | 27 | # 28 | # Copy the image files to the binary build directory 29 | # to make easier to insert them in the latex document 30 | # 31 | # This PNG_FILES variable is populated in the Documents/CMakeLists.txt file 32 | # 33 | file( 34 | COPY ${PNG_FILES} 35 | DESTINATION ${ITKOpenCVBridgeTutorialPresentation_BINARY_DIR} 36 | ) 37 | 38 | 39 | # 40 | # Copy the image files to the binary build directory 41 | # to make easier to insert them in the latex document 42 | # 43 | # This JPG_FILES variable is populated in the Documents/CMakeLists.txt file 44 | # 45 | file( 46 | COPY ${JPG_FILES} 47 | DESTINATION ${ITKOpenCVBridgeTutorialPresentation_BINARY_DIR} 48 | ) 49 | 50 | 51 | # 52 | # This adds a custom target that generates the output document 53 | # This target depends on the list of copied files created 54 | # with the custom command above and the Plots target. 55 | # 56 | add_custom_target(ShortTutorialPresentation ALL 57 | COMMAND ${PDFLATEX_COMPILER} 58 | ${ITKOpenCVBridgeTutorialPresentation_SOURCE_DIR}/ITKOpenCVBridgeTutorial.tex 59 | -output-directory ${ITKOpenCVBridgeTutorialPresentation_BINARY_DIR} 60 | DEPENDS ${COPY_RESULTS} ${REPORT_ELEMENTS} 61 | WORKING_DIRECTORY ${ITKOpenCVBridgeTutorialPresentation_BINARY_DIR} 62 | ) 63 | 64 | -------------------------------------------------------------------------------- /Documents/Tutorial/ITKIntroduction.tex: -------------------------------------------------------------------------------- 1 | \section{ITK Introduction} 2 | 3 | 4 | \centeredlargetext{white}{black}{ 5 | ITK Introduction 6 | } 7 | 8 | \begin{frame} 9 | \frametitle{ITK is a Templated Library} 10 | You will typically do: 11 | \begin{itemize} 12 | \item Include headers 13 | \pause 14 | \item Pick pixel type 15 | \pause 16 | \item Pick image dimension 17 | \pause 18 | \item Instantiate image type 19 | \pause 20 | \item Instantiate filter type 21 | \pause 22 | \item Create filters 23 | \pause 24 | \item Connect pipeline 25 | \pause 26 | \item Run pipeline 27 | \end{itemize} 28 | \end{frame} 29 | 30 | { 31 | \setbeamertemplate{navigation symbols}{} 32 | \begin{frame}[fragile] 33 | \frametitle{Basic Filtering - Median Filter} 34 | \framesubtitle{ITKIntroduction/exercise1/BasicImageFilteringITK.cxx} 35 | \begin{itemize} 36 | \item Include headers 37 | \end{itemize} 38 | \lstlistingwithnumber{19}{21}{BasicImageFilteringITK.cxx} 39 | \pause 40 | \begin{itemize} 41 | \item Read images from files 42 | \item Write images from files 43 | \item Apply a Median filter in an image 44 | \end{itemize} 45 | \end{frame} 46 | } 47 | 48 | { 49 | \setbeamertemplate{navigation symbols}{} 50 | \begin{frame}[fragile] 51 | \frametitle{Basic Filtering - Median Filter} 52 | \framesubtitle{ITKIntroduction/exercise1/BasicImageFilteringITK.cxx} 53 | \begin{itemize} 54 | \item Declare pixel types and image dimension 55 | \lstlistingwithnumber{32}{35}{BasicImageFilteringITK.cxx} 56 | \end{itemize} 57 | \pause 58 | \begin{itemize} 59 | \item Declare input and output image types 60 | \lstlistingwithnumber{37}{38}{BasicImageFilteringITK.cxx} 61 | \end{itemize} 62 | \end{frame} 63 | } 64 | 65 | { 66 | \setbeamertemplate{navigation symbols}{} 67 | \begin{frame}[fragile] 68 | \frametitle{Basic Filtering - Median Filter} 69 | \framesubtitle{ITKIntroduction/exercise1/BasicImageFilteringITK.cxx} 70 | \begin{itemize} 71 | \item Declare the types for reader and writer 72 | \lstlistingwithnumber{40}{41}{BasicImageFilteringITK.cxx} 73 | \end{itemize} 74 | \pause 75 | \begin{itemize} 76 | \item Instantiate the reader and writer objects (source and sink) 77 | \lstlistingwithnumber{43}{44}{BasicImageFilteringITK.cxx} 78 | \end{itemize} 79 | \pause 80 | \begin{itemize} 81 | \item Set input and output filenames 82 | \lstlistingwithnumber{46}{47}{BasicImageFilteringITK.cxx} 83 | \end{itemize} 84 | \end{frame} 85 | } 86 | 87 | { 88 | \setbeamertemplate{navigation symbols}{} 89 | \begin{frame}[fragile] 90 | \frametitle{Basic Filtering - Median Filter} 91 | \framesubtitle{ITKIntroduction/exercise1/BasicImageFilteringITK.cxx} 92 | \begin{itemize} 93 | \item Declare the Median filter type 94 | \lstlistingwithnumber{49}{50}{BasicImageFilteringITK.cxx} 95 | \end{itemize} 96 | \pause 97 | \begin{itemize} 98 | \item Create the filter 99 | \lstlistingwithnumber{51}{51}{BasicImageFilteringITK.cxx} 100 | \end{itemize} 101 | \end{frame} 102 | } 103 | 104 | { 105 | \setbeamertemplate{navigation symbols}{} 106 | \begin{frame}[fragile] 107 | \frametitle{Basic Filtering - Median Filter} 108 | \framesubtitle{ITKIntroduction/exercise1/BasicImageFilteringITK.cxx} 109 | \begin{itemize} 110 | \item Define the Median kernel radius (Manhattan Radius) 111 | \lstlistingwithnumber{55}{58}{BasicImageFilteringITK.cxx} 112 | \end{itemize} 113 | \pause 114 | \begin{itemize} 115 | \item Connect the pipeline 116 | \lstlistingwithnumber{60}{61}{BasicImageFilteringITK.cxx} 117 | \end{itemize} 118 | \end{frame} 119 | } 120 | 121 | { 122 | \setbeamertemplate{navigation symbols}{} 123 | \begin{frame}[fragile] 124 | \frametitle{Basic Filtering - Median Filter} 125 | \framesubtitle{ITKIntroduction/exercise1/BasicImageFilteringITK.cxx} 126 | \begin{itemize} 127 | \item Trigger the pipeline execution by calling Update(). 128 | \lstlistingwithnumber{63}{71}{BasicImageFilteringITK.cxx} 129 | \end{itemize} 130 | \pause 131 | \begin{itemize} 132 | \item ITK uses C++ exceptions for error management 133 | \item Exceptions are typically thrown during Update() calls 134 | \item Applications must catch the exceptions and solve them 135 | \end{itemize} 136 | \end{frame} 137 | } 138 | 139 | \begin{frame} 140 | \frametitle{How to Configure and Build} 141 | \framesubtitle{cmake-gui} 142 | \begin{itemize} 143 | \item Create a binary directory 144 | \item Configure the code with CMake 145 | \item Build (compile and link an executable) 146 | \item Run it in example image 147 | \end{itemize} 148 | \end{frame} 149 | 150 | \begin{frame}[fragile] 151 | \frametitle{How to Configure and Build} 152 | \framesubtitle{cmake-gui} 153 | \begin{itemize} 154 | \item Create a binary directory 155 | \begin{verbatim} 156 | cd ~/bin 157 | mkdir itkexercise1b 158 | cd itkexercise1b 159 | \end{verbatim} 160 | \end{itemize} 161 | \vspace{1in} 162 | \textcolor{gray}{For convenience, a pre-built version is available in \texttt{\textasciitilde/bin/itkexercise1}} 163 | \end{frame} 164 | 165 | \begin{frame}[fragile] 166 | \frametitle{How to Configure and Build} 167 | \framesubtitle{cmake-gui} 168 | \begin{itemize} 169 | \item Run ``cmake-gui'' 170 | \end{itemize} 171 | \begin{center} 172 | \includegraphics[width=0.5\paperwidth]{Screenshot-CMakeGUI-01.png} 173 | \end{center} 174 | \end{frame} 175 | 176 | \begin{frame}[fragile] 177 | \frametitle{How to Configure and Build} 178 | \framesubtitle{cmake-gui} 179 | \begin{itemize} 180 | \item Set ``Source Directory'' (where the source code is) 181 | \item Set ``Binary Directory'' (where to build the executable) 182 | \item Click on ``Configure'' 183 | \end{itemize} 184 | \begin{center} 185 | \includegraphics[width=0.7\paperwidth]{Screenshot-CMakeGUI-02.png} 186 | \end{center} 187 | \end{frame} 188 | 189 | \begin{frame}[fragile] 190 | \frametitle{How to Configure and Build} 191 | \framesubtitle{cmake-gui} 192 | \begin{itemize} 193 | \item You will get an error message 194 | \end{itemize} 195 | \begin{center} 196 | \includegraphics[width=0.4\paperwidth]{Screenshot-CMakeGUI-03.png} 197 | \end{center} 198 | \begin{itemize} 199 | \item Because the project needs ITK and OpenCV 200 | \item and we have not provided ITK\_DIR or OpenCV\_DIR yet 201 | \end{itemize} 202 | \end{frame} 203 | 204 | 205 | \begin{frame}[fragile] 206 | \frametitle{How to Configure and Build} 207 | \framesubtitle{cmake-gui} 208 | \begin{itemize} 209 | \item Provide the path to ITK in the ITK\_DIR variable 210 | \item /home/tutorial/bin/ITKVideo/Release 211 | \pause 212 | \item Provide the path to OpenCV in the OpenCV\_DIR variable 213 | \item /home/tutorial/bin/opencv/Release 214 | \end{itemize} 215 | \begin{center} 216 | \includegraphics[width=0.7\paperwidth]{Screenshot-CMakeGUI-04.png} 217 | \end{center} 218 | \end{frame} 219 | 220 | \begin{frame}[fragile] 221 | \frametitle{How to Configure and Build} 222 | \framesubtitle{cmake-gui} 223 | \begin{itemize} 224 | \item Click on ``Configure'' 225 | \item Click on ``Generate'' 226 | \end{itemize} 227 | \begin{center} 228 | \includegraphics[width=0.7\paperwidth]{Screenshot-CMakeGUI-05.png} 229 | \end{center} 230 | \end{frame} 231 | 232 | \begin{frame}[fragile] 233 | \frametitle{How to Build} 234 | \framesubtitle{make} 235 | \begin{itemize} 236 | \item In the command line do: 237 | \begin{verbatim} 238 | cd /home/tutorial/bin/itkexercise1b 239 | make 240 | \end{verbatim} 241 | \end{itemize} 242 | \end{frame} 243 | 244 | \begin{frame}[fragile] 245 | \frametitle{How to Run} 246 | \framesubtitle{/home/tutorial/bin/itkexercise1b} 247 | \begin{itemize} 248 | \item While in the binary directory: 249 | \begin{verbatim} 250 | /home/tutorial/bin/itkexercise1b 251 | \end{verbatim} 252 | \item In the command line type: 253 | \begin{verbatim} 254 | ./BasicImageFilteringITK \ 255 | ~/data/mandrillgray.png \ 256 | ./mandrillgrayMedian.png \ 257 | 3 3 258 | \end{verbatim} 259 | \end{itemize} 260 | \end{frame} 261 | 262 | \begin{frame}[fragile] 263 | \frametitle{How to View the Result} 264 | \framesubtitle{Image viewing application ``eye of gnome'': eog} 265 | \begin{itemize} 266 | \item In the command line type: 267 | \begin{verbatim} 268 | eog ~/data/mandrillgray.jpg & 269 | eog ./mandrillgrayMedian.png & 270 | \end{verbatim} 271 | \end{itemize} 272 | \end{frame} 273 | 274 | \begin{frame}[fragile] 275 | \frametitle{Result of Median Filter} 276 | \begin{center} 277 | \includegraphics[width=0.45\paperwidth]{Screenshot-mandrillgray-01.png} 278 | \includegraphics[width=0.45\paperwidth]{Screenshot-mandrillgrayMedian-01.png} 279 | \end{center} 280 | \end{frame} 281 | 282 | \begin{frame}[fragile] 283 | \frametitle{Excercise 1} 284 | \framesubtitle{Replace the filter with another one} 285 | \begin{itemize} 286 | \item Select a Filter from the Doxygen documentation\\ 287 | (e.g. MeanImageFilter) 288 | \item Replace the MedianImageFilter with the selected filter 289 | \item Recompile 290 | \item Rerun 291 | \end{itemize} 292 | \end{frame} 293 | 294 | \begin{frame}[fragile] 295 | \frametitle{ITK Doxygen Documentation} 296 | \begin{center} 297 | \includegraphics[scale=0.3]{Screenshot-ITKDoxygen-01.png} 298 | \end{center} 299 | \end{frame} 300 | 301 | \begin{frame} 302 | \frametitle{Excercise 1} 303 | \framesubtitle{ITKIntroduction/exercise1/BasicImageFilteringITKAnswer1.cxx} 304 | \begin{itemize} 305 | \item First we replace the Header file: 306 | \lstlistingwithnumber{21}{21}{BasicImageFilteringITKAnswer1.cxx} 307 | \pause 308 | \item Then we replace the Filter instantiation: 309 | \lstlistingwithnumber{49}{49}{BasicImageFilteringITKAnswer1.cxx} 310 | \end{itemize} 311 | \end{frame} 312 | 313 | \begin{frame}[fragile] 314 | \frametitle{How to Build} 315 | \framesubtitle{make} 316 | \begin{itemize} 317 | \item In the command line do: 318 | \begin{verbatim} 319 | cd /home/tutorial/bin/itkexercise1b 320 | make 321 | \end{verbatim} 322 | \end{itemize} 323 | \end{frame} 324 | 325 | \begin{frame}[fragile] 326 | \frametitle{How to Run} 327 | \framesubtitle{/home/tutorial/bin/itkexercise1b} 328 | \begin{itemize} 329 | \item While in the binary directory: 330 | \begin{verbatim} 331 | /home/tutorial/bin/itkexercise1b 332 | \end{verbatim} 333 | \item In the command line type: 334 | \begin{verbatim} 335 | ./BasicImageFilteringITK \ 336 | ~/data/mandrillgray.png \ 337 | ./mandrillgrayMean.png \ 338 | 3 3 339 | \end{verbatim} 340 | \end{itemize} 341 | \end{frame} 342 | 343 | \begin{frame}[fragile] 344 | \frametitle{How to View the Result} 345 | \framesubtitle{Image viewing application ``eye of gnome'': eog} 346 | \begin{itemize} 347 | \item In the command line type: 348 | \begin{verbatim} 349 | eog ~/data/mandrillgray.jpg & 350 | eog ./mandrillgrayMean.png & 351 | \end{verbatim} 352 | \end{itemize} 353 | \end{frame} 354 | 355 | \begin{frame}[fragile] 356 | \frametitle{Result of Mean Filter} 357 | \begin{center} 358 | \includegraphics[width=0.45\paperwidth]{Screenshot-mandrillgray-01.png} 359 | \includegraphics[width=0.45\paperwidth]{Screenshot-mandrillgrayMean-01.png} 360 | \end{center} 361 | \end{frame} 362 | 363 | \begin{frame}[fragile] 364 | \frametitle{Find All Other Exercises} 365 | \begin{itemize} 366 | \item Go to the binary directory 367 | \begin{verbatim} 368 | cd ~/bin/ITK-OpenCV-Bridge-Tutorial/Exercises 369 | \end{verbatim} 370 | \end{itemize} 371 | \end{frame} 372 | 373 | \begin{frame} 374 | \frametitle{Basic Filtering - Canny Filter} 375 | \framesubtitle{ITKIntroduction/exercise1/BasicImageFilteringITKAnswer2.cxx} 376 | \begin{itemize} 377 | \item Some filters expect specific pixel types 378 | \pause 379 | \item Canny Edge detection is an example 380 | \pause 381 | \item Here we Cast the image before Canny 382 | \pause 383 | \item Then we Cast/Rescale it after Canny 384 | \end{itemize} 385 | \end{frame} 386 | 387 | \begin{frame} 388 | \frametitle{Basic Filtering - Canny Filter} 389 | \framesubtitle{ITKIntroduction/exercise1/BasicImageFilteringITKAnswer2.cxx} 390 | \begin{itemize} 391 | \item Let's start with the relevant headers: 392 | \pause 393 | \lstlistingwithnumber{21}{23}{BasicImageFilteringITKAnswer2.cxx} 394 | \pause 395 | \item We then declare the relevant pixel types 396 | \pause 397 | \lstlistingwithnumber{34}{36}{BasicImageFilteringITKAnswer2.cxx} 398 | \pause 399 | \item Then we declare the relevant image types 400 | \pause 401 | \lstlistingwithnumber{38}{40}{BasicImageFilteringITKAnswer2.cxx} 402 | \end{itemize} 403 | \end{frame} 404 | 405 | \begin{frame} 406 | \frametitle{Basic Filtering - Canny Filter} 407 | \framesubtitle{ITKIntroduction/exercise1/BasicImageFilteringITKAnswer2.cxx} 408 | \begin{itemize} 409 | \item We declare the Casting filter and instantiate it: 410 | \pause 411 | \lstlistingwithnumber{52}{55}{BasicImageFilteringITKAnswer2.cxx} 412 | \pause 413 | \item We declare and instantiate the Canny filter: 414 | \pause 415 | \lstlistingwithnumber{58}{61}{BasicImageFilteringITKAnswer2.cxx} 416 | \pause 417 | \item and do the same for the RescaleIntensity filter: 418 | \pause 419 | \lstlistingwithnumber{64}{67}{BasicImageFilteringITKAnswer2.cxx} 420 | \end{itemize} 421 | \end{frame} 422 | 423 | \begin{frame} 424 | \frametitle{Basic Filtering - Canny Filter} 425 | \framesubtitle{ITKIntroduction/exercise1/BasicImageFilteringITKAnswer2.cxx} 426 | \begin{itemize} 427 | \item We connect the pipeline: 428 | \pause 429 | \lstlistingwithnumber{70}{73}{BasicImageFilteringITKAnswer2.cxx} 430 | \pause 431 | \item Set the parameters of the Canny Edge detection filter: 432 | \pause 433 | \lstlistingwithnumber{76}{78}{BasicImageFilteringITKAnswer2.cxx} 434 | \end{itemize} 435 | \end{frame} 436 | 437 | \begin{frame} 438 | \frametitle{Basic Filtering - Canny Filter} 439 | \framesubtitle{ITKIntroduction/exercise1/BasicImageFilteringITKAnswer2.cxx} 440 | \begin{itemize} 441 | \item Trigger the execution of the pipeline: 442 | \pause 443 | \lstlistingwithnumber{81}{89}{BasicImageFilteringITKAnswer2.cxx} 444 | \pause 445 | \item Note that the pipeline only runs when we call Update() 446 | \pause 447 | \item That's the point where we should catch exceptions 448 | \end{itemize} 449 | \end{frame} 450 | 451 | \begin{frame}[fragile] 452 | \frametitle{How to Run} 453 | \framesubtitle{/home/tutorial/bin/itkexercise1b} 454 | \begin{itemize} 455 | \item While in the binary directory: 456 | \begin{verbatim} 457 | /home/tutorial/bin/itkexercise1b 458 | \end{verbatim} 459 | \pause 460 | \item In the command line type: 461 | \begin{verbatim} 462 | ./BasicImageFilteringITKAnswer2 \ 463 | ~/data/mandrillgray.png \ 464 | ./mandrillgrayCanny.png \ 465 | 6 1 8 466 | \end{verbatim} 467 | \pause 468 | \item 6 = Variance for Gaussian 469 | \item 1 = Lower Threshold 470 | \item 8 = Upper Threshold 471 | \end{itemize} 472 | \end{frame} 473 | 474 | \begin{frame}[fragile] 475 | \frametitle{How to View the Result} 476 | \framesubtitle{Image viewing application ``eye of gnome'': eog} 477 | \begin{itemize} 478 | \item In the command line type: 479 | \begin{verbatim} 480 | eog ~/data/mandrillgray.jpg & 481 | eog ./mandrillgrayCanny.png & 482 | \end{verbatim} 483 | \end{itemize} 484 | \end{frame} 485 | 486 | \begin{frame}[fragile] 487 | \frametitle{Result of Canny Filter} 488 | \begin{center} 489 | \includegraphics[width=0.45\paperwidth]{Screenshot-mandrillgray-01.png} 490 | \includegraphics[width=0.45\paperwidth]{Screenshot-mandrillgrayCanny-01.png} 491 | \end{center} 492 | \end{frame} 493 | 494 | -------------------------------------------------------------------------------- /Documents/Tutorial/ITKOpenCVBridge.tex: -------------------------------------------------------------------------------- 1 | \section{ITK OpenCV Bridge} 2 | 3 | 4 | \centeredlargetext{white}{black}{ 5 | ITK OpenCV Bridge 6 | } 7 | 8 | \begin{frame} 9 | \frametitle{Introduction} 10 | \begin{itemize} 11 | \item ITK Module for working with other libraries 12 | \item Moving frame and/or video data between OpenCV and ITK 13 | \item Bring biomedical and computer vision folks together 14 | \item \url{https://github.com/itkvideo/ITK} 15 | \end{itemize} 16 | \end{frame} 17 | 18 | \begin{frame} 19 | \frametitle{Funding Source} 20 | \begin{itemize} 21 | \item Contract from the National Library of Medicine (HHSN276201000579P) 22 | \item Algorithms, Adapters \& Data Distribution Outreach 2010: 23 | Increasing the Impact of the Insight Toolkit (ITK) 24 | \end{itemize} 25 | \end{frame} 26 | 27 | \begin{frame} 28 | \frametitle{Design Choices} 29 | \begin{itemize} 30 | \item OpenCV users and ITK users should both be comfortable 31 | \item Image to image utility functions 32 | \item cv::Source to itk::VideoStream 33 | \item (Later) Focus on performance 34 | \end{itemize} 35 | \end{frame} 36 | 37 | \centeredlargetext{white}{black}{ 38 | Basic Image Filtering (Revisited) 39 | } 40 | 41 | \begin{frame} 42 | \frametitle{Include Header Files} 43 | \framesubtitle{ITKOpenCVBridge/exercise1/BasicFilteringITKOpenCVBridge.cxx} 44 | \begin{itemize} 45 | \item We include ITK and OpenCV headers (like before): 46 | \lstlistingwithnumber{20}{21}{BasicFilteringITKOpenCVBridge.cxx} 47 | \lstlistingwithnumber{23}{24}{BasicFilteringITKOpenCVBridge.cxx} 48 | \item We also need to include the bridge header: 49 | \lstlistingwithnumber{25}{25}{BasicFilteringITKOpenCVBridge.cxx} 50 | \end{itemize} 51 | \end{frame} 52 | 53 | \begin{frame} 54 | \frametitle{Basic Layout} 55 | \framesubtitle{ITKOpenCVBridge/exercise1/BasicFilteringITKOpenCVBridge.cxx} 56 | \begin{itemize} 57 | \item The basic layout of this file is the same as the OpenCV 58 | Examples: 59 | \lstlistingwithnumber{27}{35}{BasicFilteringITKOpenCVBridge.cxx} 60 | \lstlistingwithnumber{69}{84}{BasicFilteringITKOpenCVBridge.cxx} 61 | \end{itemize} 62 | \end{frame} 63 | 64 | \begin{frame} 65 | \frametitle{Adding ITK} 66 | \framesubtitle{ITKOpenCVBridge/exercise1/BasicFilteringITKOpenCVBridge.cxx} 67 | \begin{itemize} 68 | \item The type definitions should also be familiar from the ITK 69 | Material: 70 | \lstlistingwithnumber{38}{45}{BasicFilteringITKOpenCVBridge.cxx} 71 | \item However, notice the bridge class. It contains the conversion function 72 | between OpenCV and ITK. 73 | \lstlistingwithnumber{42}{42}{BasicFilteringITKOpenCVBridge.cxx} 74 | \end{itemize} 75 | \end{frame} 76 | 77 | \begin{frame} 78 | \frametitle{From OpenCV to ITK} 79 | \framesubtitle{ITKOpenCVBridge/exercise1/BasicFilteringITKOpenCVBridge.cxx} 80 | \begin{itemize} 81 | \item We call our conversion function to go from a cv::Mat to an 82 | itk::Image 83 | \lstlistingwithnumber{47}{48}{BasicFilteringITKOpenCVBridge.cxx} 84 | \end{itemize} 85 | \end{frame} 86 | 87 | \begin{frame} 88 | \frametitle{Filtering with ITK} 89 | \framesubtitle{ITKOpenCVBridge/exercise1/BasicFilteringITKOpenCVBridge.cxx} 90 | \begin{itemize} 91 | \item The median filtering is normal ITK code, but we do not connect our 92 | output to a writer 93 | \lstlistingwithnumber{49}{64}{BasicFilteringITKOpenCVBridge.cxx} 94 | \pause 95 | \item Instead, we set it to our conversion function 96 | \lstlistingwithnumber{66}{67}{BasicFilteringITKOpenCVBridge.cxx} 97 | \end{itemize} 98 | \end{frame} 99 | 100 | \begin{frame}[fragile] 101 | \frametitle{Running the Example} 102 | \framesubtitle{ITKOpenCVBridge/exercise1/BasicFilteringITKOpenCVBridge.cxx} 103 | \begin{itemize} 104 | \item Run the example with the following command 105 | \begin{verbatim} 106 | ./BasicFilteringITKOpenCVBridge \ 107 | ~/data/mandrillgray.png \ 108 | ./mandrillgrayMedian.png 109 | \end{verbatim} 110 | \end{itemize} 111 | \end{frame} 112 | 113 | \begin{frame} 114 | \frametitle{Viewing the Results} 115 | \framesubtitle{ITKOpenCVBridge/exercise1/BasicFilteringITKOpenCVBridge.cxx} 116 | \begin{itemize} 117 | \item Running the example the same way as before, we see a nicely 118 | median-filtered image. 119 | \end{itemize} 120 | \begin{columns}[c] 121 | \column{0.33\textwidth} 122 | \begin{center} 123 | \includegraphics[width=1\textwidth]{mandrilgray.png} \\ 124 | Original 125 | \end{center} 126 | \column{0.33\textwidth} 127 | \begin{center} 128 | \includegraphics[width=1\textwidth]{OpenCVITKex1.png} \\ 129 | Median Filter 130 | \end{center} 131 | \end{columns} 132 | \pause 133 | \begin{itemize} 134 | \item Now, the fun part. Let's modify our example to use Curvature Flow, an 135 | anisotropic diffusion filter built into ITK. 136 | \end{itemize} 137 | \end{frame} 138 | 139 | \begin{frame} 140 | \begin{itemize} 141 | \frametitle{Exercise 1} 142 | \framesubtitle{ITKOpenCVBridge/exercise1/BasicFilteringITKOpenCVBridge.cxx} 143 | \item Hint 1: Curvature Flow requires {\tt float} as the output pixel 144 | type. 145 | \pause 146 | \item Hint 2: Curvature Flow does not take a radius parameter. It's 147 | salient functions are: 148 | \lstlistingwithnumber{50}{51}{BasicFilteringITKOpenCVBridgeAnswer.cxx} 149 | \end{itemize} 150 | \end{frame} 151 | 152 | \begin{frame} 153 | \begin{itemize} 154 | \frametitle{Exercise 1: Answer} 155 | \framesubtitle{ITKOpenCVBridge/exercise1/BasicFilteringITKOpenCVBridgeAnswer.cxx} 156 | \item First, change the included filter 157 | \lstlistingwithnumber{24}{24}{BasicFilteringITKOpenCVBridgeAnswer.cxx} 158 | \pause 159 | \item The type definitions also need to change to reflect the new 160 | filter and output image types. 161 | \lstlistingwithnumber{37}{44}{BasicFilteringITKOpenCVBridgeAnswer.cxx} 162 | \end{itemize} 163 | \end{frame} 164 | 165 | \begin{frame} 166 | \begin{itemize} 167 | \frametitle{Exercise 1: Answer} 168 | \framesubtitle{ITKOpenCVBridge/exercise1/BasicFilteringITKOpenCVBridgeAnswer.cxx} 169 | \item The semantics of calling the filter also has to change: 170 | \lstlistingwithnumber{50}{51}{BasicFilteringITKOpenCVBridgeAnswer.cxx} 171 | \pause 172 | \item That's it! Now you're using a ``better'' blurring scheme. 173 | \end{itemize} 174 | \end{frame} 175 | 176 | \begin{frame} 177 | \begin{itemize} 178 | \frametitle{Exercise 1: Answer} 179 | \framesubtitle{ITKOpenCVBridge/exercise1/BasicFilteringITKOpenCVBridgeAnswer.cxx} 180 | \item The final pipeline should look like this: 181 | \lstlistingwithnumber{35}{35}{BasicFilteringITKOpenCVBridgeAnswer.cxx} 182 | \lstlistingwithnumber{46}{62}{BasicFilteringITKOpenCVBridgeAnswer.cxx} 183 | \end{itemize} 184 | \end{frame} 185 | 186 | \begin{frame}[fragile] 187 | \frametitle{Running the Answer} 188 | \framesubtitle{ITKOpenCVBridge/exercise1/BasicFilteringITKOpenCVBridgeAnswer.cxx} 189 | \begin{itemize} 190 | \item Run the answer with the following command 191 | \begin{verbatim} 192 | ./BasicFilteringITKOpenCVBridgeAnswer \ 193 | ~/data/mandrillgray.png \ 194 | ./mandrillgrayCurvatureFlow.png 195 | \end{verbatim} 196 | \end{itemize} 197 | \end{frame} 198 | 199 | \begin{frame} 200 | \begin{itemize} 201 | \frametitle{Exercise 1: Answer} 202 | \framesubtitle{ITKOpenCVBridge/exercise1/BasicFilteringITKOpenCVBridgeAnswer.cxx} 203 | \item The results should look like this: 204 | \end{itemize} 205 | \begin{columns}[c] 206 | \column{0.33\textwidth} 207 | \begin{center} 208 | \includegraphics[width=1\textwidth]{mandrilgray.png} \\ 209 | Original 210 | \end{center} 211 | \column{0.33\textwidth} 212 | \begin{center} 213 | \includegraphics[width=1\textwidth]{OpenCVITKex1.png} \\ 214 | Median Filter 215 | \end{center} 216 | \column{0.33\textwidth} 217 | \begin{center} 218 | \includegraphics[width=1\textwidth]{OpenCVITKex1-ans.png} \\ 219 | Curvature Flow 220 | \end{center} 221 | \end{columns} 222 | \end{frame} 223 | 224 | \centeredlargetext{white}{black}{ 225 | Basic Video Filtering (Revisited) 226 | } 227 | 228 | \begin{frame} 229 | \frametitle{Basic Layout} 230 | \framesubtitle{ITKOpenCVBridge/exercise2/BasicVideoFilteringITKOpenCVBridge.cxx} 231 | \begin{itemize} 232 | \item The basic layout of this file is the same as the OpenCV Video 233 | Examples: 234 | \item There are three functions as before. 235 | \lstlistingwithnumber{28}{28}{BasicVideoFilteringITKOpenCVBridge.cxx} 236 | \lstlistingwithnumber{63}{63}{BasicVideoFilteringITKOpenCVBridge.cxx} 237 | \lstlistingwithnumber{89}{89}{BasicVideoFilteringITKOpenCVBridge.cxx} 238 | \pause 239 | \item We only need to modify {\tt processFrame} to incorporate ITK. 240 | \end{itemize} 241 | \end{frame} 242 | 243 | \begin{frame} 244 | \frametitle{Filtering with ITK} 245 | \framesubtitle{ITKOpenCVBridge/exercise2/BasicVideoFilteringITKOpenCVBridge.cxx} 246 | \begin{itemize} 247 | \item The median filtering is again normal ITK code. 248 | \lstlistingwithnumber{28}{29}{BasicVideoFilteringITKOpenCVBridge.cxx} 249 | \lstlistingwithnumber{39}{60}{BasicVideoFilteringITKOpenCVBridge.cxx} 250 | \end{itemize} 251 | \end{frame} 252 | 253 | \begin{frame}[fragile] 254 | \frametitle{Running the Example} 255 | \framesubtitle{ITKOpenCVBridge/exercise2/BasicVideoFilteringITKOpenCVBridge.cxx} 256 | \begin{itemize} 257 | \item Run the example with the following command 258 | \begin{verbatim} 259 | ./BasicVideoFilteringITKOpenCVBridge \ 260 | ~/data/Walk1.mpg \ 261 | ./Walk1Median.mpg 262 | \end{verbatim} 263 | \end{itemize} 264 | \end{frame} 265 | 266 | \begin{frame} 267 | \begin{itemize} 268 | \frametitle{Exercise 2} 269 | \framesubtitle{ITKOpenCVBridge/exercise2/BasicVideoFilteringITKOpenCVBridge.cxx} 270 | \item Let's modify this example to use the same canny edge detection 271 | from the ITK examples 272 | \pause 273 | \item Hint 1: You should use the following function instead of ITK's 274 | cast image filter for producing output 275 | \lstlistingwithnumber{72}{72}{BasicVideoFilteringITKOpenCVBridgeAnswer.cxx} 276 | \pause 277 | \item Hint 2: You should only have to modify {\tt processFrame} 278 | \end{itemize} 279 | \end{frame} 280 | 281 | \begin{frame} 282 | \begin{itemize} 283 | \frametitle{Exercise 2: Answer} 284 | \framesubtitle{ITKOpenCVBridge/exercise2/BasicVideoFilteringITKOpenCVBridgeAnswer.cxx} 285 | \item You should now have some extra typedefs: 286 | \lstlistingwithnumber{39}{44}{BasicVideoFilteringITKOpenCVBridgeAnswer.cxx} 287 | \end{itemize} 288 | \end{frame} 289 | 290 | \begin{frame} 291 | \begin{itemize} 292 | \frametitle{Exercise 2: Answer} 293 | \framesubtitle{ITKOpenCVBridge/exercise2/BasicVideoFilteringITKOpenCVBridgeAnswer.cxx} 294 | \item Your new ITK pipeline will look like this: 295 | \lstlistingwithnumber{46}{67}{BasicVideoFilteringITKOpenCVBridgeAnswer.cxx} 296 | \end{itemize} 297 | \end{frame} 298 | 299 | \begin{frame} 300 | \begin{itemize} 301 | \frametitle{Exercise 2: Answer} 302 | \framesubtitle{ITKOpenCVBridge/exercise2/BasicVideoFilteringITKOpenCVBridgeAnswer.cxx} 303 | \item With the following code for output purposes: 304 | \lstlistingwithnumber{69}{74}{BasicVideoFilteringITKOpenCVBridgeAnswer.cxx} 305 | \end{itemize} 306 | \end{frame} 307 | 308 | \begin{frame}[fragile] 309 | \frametitle{Running the Answer} 310 | \framesubtitle{ITKOpenCVBridge/exercise2/BasicVideoFilteringITKOpenCVBridgeAnswer.cxx} 311 | \begin{itemize} 312 | \item Run the answer with the following command 313 | \begin{verbatim} 314 | ./BasicVideoFilteringITKOpenCVBridgeAnswer \ 315 | ~/data/Walk1.mpg \ 316 | ./Walk1Edges.mpg 317 | \end{verbatim} 318 | \end{itemize} 319 | \end{frame} -------------------------------------------------------------------------------- /Documents/Tutorial/ITKOpenCVBridgeTutorial.tex: -------------------------------------------------------------------------------- 1 | %\documentclass[handout,18pt]{beamer} 2 | \documentclass[18pt]{beamer} 3 | \usetheme{Madrid} 4 | 5 | \usepackage{graphics} 6 | \usepackage{listings} 7 | \usepackage{url} 8 | 9 | \definecolor{listcomment}{rgb}{0.0,0.0,1.0} 10 | \definecolor{listkeyword}{rgb}{0.5,0.0,0.0} 11 | \definecolor{listidentifier}{rgb}{0.0,0.3,0.0} 12 | \definecolor{listdirective}{rgb}{0.5,0.0,1.0} 13 | \definecolor{liststring}{rgb}{1.0,0.0,1.0} 14 | \definecolor{listnumbers}{gray}{0.65} 15 | \definecolor{listlightgray}{gray}{0.955} 16 | \definecolor{listwhite}{gray}{1.0} 17 | \definecolor{listbackground}{rgb}{0.9,0.9,1.0} 18 | 19 | 20 | \lstset{language=C++} 21 | \lstset{numbers=left} 22 | \lstset{frame=tb} 23 | \lstset{xleftmargin=0.05\linewidth} 24 | \lstset{backgroundcolor=\color{listbackground}} 25 | \lstset{basicstyle=\tiny} 26 | \lstset{keywordstyle=\color{listkeyword}\bfseries} 27 | \lstset{identifierstyle=\color{listidentifier}} 28 | \lstset{directivestyle=\color{listdirective}} 29 | \lstset{commentstyle=\color{listcomment}} 30 | \lstset{stringstyle=\ttfamily\color{liststring}} 31 | \lstset{showstringspaces=false} 32 | 33 | \newcommand{\lstlistingwithnumber}[3]{ 34 | \begin{center} 35 | \lstinputlisting[linerange={#1-#2},firstnumber=#1,numbers=left]{#3} 36 | \end{center} 37 | } 38 | 39 | \newcommand{\centeredlargetext}[3]{ 40 | { 41 | \setbeamertemplate{navigation symbols}{} 42 | \setbeamercolor{background canvas}{bg={#1}} 43 | \color{#2} 44 | \begin{frame}[plain] 45 | \fontsize{36pt}{36pt}\selectfont 46 | \center 47 | \begin{center} 48 | {#3} 49 | \end{center} 50 | \end{frame} 51 | }} 52 | 53 | \newcommand{\centeredhugetext}[3]{ 54 | { 55 | \setbeamertemplate{navigation symbols}{} 56 | \setbeamercolor{background canvas}{bg={#1}} 57 | \fontsize{72pt}{72pt}\selectfont 58 | \color{#2} 59 | \begin{frame}[plain] 60 | \center 61 | \begin{center} 62 | {#3} 63 | \end{center} 64 | \end{frame} 65 | }} 66 | 67 | 68 | \begin{document} 69 | 70 | \title[ITK - OpenCV]{ITK Meets OpenCV} 71 | \subtitle[ITK-OpenCV]{A New Open Source Software Resource for CV} 72 | \institute[Insight Software Consortium]{Insight Software Consortium} 73 | \date[June 2011]{June 2011} 74 | 75 | \begin{frame} 76 | \titlepage 77 | \begin{tabular}{cp{.15\textwidth}p{.15\textwidth}p{.15\textwidth}p{.15\textwidth}p{.15\textwidth}c} 78 | & 79 | \centering\includegraphics[height=2cm]{ibanez} & 80 | \centering\includegraphics[height=2cm]{reynolds} & 81 | \centering\includegraphics[height=2cm]{hart} & 82 | \centering\includegraphics[height=2cm]{leotta} & 83 | \centering\includegraphics[height=2cm]{perera} & \\ 84 | & 85 | \centering{}Luis \\Ib\'a\~nez & 86 | \centering{}Patrick \\Reynolds & 87 | \centering{}Gabe \\Hart & 88 | \centering{}Matt \\Leotta & 89 | \centering{}Amitha \\Perera & \\ 90 | \end{tabular} 91 | \end{frame} 92 | 93 | 94 | { 95 | \setbeamertemplate{navigation symbols}{} 96 | \begin{frame}[plain] 97 | \center 98 | \begin{center} 99 | This presentation is copyrighted by\\ 100 | The \textbf{Insight Software Consortium}\\ 101 | \bigskip 102 | distributed under the\\ 103 | \textbf{Creative Commons by Attribution License 3.0}\\ 104 | \url{http://creativecommons.org/licenses/by/3.0}\\ 105 | \end{center} 106 | \end{frame} 107 | } 108 | 109 | 110 | %\begin{frame} 111 | % \tableofcontents 112 | %\end{frame} 113 | 114 | 115 | \begin{frame} 116 | \frametitle{What this Tutorial is about} 117 | \begin{itemize} 118 | \item Introduce the Insight Toolkit (ITK) to Computer Vision 119 | \item Hands-on code examples as a starting point for using ITK 120 | \item Preview of the upcoming video extensions to ITK 121 | \item Raffle of ASUS Eee Pad Transformer 122 | \end{itemize} 123 | \end{frame} 124 | 125 | \begin{frame} 126 | \frametitle{Who is Kitware} 127 | \begin{center} 128 | \includegraphics[width=.8\textwidth]{KitwareFocusAreas} 129 | \end{center} 130 | \end{frame} 131 | 132 | \begin{frame} 133 | \frametitle{Program} 134 | 135 | %\begin{itemize} 136 | %\item Virtual Machines Preparation (10min) 137 | %\item ITK Overview (30min) 138 | %\item \textcolor{gray}{Short Break (10min)} 139 | %\item Software Environment (10min) 140 | %\item ITK Introduction (30min) 141 | %\item \textcolor{gray}{Coffee Break (30min)} 142 | %\item OpenCV Introduction (30min) 143 | %\item OpenCV+ITK (30min) 144 | %\item \textcolor{gray}{Short Break (10min)} 145 | %\item ITK Video Filters (40min) 146 | %\item Wrap-up (10min) 147 | %\end{itemize} 148 | 149 | \begin{tabular}{ll} 150 | 1:35--1:40 & Virtual Machine Preparation \\ 151 | 1:40--2:10 & ITK Overview \\ 152 | 2:10--2:20 & Software Environment \\ 153 | \textcolor{gray}{2:20--2:30} & \textcolor{gray}{Break} \\ 154 | 2:30--3:00 & ITK Introduction \\ 155 | \textcolor{gray}{3:00--3:30} & \textcolor{gray}{Coffee Break} \\ 156 | 3:30--4:00 & OpenCV Introduction \\ 157 | 4:00--4:30 & OpenCV+ITK \\ 158 | \textcolor{gray}{4:30--4:40} & \textcolor{gray}{Break} \\ 159 | 4:40--5:15 & ITK Video Filters \\ 160 | 5:15--5:30 & Wrap-up 161 | \end{tabular} 162 | 163 | \end{frame} 164 | 165 | 166 | \include{SoftwarePreparation1} 167 | 168 | \include{ITKOverview} 169 | 170 | \include{SoftwarePreparation2} 171 | 172 | \include{SoftwareEnvironment} 173 | 174 | \include{ITKIntroduction} 175 | 176 | \include{OpenCVIntroduction} 177 | 178 | \include{ITKOpenCVBridge} 179 | 180 | \include{ITKVideoFilters} 181 | 182 | \begin{frame} 183 | \frametitle{Wrap-up} 184 | \begin{itemize} 185 | \item Send us feedback (good or bad) \\ 186 | luis.ibanez@kitware.com \\ 187 | patrick.reynolds@kitware.com \\ 188 | gabe.hart@kitware.com \\ 189 | matt.leotta@kitware.com \\ 190 | amitha.perera@kitware.com 191 | \item Raffle\\ 192 | \includegraphics[height=1.5in]{asus} 193 | \end{itemize} 194 | \end{frame} 195 | 196 | 197 | \end{document} 198 | -------------------------------------------------------------------------------- /Documents/Tutorial/ITKOverview.tex: -------------------------------------------------------------------------------- 1 | \section{ITK Overview} 2 | 3 | 4 | \centeredlargetext{white}{black}{ 5 | ITK Overview 6 | } 7 | 8 | \begin{frame}[fragile] 9 | \frametitle{The Insight Toolkit (ITK)} 10 | \begin{center} 11 | \includegraphics[width=0.5\paperwidth]{itkLogo.png} 12 | \end{center} 13 | \end{frame} 14 | 15 | \begin{frame} 16 | \frametitle{What is ITK ?} 17 | \begin{itemize} 18 | \item C++ Library 19 | \pause 20 | \item Open Source (Apache 2.0 License) 21 | \pause 22 | \item Generic Programming / C++ Templates 23 | \pause 24 | \item Image Processing 25 | \pause 26 | \item Image Segmentation 27 | \pause 28 | \item Image Registration 29 | \end{itemize} 30 | \end{frame} 31 | 32 | 33 | \begin{frame} 34 | \frametitle{What ITK is not ?} 35 | \begin{itemize} 36 | \item No Visualization 37 | \pause 38 | \item No GUI 39 | \end{itemize} 40 | \end{frame} 41 | 42 | \begin{frame} 43 | \frametitle{Funding} 44 | \begin{itemize} 45 | \item Funded (mostly) by the US National Library of Medicine 46 | \pause 47 | \item With contributions from 48 | \begin{itemize} 49 | \item National Institute of Dental and Craniofacial Research 50 | \item National Science Foundation 51 | \item National Eye Institute 52 | \item National Institute of Neurological Disorders and Stroke 53 | \item National Institute of Mental Health 54 | \item National Institute on Deafness and Other Communication Disorders 55 | \item National Cancer Institute 56 | \end{itemize} 57 | \end{itemize} 58 | \end{frame} 59 | 60 | \begin{frame} 61 | \frametitle{History} 62 | \begin{itemize} 63 | \item Started in 2000 64 | \pause 65 | \item Developed by Companies and Universities 66 | \begin{itemize} 67 | \item GE Corporate Research 68 | \item Insightful 69 | \item Kitware 70 | \item UNC Chapel Hill 71 | \item University of Pennsylvania 72 | \item University of Utah 73 | \end{itemize} 74 | \end{itemize} 75 | \end{frame} 76 | 77 | \begin{frame} 78 | \frametitle{History} 79 | \begin{itemize} 80 | \item Recent contributions by a larger community 81 | \begin{itemize} 82 | \item Harvard - Brigham and Women's Hospital 83 | \item University of Iowa 84 | \item Georgetown University 85 | \item INRA - France 86 | \item German Cancer Research Center 87 | \item \ldots and many others \ldots 88 | \end{itemize} 89 | \end{itemize} 90 | \end{frame} 91 | 92 | \begin{frame} 93 | \frametitle{Project Profile} 94 | \begin{itemize} 95 | \item Total lines of code: 1,886,674 96 | \item Active developers: 56 (past 12 months) 97 | \item Total developers: 146 (full history of the project) 98 | \item Top 2\% largest open source teams in the world 99 | \item Estimated cost of development: \$34.5 M\footnote{Ohloh: \url{http://www.ohloh.net/p/itk}} 100 | \end{itemize} 101 | \end{frame} 102 | 103 | \begin{frame} 104 | \frametitle{Funding} 105 | \begin{itemize} 106 | \item First 10 years of development = \$15M 107 | \pause 108 | \item Refactoring of ITKv4 in 2011 = \$5M 109 | \pause 110 | \item Yearly maintenance supported by NLM 111 | \end{itemize} 112 | \end{frame} 113 | 114 | 115 | \begin{frame} 116 | \frametitle{ITK by the Numbers} 117 | \begin{itemize} 118 | \item Community Size 119 | \pause 120 | \begin{itemize} 121 | \item Users Mailing List 122 | \pause 123 | \begin{itemize} 124 | \item 2,071 Subscribers 125 | \item About 400 emails/month 126 | \end{itemize} 127 | \end{itemize} 128 | \pause 129 | \begin{itemize} 130 | \item Developers Mailing List 131 | \begin{itemize} 132 | \item 475 Subscribers 133 | \item About 350 emails/month 134 | \end{itemize} 135 | \end{itemize} 136 | \pause 137 | \begin{itemize} 138 | \item 4,800 Downloads/month 139 | \pause 140 | \begin{itemize} 141 | \item from 116 countries 142 | \end{itemize} 143 | \end{itemize} 144 | \end{itemize} 145 | \end{frame} 146 | 147 | \begin{frame} 148 | \frametitle{What ITK has to offer} 149 | \begin{itemize} 150 | \item Image Processing 151 | \pause 152 | \item Segmentation 153 | \pause 154 | \item Registration 155 | \end{itemize} 156 | \end{frame} 157 | 158 | \begin{frame} 159 | \frametitle{Image Processing} 160 | \begin{itemize} 161 | \item Anisotropic Diffusion 162 | \pause 163 | \item Mathematical Morphology 164 | \pause 165 | \item Anti-Aliasing 166 | \pause 167 | \item Resampling 168 | \pause 169 | \item Distance Maps 170 | \pause 171 | \item Bias Correction 172 | \pause 173 | \item Diffussion Tensor Imaging 174 | \pause 175 | \item Hessians, Laplacian, Gaussians 176 | \pause 177 | \item Hough, Canny 178 | \end{itemize} 179 | \end{frame} 180 | 181 | \begin{frame} 182 | \frametitle{Image Segmentation} 183 | \begin{itemize} 184 | \item Level Sets 185 | \pause 186 | \item Region Growing 187 | \pause 188 | \item Watersheds 189 | \pause 190 | \item Label Voting 191 | \pause 192 | \item Connected Components 193 | \pause 194 | \item Label Image Processing 195 | \pause 196 | \item Deformable Models 197 | \pause 198 | \item Cellular Models 199 | \pause 200 | \item Statistical Classification 201 | \begin{itemize} 202 | \item K-Means 203 | \item Gaussian Mixture Models 204 | \item Markov Random Fields 205 | \end{itemize} 206 | \end{itemize} 207 | \end{frame} 208 | 209 | \begin{frame} 210 | \frametitle{Image Registration} 211 | \begin{itemize} 212 | \item Generic Framework 213 | \pause 214 | \begin{itemize} 215 | \item Image Metrics 216 | \item Interpolators 217 | \item Transforms 218 | \item Optimizers 219 | \end{itemize} 220 | \pause 221 | \item Deformable Registration 222 | \pause 223 | \begin{itemize} 224 | \item BSplines (Free-form) 225 | \item Demons 226 | \item Diffeomorphic Demons 227 | \item PDE Solving 228 | \end{itemize} 229 | \pause 230 | \item Multi-Resolution 231 | \pause 232 | \item Multi-Modality 233 | \end{itemize} 234 | \end{frame} 235 | 236 | \begin{frame} 237 | \frametitle{The Insight Journal} 238 | \framesubtitle{New Algorithms Every Week\ldots} 239 | \begin{itemize} 240 | \item 2,129 Registered Users 241 | \pause 242 | \item 472 Publications 243 | \pause 244 | \item 834 Open Reviews 245 | \pause 246 | \item Open Access Journal 247 | \pause 248 | \item Reproducible Research (RR) 249 | \end{itemize} 250 | \end{frame} 251 | 252 | -------------------------------------------------------------------------------- /Documents/Tutorial/ITKVideoFilters.tex: -------------------------------------------------------------------------------- 1 | \section{ITK Video Filters} 2 | 3 | 4 | \centeredlargetext{white}{black}{ 5 | ITK Video Filters 6 | } 7 | 8 | %%%% 9 | % Introduction Page 10 | %%%% 11 | \begin{frame} 12 | \frametitle{Introduction} 13 | \begin{itemize} 14 | \item Support video processing natively in ITK 15 | \item Standard framework for multi-frame filters 16 | \item Use ITK's library of image filters in video context 17 | \end{itemize} 18 | \end{frame} 19 | 20 | 21 | %%%% 22 | % Code walkthrough 23 | %%%% 24 | { 25 | \setbeamertemplate{navigation symbols}{} 26 | \begin{frame}[fragile] 27 | \frametitle{Video Filtering - Median Filter} 28 | \framesubtitle{ITKVideoPipeline/exercise1/ITKVideoSingleFrameFilters.cxx} 29 | 30 | \begin{itemize} 31 | \item Video data structure 32 | \lstlistingwithnumber{21}{21}{ITKVideoSingleFrameFilters.cxx} 33 | \pause 34 | 35 | \item Video file reader and writer 36 | \item Use OpenCV for video IO 37 | \lstlistingwithnumber{24}{26}{ITKVideoSingleFrameFilters.cxx} 38 | \pause 39 | 40 | \item Median image filter 41 | \item Image filter $\rightarrow$ video filter wrapper 42 | \lstlistingwithnumber{22}{23}{ITKVideoSingleFrameFilters.cxx} 43 | \end{itemize} 44 | \end{frame} 45 | } 46 | 47 | { 48 | \setbeamertemplate{navigation symbols}{} 49 | \begin{frame}[fragile] 50 | \frametitle{Video Filtering - Median Filter} 51 | \framesubtitle{ITKVideoPipeline/exercise1/ITKVideoSingleFrameFilters.cxx} 52 | \begin{itemize} 53 | \item Types for data structures 54 | \lstlistingwithnumber{36}{39}{ITKVideoSingleFrameFilters.cxx} 55 | \pause 56 | 57 | \item Types reader and writer 58 | \lstlistingwithnumber{41}{42}{ITKVideoSingleFrameFilters.cxx} 59 | \pause 60 | 61 | \item Types for video median filter 62 | \item Use image filter type to define video filter type 63 | \lstlistingwithnumber{43}{45}{ITKVideoSingleFrameFilters.cxx} 64 | \end{itemize} 65 | \end{frame} 66 | } 67 | 68 | { 69 | \setbeamertemplate{navigation symbols}{} 70 | \begin{frame}[fragile] 71 | \frametitle{Video Filtering - Median Filter} 72 | \framesubtitle{ITKVideoPipeline/exercise1/ITKVideoSingleFrameFilters.cxx} 73 | \begin{itemize} 74 | \item Create reader and writer 75 | \lstlistingwithnumber{47}{48}{ITKVideoSingleFrameFilters.cxx} 76 | \pause 77 | 78 | \item Create image filter and video median filters 79 | \lstlistingwithnumber{49}{50}{ITKVideoSingleFrameFilters.cxx} 80 | \end{itemize} 81 | \end{frame} 82 | } 83 | 84 | { 85 | \setbeamertemplate{navigation symbols}{} 86 | \begin{frame}[fragile] 87 | \frametitle{Video Filtering - Median Filter} 88 | \framesubtitle{ITKVideoPipeline/exercise1/ITKVideoSingleFrameFilters.cxx} 89 | \begin{itemize} 90 | \item Set up reader and writer 91 | \item Tell ITK that we're using OpenCV for IO 92 | \lstlistingwithnumber{52}{54}{ITKVideoSingleFrameFilters.cxx} 93 | \pause 94 | 95 | \item Set up radius for (image) median filter 96 | \item Set video filter wrapper to use image median filter internally 97 | \lstlistingwithnumber{56}{60}{ITKVideoSingleFrameFilters.cxx} 98 | \end{itemize} 99 | \end{frame} 100 | } 101 | 102 | { 103 | \setbeamertemplate{navigation symbols}{} 104 | \begin{frame}[fragile] 105 | \frametitle{Video Filtering - Median Filter} 106 | \framesubtitle{ITKVideoPipeline/exercise1/ITKVideoSingleFrameFilters.cxx} 107 | \begin{itemize} 108 | \item Connect the pipeline 109 | \item reader $\rightarrow$ videoFilter $\rightarrow$ writer 110 | \lstlistingwithnumber{62}{63}{ITKVideoSingleFrameFilters.cxx} 111 | \pause 112 | 113 | \item Try calling Update() to process the entire video 114 | \lstlistingwithnumber{65}{73}{ITKVideoSingleFrameFilters.cxx} 115 | \end{itemize} 116 | \end{frame} 117 | } 118 | 119 | 120 | %%%% 121 | % Exercise 1 122 | %%%% 123 | { 124 | \setbeamertemplate{navigation symbols}{} 125 | \begin{frame}[fragile] 126 | \frametitle{Exercise 1} 127 | \framesubtitle{Replace median filter with curvature flow filter} 128 | \begin{itemize} 129 | \item Hint 1: Curvature Flow requires {\tt float} as the pixel 130 | type for output. 131 | \pause 132 | 133 | \item Hint 2: OpenCV uses ffmpeg which requires {\tt unsigned char} 134 | as the pixel type for writing. 135 | \pause 136 | 137 | \item Hint 3: Curvature Flow does not take a radius parameter. It's 138 | salient functions are: 139 | \lstlistingwithnumber{70}{71}{ITKVideoSingleFrameFiltersAnswer.cxx} 140 | \pause 141 | 142 | \item Hint 4: To use an image filter in a video pipeline use 143 | {\tt ImageFilterToVideoFilterWrapper} 144 | \end{itemize} 145 | \end{frame} 146 | } 147 | 148 | { 149 | \setbeamertemplate{navigation symbols}{} 150 | \begin{frame}[fragile] 151 | \frametitle{Exercise 1: Answer} 152 | \framesubtitle{Replace median filter with curvature flow filter} 153 | \begin{itemize} 154 | \item Include curvature and cast image filters 155 | \lstlistingwithnumber{22}{23}{ITKVideoSingleFrameFiltersAnswer.cxx} 156 | \pause 157 | 158 | \item Re-define types using seperate IO and Real pixel types 159 | \lstlistingwithnumber{37}{43}{ITKVideoSingleFrameFiltersAnswer.cxx} 160 | \end{itemize} 161 | \end{frame} 162 | } 163 | 164 | { 165 | \setbeamertemplate{navigation symbols}{} 166 | \begin{frame}[fragile] 167 | \frametitle{Exercise 1: Answer} 168 | \framesubtitle{Replace median filter with curvature flow filter} 169 | \begin{itemize} 170 | \item Define cast filter to convert from Real to IO pixel type 171 | \lstlistingwithnumber{47}{50}{ITKVideoSingleFrameFiltersAnswer.cxx} 172 | \pause 173 | 174 | \item Replace median filter with curvature flow filter 175 | \item Use Real pixel type for output 176 | \lstlistingwithnumber{51}{54}{ITKVideoSingleFrameFiltersAnswer.cxx} 177 | \end{itemize} 178 | \end{frame} 179 | } 180 | 181 | { 182 | \setbeamertemplate{navigation symbols}{} 183 | \begin{frame}[fragile] 184 | \frametitle{Exercise 1: Answer} 185 | \framesubtitle{Replace median filter with curvature flow filter} 186 | \begin{itemize} 187 | \item Set up video cast filter 188 | \lstlistingwithnumber{68}{68}{ITKVideoSingleFrameFiltersAnswer.cxx} 189 | \pause 190 | 191 | \item Set up curvature flow filter 192 | \lstlistingwithnumber{70}{72}{ITKVideoSingleFrameFiltersAnswer.cxx} 193 | \pause 194 | 195 | \item Connect the pipeline 196 | \item reader $\rightarrow$ curvature 197 | flow $\rightarrow$ output caster $\rightarrow$ writer 198 | \lstlistingwithnumber{74}{76}{ITKVideoSingleFrameFiltersAnswer.cxx} 199 | \end{itemize} 200 | \end{frame} 201 | } 202 | 203 | { 204 | \setbeamertemplate{navigation symbols}{} 205 | \begin{frame}[fragile] 206 | \frametitle{Running the Example} 207 | \framesubtitle{/home/tutorial/bin/ITK-OpenCV-Bridge-Tutorial/Exercises/ITKVideoPipeline} 208 | \begin{itemize} 209 | \item Run the example with the following command 210 | \begin{verbatim} 211 | ./exercise1/ITKVideoSingleFrameFilters \ 212 | ~/data/Walk1_short.avi \ 213 | ./Walk1_short_median.avi 214 | \end{verbatim} 215 | \end{itemize} 216 | \end{frame} 217 | } 218 | 219 | 220 | %%%% 221 | % Exercise 2 222 | %%%% 223 | { 224 | \setbeamertemplate{navigation symbols}{} 225 | \begin{frame}[fragile] 226 | \frametitle{Exercise 2} 227 | \framesubtitle{Compute frame differences after diffusion} 228 | \begin{itemize} 229 | \item Start with solution to Exercise 1 (ITKVideoMultiFrameFilters.cxx) 230 | \pause 231 | 232 | \item Hint 1: Use FrameDifferenceVideoFilter 233 | \pause 234 | 235 | \item Hint 2: Difference filter's important parameter is: 236 | \lstlistingwithnumber{73}{73}{ITKVideoMultiFrameFiltersAnswer.cxx} 237 | \item This sets the spacing of the frames to be differenced. Setting 238 | it to 1 means adjacent frames will be used. 239 | \end{itemize} 240 | \end{frame} 241 | } 242 | 243 | { 244 | \setbeamertemplate{navigation symbols}{} 245 | \begin{frame}[fragile] 246 | \frametitle{Exercise 2: Answer} 247 | \framesubtitle{Compute frame differences after diffusion} 248 | \begin{itemize} 249 | \item Include frame difference filter 250 | \lstlistingwithnumber{25}{25}{ITKVideoMultiFrameFiltersAnswer.cxx} 251 | \pause 252 | 253 | \item Define type for frame difference filter 254 | \item Since this is a native video filter, no wrapper is necessary 255 | \lstlistingwithnumber{57}{58}{ITKVideoMultiFrameFiltersAnswer.cxx} 256 | \pause 257 | 258 | \item Create frame difference filter 259 | \lstlistingwithnumber{66}{67}{ITKVideoMultiFrameFiltersAnswer.cxx} 260 | \end{itemize} 261 | \end{frame} 262 | } 263 | 264 | { 265 | \setbeamertemplate{navigation symbols}{} 266 | \begin{frame}[fragile] 267 | \frametitle{Exercise 2: Answer} 268 | \framesubtitle{Compute frame differences after diffusion} 269 | \begin{itemize} 270 | \item Set the frame offset to 1 271 | \lstlistingwithnumber{73}{73}{ITKVideoMultiFrameFiltersAnswer.cxx} 272 | \pause 273 | 274 | \item Connect the pipeline 275 | \item reader $\rightarrow$ curvature flow $\rightarrow$ output caster 276 | $\rightarrow$ frame differ $\rightarrow$ writer 277 | \lstlistingwithnumber{81}{84}{ITKVideoMultiFrameFiltersAnswer.cxx} 278 | \end{itemize} 279 | \end{frame} 280 | } 281 | 282 | { 283 | \setbeamertemplate{navigation symbols}{} 284 | \begin{frame}[fragile] 285 | \frametitle{Running the Answer} 286 | \framesubtitle{/home/tutorial/bin/ITK-OpenCV-Bridge-Tutorial/Exercises/ITKVideoPipeline} 287 | \begin{itemize} 288 | \item Run the example with the following command 289 | \begin{verbatim} 290 | ./exercise2/ITKVideoMultiFrameFiltersAnswer \ 291 | ~/data/Walk1_short.avi \ 292 | ./Walk1_short_diff.avi 293 | \end{verbatim} 294 | 295 | \item Extra Credit: Add a threshold to the difference output to supress 296 | background noise 297 | \item {\footnotesize ITKVideoPipeline/exercise1/ITKVideoMultiFrameFiltersAnswer2.cxx} 298 | \end{itemize} 299 | \end{frame} 300 | } 301 | -------------------------------------------------------------------------------- /Documents/Tutorial/OpenCVIntroduction.tex: -------------------------------------------------------------------------------- 1 | \section{OpenCV Introduction} 2 | 3 | 4 | \centeredlargetext{white}{black}{ 5 | OpenCV Introduction 6 | } 7 | 8 | 9 | \begin{frame} 10 | \frametitle{OpenCV Overview} 11 | \begin{center} 12 | \begin{columns}[c] 13 | \column{0.8\textwidth} 14 | \begin{itemize} 15 | \item What is OpenCV? OpenCV is \ldots 16 | \begin{itemize} 17 | \item an open source computer vision library. 18 | \item written in C, but has C++ and Python APIs. 19 | \item released under a BSD license. 20 | \item supported and guided by Willow Garage. 21 | \item found at \url{http://opencv.willowgarage.com/wiki/}. 22 | \end{itemize} 23 | \end{itemize} 24 | \column{0.2\textwidth} 25 | \includegraphics[width=0.8\textwidth]{OpenCVLogo.png} 26 | \end{columns} 27 | \pause 28 | \begin{itemize} 29 | \item We will be using OpenCV 2.2 (from subversion). 30 | \item The new C++ interface will be used when possible. 31 | \item We assume you have some prior experience with OpenCV 32 | \item \ldots but we will cover the basics in case you don't. 33 | \end{itemize} 34 | \end{center} 35 | \end{frame} 36 | 37 | 38 | \begin{frame} 39 | \frametitle{Include Header Files} 40 | \framesubtitle{OpenCVIntroduction/exercise1/BasicFilteringOpenCV.cxx} 41 | \begin{center} 42 | We need to include the OpenCV headers 43 | \lstlistingwithnumber{19}{20}{BasicFilteringOpenCV.cxx} 44 | \pause 45 | \vspace{1 em} 46 | and standard library headers for {\tt cout} and {\tt string} 47 | \lstlistingwithnumber{22}{23}{BasicFilteringOpenCV.cxx} 48 | \end{center} 49 | \end{frame} 50 | 51 | 52 | \begin{frame} 53 | \frametitle{The Main function} 54 | \framesubtitle{OpenCVIntroduction/exercise1/BasicFilteringOpenCV.cxx} 55 | \begin{center} 56 | \begin{itemize} 57 | \lstlistingwithnumber{26}{52}{BasicFilteringOpenCV.cxx} 58 | \end{itemize} 59 | \end{center} 60 | \end{frame} 61 | 62 | 63 | \begin{frame} 64 | \frametitle{Loading an Image / Applying a Filter} 65 | \framesubtitle{OpenCVIntroduction/exercise1/BasicFilteringOpenCV.cxx} 66 | \begin{center} 67 | \begin{itemize} 68 | \item If no arguments, print usage and exit \\ 69 | Note: {\tt argv[0]} contains the executable name 70 | \lstlistingwithnumber{28}{32}{BasicFilteringOpenCV.cxx} 71 | \pause 72 | \item Load an image from the specified file into a matrix object 73 | \lstlistingwithnumber{34}{34}{BasicFilteringOpenCV.cxx} 74 | \pause 75 | \item Create a matrix for the output and apply a median filter 76 | \lstlistingwithnumber{35}{36}{BasicFilteringOpenCV.cxx} 77 | \item The last argument represent the size of the filter, $9\times9$ in this case 78 | \end{itemize} 79 | \end{center} 80 | \end{frame} 81 | 82 | 83 | \begin{frame} 84 | \frametitle{Displaying an Image} 85 | \framesubtitle{OpenCVIntroduction/exercise1/BasicFilteringOpenCV.cxx} 86 | \begin{center} 87 | \begin{itemize} 88 | \item If no output file is specified, use HighGUI to display the resulting image. 89 | \lstlistingwithnumber{38}{45}{BasicFilteringOpenCV.cxx} 90 | \end{itemize} 91 | \end{center} 92 | \end{frame} 93 | 94 | 95 | \begin{frame} 96 | \frametitle{Create the Display Window} 97 | \framesubtitle{OpenCVIntroduction/exercise1/BasicFilteringOpenCV.cxx} 98 | \begin{center} 99 | \begin{itemize} 100 | \item A title string is used to identify the GUI window. 101 | \lstlistingwithnumber{40}{40}{BasicFilteringOpenCV.cxx} 102 | \pause 103 | \item Create a named window. 104 | \begin{itemize} 105 | \item {\tt\small CV\_WINDOW\_FREERATIO} is needed for display using OpenGL. 106 | \end{itemize} 107 | \lstlistingwithnumber{41}{41}{BasicFilteringOpenCV.cxx} 108 | \pause 109 | \item Resize the window to match the image size. 110 | \begin{itemize} 111 | \item {\tt\small cvResizeWindow()} is a C function with no C++ API equivalent. 112 | \item It is not in the {\tt\small cv} namespace. 113 | \item It requires a {\tt\small const char*} name, provided by {\tt\small std::string::c\_str()}. 114 | \item The +50 in height to account for the height of tool/status bars. 115 | \end{itemize} 116 | \lstlistingwithnumber{42}{42}{BasicFilteringOpenCV.cxx} 117 | \end{itemize} 118 | \end{center} 119 | \end{frame} 120 | 121 | 122 | \begin{frame} 123 | \frametitle{Display and Wait} 124 | \framesubtitle{OpenCVIntroduction/exercise1/BasicFilteringOpenCV.cxx} 125 | \begin{center} 126 | \begin{itemize} 127 | \item Show the image in the previously created window. 128 | \lstlistingwithnumber{43}{43}{BasicFilteringOpenCV.cxx} 129 | \pause 130 | \item Wait for the user to press a key, then continue. 131 | \lstlistingwithnumber{44}{44}{BasicFilteringOpenCV.cxx} 132 | \end{itemize} 133 | \end{center} 134 | \end{frame} 135 | 136 | 137 | \begin{frame} 138 | \frametitle{Saving an Image} 139 | \framesubtitle{OpenCVIntroduction/exercise1/BasicFilteringOpenCV.cxx} 140 | \begin{center} 141 | \begin{itemize} 142 | \item If an output file is specified, write the image to the specified file 143 | \lstlistingwithnumber{46}{49}{BasicFilteringOpenCV.cxx} 144 | \end{itemize} 145 | \end{center} 146 | \end{frame} 147 | 148 | 149 | \begin{frame}[fragile] 150 | \frametitle{Exercise 1} 151 | \framesubtitle{OpenCVIntroduction/exercise1/BasicFilteringOpenCV.cxx} 152 | \begin{center} 153 | \begin{itemize} 154 | \item Replace the median filter with a Canny edge detector 155 | \lstlistingwithnumber{35}{36}{BasicFilteringOpenCV.cxx} 156 | \pause 157 | \item Hint: The OpenCV Canny function has this signature 158 | \begin{lstlisting}[numbers=none,xleftmargin=0pt] 159 | void Canny(const Mat& image, Mat& edges, double threshold1, double threshold2); 160 | \end{lstlisting} 161 | \pause 162 | \item Canny requires grayscale image input, but our images are color 163 | \item Hint: Use this function to convert a color space 164 | \begin{lstlisting}[numbers=none,xleftmargin=0pt] 165 | void cvtColor(const Mat& src, Mat& dst, int code); 166 | \end{lstlisting} 167 | \item Use {\tt CV\_BGR2GRAY} for {\tt code} to convert BGR color to gray. 168 | \end{itemize} 169 | \end{center} 170 | \end{frame} 171 | 172 | 173 | \begin{frame}[fragile] 174 | \frametitle{Exercise 1: Answer} 175 | \framesubtitle{OpenCVIntroduction/exercise1/BasicFilteringOpenCVAnswer.cxx} 176 | \begin{center} 177 | \lstlistingwithnumber{34}{38}{BasicFilteringOpenCVAnswer.cxx} 178 | \begin{itemize} 179 | \item Run \verb|./BasicFilteringOpenCV ~/data/mandrill.png| 180 | \end{itemize} 181 | \pause 182 | \begin{columns}[c] 183 | \column{0.5\textwidth} 184 | \begin{center} 185 | \includegraphics[width=0.5\textwidth]{OpenCVex1-GUI.png} \\ 186 | Median Filter 187 | \end{center} 188 | \column{0.5\textwidth} 189 | \begin{center} 190 | \includegraphics[width=0.5\textwidth]{OpenCVex1-ans-GUI.png} \\ 191 | Canny Edges 192 | \end{center} 193 | \end{columns} 194 | \end{center} 195 | \end{frame} 196 | 197 | 198 | \begin{frame} 199 | \frametitle{Exercise 2: Basic Video Filtering} 200 | \framesubtitle{OpenCVIntroduction/exercise2/BasicVideoFilteringOpenCV.cxx} 201 | \begin{center} 202 | \begin{itemize} 203 | \item Video filtering is similar to image filtering, except 204 | \begin{itemize} 205 | \item use a {\tt VideoCapture} object to read a video file. 206 | \item loop over each frame in the video and process each one. 207 | \item display or encode each output frame within the loop. 208 | \end{itemize} 209 | \end{itemize} 210 | \end{center} 211 | \end{frame} 212 | 213 | 214 | \begin{frame} 215 | \frametitle{Loading a Video File} 216 | \framesubtitle{OpenCVIntroduction/exercise2/BasicVideoFilteringOpenCV.cxx} 217 | \begin{center} 218 | \begin{itemize} 219 | \item The first step is to open the video file and parse the headers. 220 | \lstlistingwithnumber{88}{93}{BasicVideoFilteringOpenCV.cxx} 221 | \item If unable to parse the headers then terminate the program. 222 | \end{itemize} 223 | \end{center} 224 | \end{frame} 225 | 226 | 227 | \begin{frame} 228 | \frametitle{Display or Save} 229 | \framesubtitle{OpenCVIntroduction/exercise2/BasicVideoFilteringOpenCV.cxx} 230 | \begin{center} 231 | \begin{itemize} 232 | \item Same command line usage as before for selecting between displaying 233 | or saving results. 234 | \item The processing code has been encapsulated into functions. 235 | \item If only input video is specified, then display the resulting video. 236 | \lstlistingwithnumber{95}{98}{BasicVideoFilteringOpenCV.cxx} 237 | \item If a second file is specified, then save the resulting video to the file. 238 | \lstlistingwithnumber{99}{102}{BasicVideoFilteringOpenCV.cxx} 239 | \end{itemize} 240 | \end{center} 241 | \end{frame} 242 | 243 | 244 | \begin{frame} 245 | \frametitle{Prepare the Display Window} 246 | \framesubtitle{OpenCVIntroduction/exercise2/BasicVideoFilteringOpenCV.cxx} 247 | \begin{center} 248 | \begin{itemize} 249 | \item This function processes the video and displays the results. 250 | \lstlistingwithnumber{35}{36}{BasicVideoFilteringOpenCV.cxx} 251 | \pause 252 | \item Use the {\tt\small get()} member function to access video properties: \\ 253 | frame rate, width, and height. 254 | \lstlistingwithnumber{37}{39}{BasicVideoFilteringOpenCV.cxx} 255 | \pause 256 | \item Setup the HighGUI window as in the previous example. 257 | \lstlistingwithnumber{41}{43}{BasicVideoFilteringOpenCV.cxx} 258 | \end{itemize} 259 | \end{center} 260 | \end{frame} 261 | 262 | 263 | \begin{frame} 264 | \frametitle{Process and Display} 265 | \framesubtitle{OpenCVIntroduction/exercise2/BasicVideoFilteringOpenCV.cxx} 266 | \begin{center} 267 | \begin{itemize} 268 | \item Number of milliseconds to wait before drawing the next frame. 269 | \lstlistingwithnumber{45}{45}{BasicVideoFilteringOpenCV.cxx} 270 | \pause 271 | \item Loop until no more frames can be read from the video capture object. 272 | \lstlistingwithnumber{47}{57}{BasicVideoFilteringOpenCV.cxx} 273 | \item Call {\tt\small processFrame()} on each frame and and display the result. 274 | \item {\tt waitkey(\emph{delay})} returns positive value indicating the key pressed 275 | or returns -1 after {\tt \emph{delay}} ms have passed. 276 | \end{itemize} 277 | \end{center} 278 | \end{frame} 279 | 280 | 281 | \begin{frame} 282 | \frametitle{Create a Video Writer} 283 | \framesubtitle{OpenCVIntroduction/exercise2/BasicVideoFilteringOpenCV.cxx} 284 | \begin{center} 285 | \begin{itemize} 286 | \item This function processes the video and saves the results. 287 | \lstlistingwithnumber{62}{63}{BasicVideoFilteringOpenCV.cxx} 288 | \pause 289 | \item Get the video properties as before. 290 | \lstlistingwithnumber{64}{66}{BasicVideoFilteringOpenCV.cxx} 291 | \pause 292 | \item Specify that the output video will be encoded in DIVX format. 293 | \item Create a video writer object with the specified filename. 294 | \lstlistingwithnumber{68}{70}{BasicVideoFilteringOpenCV.cxx} 295 | \end{itemize} 296 | \end{center} 297 | \end{frame} 298 | 299 | 300 | \begin{frame} 301 | \frametitle{Process and Save} 302 | \framesubtitle{OpenCVIntroduction/exercise2/BasicVideoFilteringOpenCV.cxx} 303 | \begin{center} 304 | \begin{itemize} 305 | \item Loop until no more frames can be read from the video capture object. 306 | \lstlistingwithnumber{71}{76}{BasicVideoFilteringOpenCV.cxx} 307 | \item Call {\tt\small processFrame()} on each frame. 308 | \item Write the resulting image to the output video file with the insertion operator ({\tt\small <<}). 309 | \end{itemize} 310 | \end{center} 311 | \end{frame} 312 | 313 | 314 | \begin{frame} 315 | \frametitle{Exercise 2} 316 | \framesubtitle{OpenCVIntroduction/exercise2/BasicVideoFilteringOpenCV.cxx} 317 | \begin{center} 318 | \begin{itemize} 319 | \item Implement {\tt\small processFrame()} by adding the Canny edge detector. 320 | \lstlistingwithnumber{27}{31}{BasicVideoFilteringOpenCV.cxx} 321 | \pause 322 | \item Saving to a video requires color images, but Canny produces grayscale images. 323 | \item Hint: Use {\tt\small cvtColor()} again to convert back to color. 324 | \item Use code {\tt\small CV\_GRAY2BGR} for {\tt\small code} to convert gray to BGR. 325 | \end{itemize} 326 | \end{center} 327 | \end{frame} 328 | 329 | 330 | \begin{frame}[fragile] 331 | \frametitle{Exercise 2: Answer} 332 | \framesubtitle{OpenCVIntroduction/exercise2/BasicVideoFilteringOpenCVAnswer.cxx} 333 | \begin{center} 334 | \lstlistingwithnumber{27}{35}{BasicVideoFilteringOpenCVAnswer.cxx} 335 | \begin{itemize} 336 | \item Run \verb|./BasicVideoFilteringOpenCV ~/data/Walk1.mpg| 337 | \end{itemize} 338 | \pause 339 | \begin{columns}[c] 340 | \column{0.5\textwidth} 341 | \begin{center} 342 | \includegraphics[width=0.5\textwidth]{OpenCVex2-ans-GUI.png} \\ 343 | HighGUI Display 344 | \end{center} 345 | \column{0.5\textwidth} 346 | \begin{center} 347 | \includegraphics[width=0.5\textwidth]{OpenCVex2-ans-save.png} \\ 348 | Saved Video (Opened in vlc) 349 | \end{center} 350 | \end{columns} 351 | \end{center} 352 | \end{frame} 353 | -------------------------------------------------------------------------------- /Documents/Tutorial/SoftwareEnvironment.tex: -------------------------------------------------------------------------------- 1 | \section{Software Environment} 2 | 3 | \centeredlargetext{white}{black}{ 4 | Software Environment 5 | } 6 | 7 | \begin{frame} 8 | \frametitle{Welcome to Ubuntu GNU/Linux} 9 | \begin{center} 10 | \includegraphics[height=0.5\paperheight]{Tux.png} 11 | \includegraphics[width=0.5\paperwidth]{blackeubuntulogo.png} 12 | \end{center} 13 | \end{frame} 14 | 15 | \begin{frame} 16 | \frametitle{How to take the mouse out of the Virtual Machine} 17 | \begin{itemize} 18 | \item Hit the \textbf{RIGHT CTRL} Key on Windows / Linux Host 19 | \item Hit the \textbf{LEFT APPLE} Key on Mac Host 20 | \end{itemize} 21 | \end{frame} 22 | 23 | \begin{frame} 24 | \frametitle{How to Open a Terminal - Icon in Upper Left Corner} 25 | \framesubtitle{To type your command line instructions} 26 | \begin{center} 27 | \includegraphics[width=0.7\paperwidth]{Screenshot-OpenTerminal.jpg} 28 | \end{center} 29 | \end{frame} 30 | 31 | \begin{frame} 32 | \frametitle{How to Open a Terminal - Icon in Upper Left Corner} 33 | \framesubtitle{To type your command line instructions} 34 | \begin{center} 35 | \includegraphics[width=0.7\paperwidth]{Screenshot-Terminal.jpg} 36 | \end{center} 37 | \end{frame} 38 | 39 | \begin{frame} 40 | \frametitle{How to Navigate Directories} 41 | \framesubtitle{Double Click in Folder Icons in the Desktop} 42 | \begin{center} 43 | \includegraphics[width=0.7\paperwidth]{Screenshot-Nautilus.jpg} 44 | \end{center} 45 | \end{frame} 46 | 47 | \begin{frame}[fragile] 48 | \frametitle{Walk through the directories} 49 | \begin{itemize} 50 | \item Find source code of exercises 51 | \begin{verbatim} 52 | cd ~/src/ITK-OpenCV-Bridge-Tutorial/Exercises 53 | pwd 54 | ls 55 | nautilus . 56 | \end{verbatim} 57 | \pause 58 | \item Find binary build of exercises 59 | \begin{verbatim} 60 | cd ~/bin/ITK-OpenCV-Bridge-Tutorial/Exercises 61 | pwd 62 | ls 63 | \end{verbatim} 64 | \end{itemize} 65 | \end{frame} 66 | 67 | \begin{frame}[fragile] 68 | \frametitle{How to View Images} 69 | \begin{itemize} 70 | \item Go to the directory 71 | \item Invoke ``eye of gnome" eog application 72 | \begin{verbatim} 73 | cd ~/data 74 | eog mandrill.png 75 | \end{verbatim} 76 | \pause 77 | \item Hit ESC key to quit the application 78 | \end{itemize} 79 | \end{frame} 80 | 81 | \begin{frame}[fragile] 82 | \frametitle{How to View Videos} 83 | \begin{itemize} 84 | \item Go to the directory 85 | \item Invoke ``VideoLAN" vlc application 86 | \begin{verbatim} 87 | cd ~/data 88 | vlc Walk1.mpg 89 | \end{verbatim} 90 | \pause 91 | \item Hit CTRL-Q to quit the application 92 | \item or use the menus 93 | \end{itemize} 94 | \end{frame} 95 | -------------------------------------------------------------------------------- /Documents/Tutorial/SoftwarePreparation.tex: -------------------------------------------------------------------------------- 1 | \section{Virtual Machines Preparation} 2 | 3 | \centeredlargetext{white}{black}{ 4 | Virtual Machines Preparation 5 | } 6 | 7 | \begin{frame} 8 | \frametitle{Virtual Machines Preparation} 9 | \begin{itemize} 10 | \item Get DVD / USB Memory Stick 11 | \item Install VirtualBox from it 12 | \item Import the VirtualMachine file 13 | \item Boot the Virtual Machine 14 | \item Log in 15 | \item Get familiar with directories 16 | \end{itemize} 17 | \end{frame} 18 | 19 | 20 | \begin{frame} 21 | \frametitle{Media Content} 22 | \framesubtitle{Directories and Files} 23 | \begin{itemize} 24 | \item VirtualBoxInstallers 25 | \begin{itemize} 26 | \item VirtualBox-4.0.8-71778-OSX.dmg (Mac) 27 | \item VirtualBox-4.0.8-71778-Win.exe (Windows) 28 | \item (Ubuntu Linux) 29 | \begin{itemize} 30 | \item virtualbox-4.0\_4.0.8-71778~Ubuntu~lucid\_amd64.deb 31 | \item virtualbox-4.0\_4.0.8-71778~Ubuntu~lucid\_i386.deb 32 | \item virtualbox-4.0\_4.0.8-71778~Ubuntu~maverick\_amd64.deb 33 | \item virtualbox-4.0\_4.0.8-71778~Ubuntu~maverick\_i386.deb 34 | \item virtualbox-4.0\_4.0.8-71778~Ubuntu~natty\_amd64.deb 35 | \item virtualbox-4.0\_4.0.8-71778~Ubuntu~natty\_i386.deb 36 | \item \ldots 37 | \end{itemize} 38 | \end{itemize} 39 | \pause 40 | \item VirtualMachine 41 | \begin{itemize} 42 | \item OpenCV-ITK-disk1.vmdk 43 | \item OpenCV-ITK.ovf 44 | \end{itemize} 45 | \end{itemize} 46 | \end{frame} 47 | 48 | \begin{frame} 49 | \frametitle{Install VirtualBox} 50 | \begin{itemize} 51 | \item Select the installer for your platform 52 | \item Run it 53 | \end{itemize} 54 | \end{frame} 55 | 56 | \begin{frame} 57 | \frametitle{Alternative Linux Installation} 58 | \begin{itemize} 59 | \item You can also install VirtualBox by doing: 60 | \item sudo apt-get install virtualbox-ose-qt 61 | \end{itemize} 62 | \end{frame} 63 | 64 | \begin{frame} 65 | \frametitle{Importing the Virtual Machine} 66 | \begin{itemize} 67 | \item Run VirtualBox 68 | \item In ``File'' Menu select ``Import Appliance'' 69 | \item Provide the filename in the DVD / USB stick ``VirtualMachine/OpenCV-ITK.ovf" 70 | \item A progress bar will appear, and when it finishes you should see: 71 | \end{itemize} 72 | \begin{center} 73 | \includegraphics[width=0.5\paperwidth]{Screenshot-VirtualBox-OSE-01.png} 74 | \end{center} 75 | \end{frame} 76 | 77 | \begin{frame} 78 | \frametitle{Booting the Virtual Machine} 79 | \begin{itemize} 80 | \item Click on the ``OpenCV-ITK'' icon on the left, to select it. 81 | \item Click on the Green Arrow at the top ``Show''. 82 | \item The VM will start to boot and you will see the warning: 83 | \end{itemize} 84 | \begin{center} 85 | \includegraphics[width=0.4\paperwidth]{Screenshot-VirtualBox-OSE-02.png} 86 | \end{center} 87 | \begin{itemize} 88 | \item Click ``OK'' 89 | \end{itemize} 90 | \end{frame} 91 | 92 | \begin{frame} 93 | \frametitle{Booting the Virtual Machine} 94 | \begin{itemize} 95 | \item The boot sequence should continue and you shold see: 96 | \end{itemize} 97 | \begin{center} 98 | \includegraphics[width=0.7\paperwidth]{Screenshot-OpenCV-ITK-VirtualBox-01.png} 99 | \end{center} 100 | \end{frame} 101 | 102 | \centeredlargetext{white}{black}{ 103 | Your Virtual Machine\\ is Ready ! 104 | } 105 | 106 | \begin{frame} 107 | \frametitle{Additional Copies} 108 | \begin{itemize} 109 | \item The same source trees are available in the DVD / USB key 110 | \item Outside of the VirtualBox image 111 | \end{itemize} 112 | \end{frame} 113 | 114 | -------------------------------------------------------------------------------- /Documents/Tutorial/SoftwarePreparation1.tex: -------------------------------------------------------------------------------- 1 | \section{Virtual Machines Preparation} 2 | 3 | \centeredlargetext{white}{black}{ 4 | Virtual Machines Preparation 5 | } 6 | 7 | \begin{frame} 8 | \frametitle{Virtual Machines Preparation} 9 | \begin{itemize} 10 | \item Get DVD / USB Memory Stick 11 | \item Install VirtualBox from it 12 | \item Import the VirtualMachine file 13 | \item Boot the Virtual Machine 14 | \item Log in 15 | \item Get familiar with directories 16 | \end{itemize} 17 | \end{frame} 18 | 19 | 20 | \begin{frame} 21 | \frametitle{Media Content} 22 | \framesubtitle{Directories and Files} 23 | \begin{itemize} 24 | \item VirtualBoxInstallers 25 | \begin{itemize} 26 | \item VirtualBox-4.0.8-71778-OSX.dmg (Mac) 27 | \item VirtualBox-4.0.8-71778-Win.exe (Windows) 28 | \item (Ubuntu Linux) 29 | \begin{itemize} 30 | \item virtualbox-4.0\_4.0.8-71778~Ubuntu~lucid\_amd64.deb 31 | \item virtualbox-4.0\_4.0.8-71778~Ubuntu~lucid\_i386.deb 32 | \item virtualbox-4.0\_4.0.8-71778~Ubuntu~maverick\_amd64.deb 33 | \item virtualbox-4.0\_4.0.8-71778~Ubuntu~maverick\_i386.deb 34 | \item virtualbox-4.0\_4.0.8-71778~Ubuntu~natty\_amd64.deb 35 | \item virtualbox-4.0\_4.0.8-71778~Ubuntu~natty\_i386.deb 36 | \item \ldots 37 | \end{itemize} 38 | \end{itemize} 39 | \pause 40 | \item VirtualMachine 41 | \begin{itemize} 42 | \item OpenCV-ITK-disk1.vmdk 43 | \item OpenCV-ITK.ovf 44 | \end{itemize} 45 | \end{itemize} 46 | \end{frame} 47 | 48 | \begin{frame} 49 | \frametitle{Install VirtualBox} 50 | \begin{itemize} 51 | \item Select the installer for your platform 52 | \item Run it 53 | \end{itemize} 54 | \end{frame} 55 | 56 | \begin{frame} 57 | \frametitle{Alternative Linux Installation} 58 | \begin{itemize} 59 | \item You can also install VirtualBox by doing: 60 | \item sudo apt-get install virtualbox-ose-qt 61 | \end{itemize} 62 | \end{frame} 63 | 64 | \begin{frame} 65 | \frametitle{Importing the Virtual Machine} 66 | \begin{itemize} 67 | \item Run VirtualBox 68 | \item In ``File'' Menu select ``Import Appliance'' 69 | \item Provide the filename in the DVD / USB stick ``VirtualMachine/OpenCV-ITK.ovf" 70 | \item A progress bar will appear, and when it finishes you should see: 71 | \end{itemize} 72 | \begin{center} 73 | \includegraphics[width=0.5\paperwidth]{Screenshot-VirtualBox-OSE-01.png} 74 | \end{center} 75 | \end{frame} 76 | 77 | 78 | \centeredlargetext{white}{black}{ 79 | We will get back... 80 | } 81 | -------------------------------------------------------------------------------- /Documents/Tutorial/SoftwarePreparation2.tex: -------------------------------------------------------------------------------- 1 | \section{Virtual Machines Preparation} 2 | 3 | \centeredlargetext{white}{black}{ 4 | Virtual Machines Preparation II 5 | } 6 | 7 | \begin{frame} 8 | \frametitle{Booting the Virtual Machine} 9 | \begin{itemize} 10 | \item Click on the ``OpenCV-ITK'' icon on the left, to select it. 11 | \item Click on the Green Arrow at the top ``Show''. 12 | \item The VM will start to boot and you will see the warning: 13 | \end{itemize} 14 | \begin{center} 15 | \includegraphics[width=0.4\paperwidth]{Screenshot-VirtualBox-OSE-02.png} 16 | \end{center} 17 | \begin{itemize} 18 | \item Click ``OK'' 19 | \end{itemize} 20 | \end{frame} 21 | 22 | \begin{frame} 23 | \frametitle{Booting the Virtual Machine} 24 | \begin{itemize} 25 | \item The boot sequence should continue and you shold see: 26 | \end{itemize} 27 | \begin{center} 28 | \includegraphics[width=0.7\paperwidth]{Screenshot-OpenCV-ITK-VirtualBox-01.png} 29 | \end{center} 30 | \end{frame} 31 | 32 | \centeredlargetext{white}{black}{ 33 | Your Virtual Machine\\ is Ready ! 34 | } 35 | 36 | \begin{frame} 37 | \frametitle{Additional Copies} 38 | \begin{itemize} 39 | \item The same source trees are available in the DVD / USB key 40 | \item Outside of the VirtualBox image 41 | \end{itemize} 42 | \end{frame} 43 | 44 | -------------------------------------------------------------------------------- /Exercises/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Here we will add the hands-on exercises 3 | # 4 | add_subdirectory( ITKIntroduction ) 5 | add_subdirectory( OpenCVIntroduction ) 6 | add_subdirectory( ITKOpenCVBridge ) 7 | add_subdirectory( ITKVideoPipeline ) 8 | -------------------------------------------------------------------------------- /Exercises/ITKIntroduction/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | add_subdirectory(exercise1) 3 | -------------------------------------------------------------------------------- /Exercises/ITKIntroduction/exercise1/BasicImageFilteringITK.cxx: -------------------------------------------------------------------------------- 1 | /*========================================================================= 2 | * 3 | * Copyright Insight Software Consortium 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0.txt 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * 17 | *=========================================================================*/ 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | int main( int argc, char * argv [] ) 24 | { 25 | if( argc < 5 ) 26 | { 27 | std::cerr << "Usage: " << std::endl; 28 | std::cerr << argv[0] << " inputImageFile outputImageFile radiusX radiusY" << std::endl; 29 | return EXIT_FAILURE; 30 | } 31 | 32 | typedef unsigned char InputPixelType; 33 | typedef unsigned char OutputPixelType; 34 | 35 | const unsigned int Dimension = 2; 36 | 37 | typedef itk::Image< InputPixelType, Dimension > InputImageType; 38 | typedef itk::Image< OutputPixelType, Dimension > OutputImageType; 39 | 40 | typedef itk::ImageFileReader< InputImageType > ReaderType; 41 | typedef itk::ImageFileWriter< OutputImageType > WriterType; 42 | 43 | ReaderType::Pointer reader = ReaderType::New(); 44 | WriterType::Pointer writer = WriterType::New(); 45 | 46 | reader->SetFileName( argv[1] ); 47 | writer->SetFileName( argv[2] ); 48 | 49 | typedef itk::MedianImageFilter< InputImageType, OutputImageType > FilterType; 50 | 51 | FilterType::Pointer filter = FilterType::New(); 52 | 53 | InputImageType::SizeType indexRadius; 54 | 55 | indexRadius[0] = atoi( argv[3] ); // radius along x 56 | indexRadius[1] = atoi( argv[4] ); // radius along y 57 | 58 | filter->SetRadius( indexRadius ); 59 | 60 | filter->SetInput( reader->GetOutput() ); 61 | writer->SetInput( filter->GetOutput() ); 62 | 63 | try 64 | { 65 | writer->Update(); 66 | } 67 | catch( itk::ExceptionObject & excp ) 68 | { 69 | std::cerr << excp << std::endl; 70 | return EXIT_FAILURE; 71 | } 72 | 73 | return EXIT_SUCCESS; 74 | } 75 | 76 | -------------------------------------------------------------------------------- /Exercises/ITKIntroduction/exercise1/BasicImageFilteringITKAnswer1.cxx: -------------------------------------------------------------------------------- 1 | /*========================================================================= 2 | * 3 | * Copyright Insight Software Consortium 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0.txt 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * 17 | *=========================================================================*/ 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | int main( int argc, char * argv [] ) 24 | { 25 | if( argc < 5 ) 26 | { 27 | std::cerr << "Usage: " << std::endl; 28 | std::cerr << argv[0] << " inputImageFile outputImageFile radiusX radiusY" << std::endl; 29 | return EXIT_FAILURE; 30 | } 31 | 32 | typedef unsigned char InputPixelType; 33 | typedef unsigned char OutputPixelType; 34 | 35 | const unsigned int Dimension = 2; 36 | 37 | typedef itk::Image< InputPixelType, Dimension > InputImageType; 38 | typedef itk::Image< OutputPixelType, Dimension > OutputImageType; 39 | 40 | typedef itk::ImageFileReader< InputImageType > ReaderType; 41 | typedef itk::ImageFileWriter< OutputImageType > WriterType; 42 | 43 | ReaderType::Pointer reader = ReaderType::New(); 44 | WriterType::Pointer writer = WriterType::New(); 45 | 46 | reader->SetFileName( argv[1] ); 47 | writer->SetFileName( argv[2] ); 48 | 49 | typedef itk::MeanImageFilter< InputImageType, OutputImageType > FilterType; 50 | 51 | FilterType::Pointer filter = FilterType::New(); 52 | 53 | InputImageType::SizeType indexRadius; 54 | 55 | indexRadius[0] = atoi( argv[3] ); // radius along x 56 | indexRadius[1] = atoi( argv[4] ); // radius along y 57 | 58 | filter->SetRadius( indexRadius ); 59 | 60 | filter->SetInput( reader->GetOutput() ); 61 | writer->SetInput( filter->GetOutput() ); 62 | 63 | try 64 | { 65 | writer->Update(); 66 | } 67 | catch( itk::ExceptionObject & excp ) 68 | { 69 | std::cerr << excp << std::endl; 70 | return EXIT_FAILURE; 71 | } 72 | 73 | return EXIT_SUCCESS; 74 | } 75 | 76 | -------------------------------------------------------------------------------- /Exercises/ITKIntroduction/exercise1/BasicImageFilteringITKAnswer2.cxx: -------------------------------------------------------------------------------- 1 | /*========================================================================= 2 | * 3 | * Copyright Insight Software Consortium 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0.txt 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * 17 | *=========================================================================*/ 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | int main( int argc, char * argv [] ) 26 | { 27 | if( argc < 6 ) 28 | { 29 | std::cerr << "Usage: " << std::endl; 30 | std::cerr << argv[0] << " inputImageFile outputImageFile variance lowerThreshold upperThreshold" << std::endl; 31 | return EXIT_FAILURE; 32 | } 33 | 34 | typedef unsigned char InputPixelType; 35 | typedef float RealPixelType; 36 | typedef unsigned char OutputPixelType; 37 | 38 | typedef itk::Image< InputPixelType, 2 > InputImageType; 39 | typedef itk::Image< RealPixelType, 2 > RealImageType; 40 | typedef itk::Image< OutputPixelType, 2 > OutputImageType; 41 | 42 | typedef itk::ImageFileReader< InputImageType > ReaderType; 43 | typedef itk::ImageFileWriter< OutputImageType > WriterType; 44 | 45 | ReaderType::Pointer reader = ReaderType::New(); 46 | WriterType::Pointer writer = WriterType::New(); 47 | 48 | reader->SetFileName( argv[1] ); 49 | writer->SetFileName( argv[2] ); 50 | 51 | 52 | typedef itk::CastImageFilter< 53 | InputImageType, RealImageType > CastFilterType; 54 | 55 | CastFilterType::Pointer caster = CastFilterType::New(); 56 | 57 | 58 | typedef itk::CannyEdgeDetectionImageFilter< 59 | RealImageType, RealImageType > FilterType; 60 | 61 | FilterType::Pointer canny = FilterType::New(); 62 | 63 | 64 | typedef itk::RescaleIntensityImageFilter< 65 | RealImageType, OutputImageType > RescaleFilterType; 66 | 67 | RescaleFilterType::Pointer rescaler = RescaleFilterType::New(); 68 | 69 | 70 | caster->SetInput( reader->GetOutput() ); 71 | canny->SetInput( caster->GetOutput() ); 72 | rescaler->SetInput( canny->GetOutput() ); 73 | writer->SetInput( rescaler->GetOutput() ); 74 | 75 | 76 | canny->SetVariance( atof( argv[3] ) ); 77 | canny->SetLowerThreshold( atof( argv[4] ) ); 78 | canny->SetUpperThreshold( atof( argv[5] ) ); 79 | 80 | 81 | try 82 | { 83 | writer->Update(); 84 | } 85 | catch( itk::ExceptionObject & excp ) 86 | { 87 | std::cerr << excp << std::endl; 88 | return EXIT_FAILURE; 89 | } 90 | 91 | return EXIT_SUCCESS; 92 | } 93 | -------------------------------------------------------------------------------- /Exercises/ITKIntroduction/exercise1/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.4) 2 | if(COMMAND CMAKE_POLICY) 3 | cmake_policy(SET CMP0003 NEW) 4 | endif(COMMAND CMAKE_POLICY) 5 | 6 | project(ITKBasicImageFiltering) 7 | 8 | find_package(ITK REQUIRED) 9 | if(ITK_FOUND) 10 | include(${ITK_USE_FILE}) 11 | endif() 12 | 13 | find_package(OpenCV REQUIRED) 14 | if(OpenCV_FOUND) 15 | include_directories(${OpenCV_INCLUDE_DIRS}) 16 | endif() 17 | 18 | add_executable(BasicImageFilteringITK BasicImageFilteringITK.cxx ) 19 | target_link_libraries(BasicImageFilteringITK ${ITK_LIBRARIES}) 20 | 21 | add_executable(BasicImageFilteringITKAnswer1 BasicImageFilteringITKAnswer1.cxx ) 22 | target_link_libraries(BasicImageFilteringITKAnswer1 ${ITK_LIBRARIES}) 23 | 24 | add_executable(BasicImageFilteringITKAnswer2 BasicImageFilteringITKAnswer2.cxx ) 25 | target_link_libraries(BasicImageFilteringITKAnswer2 ${ITK_LIBRARIES}) 26 | -------------------------------------------------------------------------------- /Exercises/ITKIntroduction/exercise1/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cd /home/tutorial/bin/ITK-OpenCV-Bridge-Tutorial/Exercises/ITKIntroduction/exercise1 3 | make 4 | gnome-terminal 5 | -------------------------------------------------------------------------------- /Exercises/ITKOpenCVBridge/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | find_package(ITK REQUIRED ) 2 | if(ITK_FOUND) 3 | include(${ITK_USE_FILE}) 4 | endif() 5 | 6 | find_package(OpenCV REQUIRED) 7 | if(OpenCV_FOUND) 8 | include_directories(${OpenCV_INCLUDE_DIRS}) 9 | endif() 10 | 11 | add_subdirectory(exercise1) 12 | add_subdirectory(exercise2) 13 | -------------------------------------------------------------------------------- /Exercises/ITKOpenCVBridge/exercise1/BasicFilteringITKOpenCVBridge.cxx: -------------------------------------------------------------------------------- 1 | /*========================================================================= 2 | * 3 | * Copyright Insight Software Consortium 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0.txt 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * 17 | *=========================================================================*/ 18 | #include 19 | 20 | #include 21 | #include 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | int main ( int argc, char **argv ) 28 | { 29 | if( argc < 2 ) 30 | { 31 | std::cout << "Usage: "<< argv[0] <<" input_image output_image"< InputImageType; 41 | typedef itk::Image< OutputPixelType, Dimension > OutputImageType; 42 | typedef itk::OpenCVImageBridge BridgeType; 43 | typedef itk::MedianImageFilter< InputImageType, OutputImageType > 44 | FilterType; 45 | 46 | InputImageType::Pointer itkImage = 47 | BridgeType::CVMatToITKImage< InputImageType >( inputImage ); 48 | 49 | FilterType::Pointer filter = FilterType::New(); 50 | InputImageType::SizeType neighborhoodRadius; 51 | neighborhoodRadius[0] = 9; 52 | neighborhoodRadius[1] = 9; 53 | filter->SetRadius( neighborhoodRadius ); 54 | 55 | filter->SetInput( itkImage ); 56 | try 57 | { 58 | filter->Update(); 59 | } 60 | catch( itk::ExceptionObject & excp ) 61 | { 62 | std::cerr << excp << std::endl; 63 | return EXIT_FAILURE; 64 | } 65 | 66 | cv::Mat resultImage = 67 | BridgeType::ITKImageToCVMat< OutputImageType >( filter->GetOutput() ); 68 | 69 | if(argc < 3) 70 | { 71 | std::string windowName = "Exercise 1: Basic Filtering in OpenCV & ITK"; 72 | cv::namedWindow( windowName, CV_WINDOW_FREERATIO); 73 | cvResizeWindow( windowName.c_str(), resultImage.cols, resultImage.rows+50 ); 74 | cv::Mat scaled; 75 | resultImage.convertTo( scaled, CV_8UC1 ); 76 | cv::imshow( windowName, scaled ); 77 | cv::waitKey(); 78 | } 79 | else 80 | { 81 | cv::imwrite( argv[2], resultImage ); 82 | } 83 | 84 | return 0; 85 | } 86 | -------------------------------------------------------------------------------- /Exercises/ITKOpenCVBridge/exercise1/BasicFilteringITKOpenCVBridgeAnswer.cxx: -------------------------------------------------------------------------------- 1 | /*========================================================================= 2 | * 3 | * Copyright Insight Software Consortium 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0.txt 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * 17 | *=========================================================================*/ 18 | #include 19 | 20 | #include 21 | #include 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | int main ( int argc, char **argv ) 28 | { 29 | if( argc < 2 ) 30 | { 31 | std::cout << "Usage: "<< argv[0] <<" input_image output_image"< InputImageType; 41 | typedef itk::Image< OutputPixelType, Dimension > OutputImageType; 42 | typedef itk::OpenCVImageBridge BridgeType; 43 | typedef itk::CurvatureFlowImageFilter< InputImageType, OutputImageType > 44 | FilterType; 45 | 46 | InputImageType::Pointer itkImage = 47 | BridgeType::CVMatToITKImage< InputImageType >( inputImage ); 48 | 49 | FilterType::Pointer filter = FilterType::New(); 50 | filter->SetTimeStep( 0.5 ); 51 | filter->SetNumberOfIterations( 20 ); 52 | 53 | filter->SetInput( itkImage ); 54 | try 55 | { 56 | filter->Update(); 57 | } 58 | catch( itk::ExceptionObject & excp ) 59 | { 60 | std::cerr << excp << std::endl; 61 | return EXIT_FAILURE; 62 | } 63 | 64 | cv::Mat resultImage = 65 | BridgeType::ITKImageToCVMat< OutputImageType >( filter->GetOutput() ); 66 | 67 | if(argc < 3) 68 | { 69 | std::string windowName = "Exercise 1: Basic Filtering in OpenCV & ITK"; 70 | cv::namedWindow( windowName, CV_WINDOW_FREERATIO); 71 | cvResizeWindow( windowName.c_str(), resultImage.cols, resultImage.rows+50 ); 72 | cv::Mat scaled; 73 | resultImage.convertTo(scaled, CV_8UC1 ); 74 | cv::imshow( windowName, scaled ); 75 | cv::waitKey(); 76 | } 77 | else 78 | { 79 | cv::imwrite( argv[2], resultImage ); 80 | } 81 | 82 | return 0; 83 | } 84 | -------------------------------------------------------------------------------- /Exercises/ITKOpenCVBridge/exercise1/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | # BasicFilteringITKOpenCVBridge 3 | add_executable(BasicFilteringITKOpenCVBridge 4 | BasicFilteringITKOpenCVBridge.cxx ) 5 | target_link_libraries(BasicFilteringITKOpenCVBridge 6 | ${ITK_LIBRARIES} ${OpenCV_LIBS}) 7 | 8 | # BasicFilteringITKOpenCVBridgeAnswer 9 | add_executable(BasicFilteringITKOpenCVBridgeAnswer 10 | BasicFilteringITKOpenCVBridgeAnswer.cxx ) 11 | target_link_libraries(BasicFilteringITKOpenCVBridgeAnswer 12 | ${ITK_LIBRARIES} ${OpenCV_LIBS}) 13 | -------------------------------------------------------------------------------- /Exercises/ITKOpenCVBridge/exercise2/BasicVideoFilteringITKOpenCVBridge.cxx: -------------------------------------------------------------------------------- 1 | /*========================================================================= 2 | * 3 | * Copyright Insight Software Consortium 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0.txt 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * 17 | *=========================================================================*/ 18 | #include 19 | 20 | #include 21 | #include 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | // Process a single frame of video and return the resulting frame 28 | cv::Mat processFrame( const cv::Mat& inputImage ) 29 | { 30 | const unsigned int Dimension = 2; 31 | typedef unsigned char InputPixelType; 32 | typedef unsigned char OutputPixelType; 33 | typedef itk::Image< InputPixelType, Dimension > InputImageType; 34 | typedef itk::Image< OutputPixelType, Dimension > OutputImageType; 35 | typedef itk::OpenCVImageBridge BridgeType; 36 | typedef itk::MedianImageFilter< InputImageType, OutputImageType > 37 | FilterType; 38 | 39 | FilterType::Pointer filter = FilterType::New(); 40 | InputImageType::SizeType neighborhoodRadius; 41 | neighborhoodRadius[0] = 9; 42 | neighborhoodRadius[1] = 9; 43 | filter->SetRadius( neighborhoodRadius ); 44 | 45 | InputImageType::Pointer itkFrame = 46 | BridgeType::CVMatToITKImage< InputImageType >( inputImage ); 47 | 48 | filter->SetInput(itkFrame); 49 | try 50 | { 51 | filter->Update(); 52 | } 53 | catch( itk::ExceptionObject & excp ) 54 | { 55 | std::cerr << excp << std::endl; 56 | } 57 | 58 | return BridgeType::ITKImageToCVMat( filter->GetOutput(), 59 | true ); 60 | } 61 | 62 | // Iterate through a video, process each frame, and display the result in a GUI. 63 | void processAndDisplayVideo(cv::VideoCapture& vidCap) 64 | { 65 | double frameRate = vidCap.get( CV_CAP_PROP_FPS ); 66 | int width = vidCap.get( CV_CAP_PROP_FRAME_WIDTH ); 67 | int height = vidCap.get( CV_CAP_PROP_FRAME_HEIGHT ); 68 | 69 | std::string windowName = "Exercise 2: Basic Video Filtering in OpenCV"; 70 | cv::namedWindow( windowName, CV_WINDOW_FREERATIO); 71 | cvResizeWindow( windowName.c_str(), width, height+50 ); 72 | 73 | unsigned delay = 1000 / frameRate; 74 | 75 | cv::Mat frame; 76 | while( vidCap.read(frame) ) 77 | { 78 | cv::Mat outputFrame = processFrame( frame ); 79 | cv::imshow( windowName, outputFrame ); 80 | 81 | if( cv::waitKey(delay) >= 0 ) 82 | { 83 | break; 84 | } 85 | } 86 | } 87 | 88 | // Iterate through a video, process each frame, and save the processed video. 89 | void processAndSaveVideo(cv::VideoCapture& vidCap, const std::string& filename) 90 | { 91 | double frameRate = vidCap.get( CV_CAP_PROP_FPS ); 92 | int width = vidCap.get( CV_CAP_PROP_FRAME_WIDTH ); 93 | int height = vidCap.get( CV_CAP_PROP_FRAME_HEIGHT ); 94 | 95 | int fourcc = CV_FOURCC('D','I','V','X'); 96 | 97 | cv::VideoWriter writer( filename, fourcc, frameRate, 98 | cv::Size(width, height) ); 99 | 100 | cv::Mat frame; 101 | while( vidCap.read(frame) ) 102 | { 103 | cv::Mat outputFrame = processFrame( frame ); 104 | writer << outputFrame; 105 | } 106 | } 107 | 108 | int main ( int argc, char **argv ) 109 | { 110 | if( argc < 2 ) 111 | { 112 | std::cout << "Usage: "<< argv[0] <<" input_image output_image"< 19 | 20 | #include 21 | #include 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | // Process a single frame of video and return the resulting frame 30 | cv::Mat processFrame( const cv::Mat& inputImage ) 31 | { 32 | typedef unsigned char InputPixelType; 33 | typedef float RealPixelType; 34 | typedef unsigned char OutputPixelType; 35 | typedef itk::Image< InputPixelType, 2 > InputImageType; 36 | typedef itk::Image< RealPixelType, 2 > RealImageType; 37 | typedef itk::Image< OutputPixelType, 2 > OutputImageType; 38 | typedef itk::OpenCVImageBridge BridgeType; 39 | typedef itk::CastImageFilter< InputImageType, RealImageType > 40 | CastFilterType; 41 | typedef itk::CannyEdgeDetectionImageFilter< RealImageType, RealImageType > 42 | FilterType; 43 | typedef itk::RescaleIntensityImageFilter< RealImageType, OutputImageType > 44 | RescaleFilterType; 45 | 46 | CastFilterType::Pointer caster = CastFilterType::New(); 47 | FilterType::Pointer canny = FilterType::New(); 48 | RescaleFilterType::Pointer rescaler = RescaleFilterType::New(); 49 | 50 | InputImageType::Pointer itkFrame = 51 | itk::OpenCVImageBridge::CVMatToITKImage< InputImageType >( inputImage ); 52 | caster->SetInput( itkFrame ); 53 | canny->SetInput( caster->GetOutput() ); 54 | rescaler->SetInput( canny->GetOutput() ); 55 | 56 | canny->SetVariance( 6 ); 57 | canny->SetLowerThreshold( 1 ); 58 | canny->SetUpperThreshold( 8 ); 59 | 60 | try 61 | { 62 | rescaler->Update(); 63 | } 64 | catch( itk::ExceptionObject & excp ) 65 | { 66 | std::cerr << excp << std::endl; 67 | } 68 | 69 | cv::Mat frameOut = 70 | BridgeType::ITKImageToCVMat< OutputImageType >(rescaler->GetOutput(),true); 71 | 72 | frameOut.convertTo( frameOut, CV_8U ); 73 | 74 | return frameOut; 75 | } 76 | 77 | // Iterate through a video, process each frame, and display the result in a GUI. 78 | void processAndDisplayVideo(cv::VideoCapture& vidCap) 79 | { 80 | double frameRate = vidCap.get( CV_CAP_PROP_FPS ); 81 | int width = vidCap.get( CV_CAP_PROP_FRAME_WIDTH ); 82 | int height = vidCap.get( CV_CAP_PROP_FRAME_HEIGHT ); 83 | 84 | std::string windowName = "Exercise 2: Basic Video Filtering in OpenCV"; 85 | cv::namedWindow( windowName, CV_WINDOW_FREERATIO); 86 | cvResizeWindow( windowName.c_str(), width, height+50 ); 87 | 88 | unsigned delay = 1000 / frameRate; 89 | 90 | cv::Mat frame; 91 | while( vidCap.read(frame) ) 92 | { 93 | cv::Mat outputFrame = processFrame( frame ); 94 | cv::imshow( windowName, outputFrame ); 95 | 96 | if( cv::waitKey(delay) >= 0 ) 97 | { 98 | break; 99 | } 100 | } 101 | } 102 | 103 | // Iterate through a video, process each frame, and save the processed video. 104 | void processAndSaveVideo(cv::VideoCapture& vidCap, const std::string& filename) 105 | { 106 | double frameRate = vidCap.get( CV_CAP_PROP_FPS ); 107 | int width = vidCap.get( CV_CAP_PROP_FRAME_WIDTH ); 108 | int height = vidCap.get( CV_CAP_PROP_FRAME_HEIGHT ); 109 | 110 | int fourcc = CV_FOURCC('D','I','V','X'); 111 | 112 | cv::VideoWriter writer( filename, fourcc, frameRate, 113 | cv::Size(width, height) ); 114 | 115 | cv::Mat frame; 116 | while( vidCap.read(frame) ) 117 | { 118 | cv::Mat outputFrame = processFrame( frame ); 119 | writer << outputFrame; 120 | } 121 | } 122 | 123 | int main ( int argc, char **argv ) 124 | { 125 | if( argc < 2 ) 126 | { 127 | std::cout << "Usage: "<< argv[0] <<" input_image output_image"< 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | int main ( int argc, char **argv ) 29 | { 30 | if( argc < 3 ) 31 | { 32 | std::cout << "Usage: " << argv[0] << "input_image output_image" << std::endl; 33 | return EXIT_FAILURE; 34 | } 35 | 36 | const unsigned int Dimension = 2; 37 | typedef unsigned char PixelType; 38 | typedef itk::Image< PixelType, Dimension > FrameType; 39 | typedef itk::VideoStream< FrameType > VideoType; 40 | 41 | typedef itk::VideoFileReader< VideoType > ReaderType; 42 | typedef itk::VideoFileWriter< VideoType > WriterType; 43 | typedef itk::MedianImageFilter< FrameType, FrameType > ImageFilterType; 44 | typedef itk::ImageFilterToVideoFilterWrapper< ImageFilterType > 45 | VideoFilterType; 46 | 47 | ReaderType::Pointer reader = ReaderType::New(); 48 | WriterType::Pointer writer = WriterType::New(); 49 | ImageFilterType::Pointer imageFilter = ImageFilterType::New(); 50 | VideoFilterType::Pointer videoFilter = VideoFilterType::New(); 51 | 52 | itk::ObjectFactoryBase::RegisterFactory( itk::OpenCVVideoIOFactory::New() ); 53 | reader->SetFileName( argv[1] ); 54 | writer->SetFileName( argv[2] ); 55 | 56 | FrameType::SizeType neighborhoodRadius; 57 | neighborhoodRadius[0] = 10; 58 | neighborhoodRadius[1] = 10; 59 | imageFilter->SetRadius( neighborhoodRadius ); 60 | videoFilter->SetImageFilter( imageFilter ); 61 | 62 | videoFilter->SetInput( reader->GetOutput() ); 63 | writer->SetInput( videoFilter->GetOutput() ); 64 | 65 | try 66 | { 67 | writer->Update(); 68 | } 69 | catch( itk::ExceptionObject & excp ) 70 | { 71 | std::cerr << excp << std::endl; 72 | return EXIT_FAILURE; 73 | } 74 | 75 | return EXIT_SUCCESS; 76 | } 77 | 78 | -------------------------------------------------------------------------------- /Exercises/ITKVideoPipeline/exercise1/ITKVideoSingleFrameFiltersAnswer.cxx: -------------------------------------------------------------------------------- 1 | /*========================================================================= 2 | * 3 | * Copyright Insight Software Consortium 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0.txt 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * 17 | *=========================================================================*/ 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | int main ( int argc, char **argv ) 30 | { 31 | if( argc < 3 ) 32 | { 33 | std::cout << "Usage: " << argv[0] << "input_image output_image" << std::endl; 34 | return EXIT_FAILURE; 35 | } 36 | 37 | const unsigned int Dimension = 2; 38 | typedef unsigned char IOPixelType; 39 | typedef float RealPixelType; 40 | typedef itk::Image< IOPixelType, Dimension > IOFrameType; 41 | typedef itk::Image< RealPixelType, Dimension > RealFrameType; 42 | typedef itk::VideoStream< IOFrameType > IOVideoType; 43 | typedef itk::VideoStream< RealFrameType > RealVideoType; 44 | 45 | typedef itk::VideoFileReader< IOVideoType > ReaderType; 46 | typedef itk::VideoFileWriter< IOVideoType > WriterType; 47 | typedef itk::CastImageFilter< RealFrameType, IOFrameType > 48 | CastImageFilterType; 49 | typedef itk::ImageFilterToVideoFilterWrapper< CastImageFilterType > 50 | CastVideoFilterType; 51 | typedef itk::CurvatureFlowImageFilter< IOFrameType, RealFrameType > 52 | ImageFilterType; 53 | typedef itk::ImageFilterToVideoFilterWrapper< ImageFilterType > 54 | VideoFilterType; 55 | 56 | ReaderType::Pointer reader = ReaderType::New(); 57 | WriterType::Pointer writer = WriterType::New(); 58 | ImageFilterType::Pointer imageFilter = ImageFilterType::New(); 59 | VideoFilterType::Pointer videoFilter = VideoFilterType::New(); 60 | CastImageFilterType::Pointer imageCaster = CastImageFilterType::New(); 61 | CastVideoFilterType::Pointer videoCaster = CastVideoFilterType::New(); 62 | 63 | 64 | itk::ObjectFactoryBase::RegisterFactory( itk::OpenCVVideoIOFactory::New() ); 65 | reader->SetFileName( argv[1] ); 66 | writer->SetFileName( argv[2] ); 67 | 68 | videoCaster->SetImageFilter( imageCaster ); 69 | 70 | imageFilter->SetTimeStep( 0.5 ); 71 | imageFilter->SetNumberOfIterations( 20 ); 72 | videoFilter->SetImageFilter( imageFilter ); 73 | 74 | videoFilter->SetInput( reader->GetOutput() ); 75 | videoCaster->SetInput( videoFilter->GetOutput() ); 76 | writer->SetInput( videoCaster->GetOutput() ); 77 | 78 | try 79 | { 80 | writer->Update(); 81 | } 82 | catch( itk::ExceptionObject & excp ) 83 | { 84 | std::cerr << excp << std::endl; 85 | return EXIT_FAILURE; 86 | } 87 | 88 | return EXIT_SUCCESS; 89 | } 90 | 91 | -------------------------------------------------------------------------------- /Exercises/ITKVideoPipeline/exercise2/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Make sure that we prefix the executable names with the exerciser number. 3 | # 4 | 5 | # ITKVideoPipeline 6 | add_executable(ITKVideoMultiFrameFilters 7 | ITKVideoMultiFrameFilters.cxx ) 8 | target_link_libraries(ITKVideoMultiFrameFilters ${ITK_LIBRARIES} ${OpenCV_LIBS}) 9 | 10 | # ITKVideoPipeline 11 | add_executable(ITKVideoMultiFrameFiltersAnswer 12 | ITKVideoMultiFrameFiltersAnswer.cxx ) 13 | target_link_libraries(ITKVideoMultiFrameFiltersAnswer ${ITK_LIBRARIES} ${OpenCV_LIBS}) 14 | 15 | # ITKVideoPipelineAnswer2 16 | add_executable(ITKVideoMultiFrameFiltersAnswer2 17 | ITKVideoMultiFrameFiltersAnswer2.cxx ) 18 | target_link_libraries(ITKVideoMultiFrameFiltersAnswer2 ${ITK_LIBRARIES} ${OpenCV_LIBS}) 19 | -------------------------------------------------------------------------------- /Exercises/ITKVideoPipeline/exercise2/ITKVideoMultiFrameFilters.cxx: -------------------------------------------------------------------------------- 1 | /*========================================================================= 2 | * 3 | * Copyright Insight Software Consortium 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0.txt 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * 17 | *=========================================================================*/ 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | int main ( int argc, char **argv ) 30 | { 31 | if( argc < 3 ) 32 | { 33 | std::cout << "Usage: " << argv[0] << "input_image output_image" << std::endl; 34 | return EXIT_FAILURE; 35 | } 36 | 37 | const unsigned int Dimension = 2; 38 | typedef unsigned char IOPixelType; 39 | typedef float RealPixelType; 40 | typedef itk::Image< IOPixelType, Dimension > IOFrameType; 41 | typedef itk::Image< RealPixelType, Dimension > RealFrameType; 42 | typedef itk::VideoStream< IOFrameType > IOVideoType; 43 | typedef itk::VideoStream< RealFrameType > RealVideoType; 44 | 45 | typedef itk::VideoFileReader< IOVideoType > ReaderType; 46 | typedef itk::VideoFileWriter< IOVideoType > WriterType; 47 | typedef itk::CastImageFilter< RealFrameType, IOFrameType > 48 | CastImageFilterType; 49 | typedef itk::ImageFilterToVideoFilterWrapper< CastImageFilterType > 50 | CastVideoFilterType; 51 | typedef itk::CurvatureFlowImageFilter< IOFrameType, RealFrameType > 52 | ImageFilterType; 53 | typedef itk::ImageFilterToVideoFilterWrapper< ImageFilterType > 54 | VideoFilterType; 55 | 56 | ReaderType::Pointer reader = ReaderType::New(); 57 | WriterType::Pointer writer = WriterType::New(); 58 | ImageFilterType::Pointer imageFilter = ImageFilterType::New(); 59 | VideoFilterType::Pointer videoFilter = VideoFilterType::New(); 60 | CastImageFilterType::Pointer imageCaster = CastImageFilterType::New(); 61 | CastVideoFilterType::Pointer videoCaster = CastVideoFilterType::New(); 62 | 63 | 64 | itk::ObjectFactoryBase::RegisterFactory( itk::OpenCVVideoIOFactory::New() ); 65 | reader->SetFileName( argv[1] ); 66 | writer->SetFileName( argv[2] ); 67 | 68 | videoCaster->SetImageFilter( imageCaster ); 69 | 70 | imageFilter->SetTimeStep( 0.5 ); 71 | imageFilter->SetNumberOfIterations( 20 ); 72 | videoFilter->SetImageFilter( imageFilter ); 73 | 74 | videoFilter->SetInput( reader->GetOutput() ); 75 | videoCaster->SetInput( videoFilter->GetOutput() ); 76 | writer->SetInput( videoCaster->GetOutput() ); 77 | 78 | try 79 | { 80 | writer->Update(); 81 | } 82 | catch( itk::ExceptionObject & excp ) 83 | { 84 | std::cerr << excp << std::endl; 85 | return EXIT_FAILURE; 86 | } 87 | 88 | return EXIT_SUCCESS; 89 | } 90 | 91 | -------------------------------------------------------------------------------- /Exercises/ITKVideoPipeline/exercise2/ITKVideoMultiFrameFiltersAnswer.cxx: -------------------------------------------------------------------------------- 1 | /*========================================================================= 2 | * 3 | * Copyright Insight Software Consortium 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0.txt 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * 17 | *=========================================================================*/ 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | int main ( int argc, char **argv ) 31 | { 32 | if( argc < 3 ) 33 | { 34 | std::cout << "Usage: " << argv[0] << "input_image output_image" << std::endl; 35 | return EXIT_FAILURE; 36 | } 37 | 38 | const unsigned int Dimension = 2; 39 | typedef unsigned char IOPixelType; 40 | typedef float RealPixelType; 41 | typedef itk::Image< IOPixelType, Dimension > IOFrameType; 42 | typedef itk::Image< RealPixelType, Dimension > RealFrameType; 43 | typedef itk::VideoStream< IOFrameType > IOVideoType; 44 | typedef itk::VideoStream< RealFrameType > RealVideoType; 45 | 46 | typedef itk::VideoFileReader< IOVideoType > ReaderType; 47 | typedef itk::VideoFileWriter< IOVideoType > WriterType; 48 | typedef itk::CastImageFilter< RealFrameType, IOFrameType > 49 | CastImageFilterType; 50 | typedef itk::ImageFilterToVideoFilterWrapper< CastImageFilterType > 51 | CastVideoFilterType; 52 | typedef itk::CurvatureFlowImageFilter< IOFrameType, RealFrameType > 53 | ImageFilterType; 54 | typedef itk::ImageFilterToVideoFilterWrapper< ImageFilterType > 55 | VideoFilterType; 56 | 57 | typedef itk::FrameDifferenceVideoFilter< IOVideoType, IOVideoType > 58 | FrameDifferenceFilterType; 59 | 60 | ReaderType::Pointer reader = ReaderType::New(); 61 | WriterType::Pointer writer = WriterType::New(); 62 | ImageFilterType::Pointer imageFilter = ImageFilterType::New(); 63 | VideoFilterType::Pointer videoFilter = VideoFilterType::New(); 64 | CastImageFilterType::Pointer imageCaster = CastImageFilterType::New(); 65 | CastVideoFilterType::Pointer videoCaster = CastVideoFilterType::New(); 66 | FrameDifferenceFilterType::Pointer frameDifferenceFilter = 67 | FrameDifferenceFilterType::New(); 68 | 69 | itk::ObjectFactoryBase::RegisterFactory( itk::OpenCVVideoIOFactory::New() ); 70 | reader->SetFileName( argv[1] ); 71 | writer->SetFileName( argv[2] ); 72 | 73 | frameDifferenceFilter->SetFrameOffset(1); 74 | 75 | videoCaster->SetImageFilter( imageCaster ); 76 | 77 | imageFilter->SetTimeStep( 0.5 ); 78 | imageFilter->SetNumberOfIterations( 20 ); 79 | videoFilter->SetImageFilter( imageFilter ); 80 | 81 | videoFilter->SetInput( reader->GetOutput() ); 82 | videoCaster->SetInput( videoFilter->GetOutput() ); 83 | frameDifferenceFilter->SetInput( videoCaster->GetOutput() ); 84 | writer->SetInput( frameDifferenceFilter->GetOutput() ); 85 | 86 | try 87 | { 88 | writer->Update(); 89 | } 90 | catch( itk::ExceptionObject & excp ) 91 | { 92 | std::cerr << excp << std::endl; 93 | return EXIT_FAILURE; 94 | } 95 | 96 | return EXIT_SUCCESS; 97 | } 98 | 99 | -------------------------------------------------------------------------------- /Exercises/ITKVideoPipeline/exercise2/ITKVideoMultiFrameFiltersAnswer2.cxx: -------------------------------------------------------------------------------- 1 | /*========================================================================= 2 | * 3 | * Copyright Insight Software Consortium 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0.txt 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * 17 | *=========================================================================*/ 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | int main ( int argc, char **argv ) 32 | { 33 | if( argc < 3 ) 34 | { 35 | std::cout << "Usage: " << argv[0] << "input_image output_image" << std::endl; 36 | return EXIT_FAILURE; 37 | } 38 | 39 | const unsigned int Dimension = 2; 40 | typedef unsigned char IOPixelType; 41 | typedef float RealPixelType; 42 | typedef itk::Image< IOPixelType, Dimension > IOFrameType; 43 | typedef itk::Image< RealPixelType, Dimension > RealFrameType; 44 | typedef itk::VideoStream< IOFrameType > IOVideoType; 45 | typedef itk::VideoStream< RealFrameType > RealVideoType; 46 | 47 | typedef itk::VideoFileReader< IOVideoType > ReaderType; 48 | typedef itk::VideoFileWriter< IOVideoType > WriterType; 49 | typedef itk::CastImageFilter< RealFrameType, IOFrameType > 50 | CastImageFilterType; 51 | typedef itk::ImageFilterToVideoFilterWrapper< CastImageFilterType > 52 | CastVideoFilterType; 53 | typedef itk::CurvatureFlowImageFilter< IOFrameType, RealFrameType > 54 | ImageFilterType; 55 | typedef itk::ImageFilterToVideoFilterWrapper< ImageFilterType > 56 | VideoFilterType; 57 | typedef itk::ThresholdImageFilter< IOFrameType > 58 | ThresholdImageFilterType; 59 | typedef itk::ImageFilterToVideoFilterWrapper< ThresholdImageFilterType > 60 | ThresholdVideoFilterType; 61 | 62 | typedef itk::FrameDifferenceVideoFilter< IOVideoType, IOVideoType > 63 | FrameDifferenceFilterType; 64 | 65 | ReaderType::Pointer reader = ReaderType::New(); 66 | WriterType::Pointer writer = WriterType::New(); 67 | ImageFilterType::Pointer imageFilter = ImageFilterType::New(); 68 | VideoFilterType::Pointer videoFilter = VideoFilterType::New(); 69 | CastImageFilterType::Pointer imageCaster = CastImageFilterType::New(); 70 | CastVideoFilterType::Pointer videoCaster = CastVideoFilterType::New(); 71 | ThresholdImageFilterType::Pointer imageThresh = ThresholdImageFilterType::New(); 72 | ThresholdVideoFilterType::Pointer videoThresh = ThresholdVideoFilterType::New(); 73 | FrameDifferenceFilterType::Pointer frameDifferenceFilter = 74 | FrameDifferenceFilterType::New(); 75 | 76 | itk::ObjectFactoryBase::RegisterFactory( itk::OpenCVVideoIOFactory::New() ); 77 | reader->SetFileName( argv[1] ); 78 | writer->SetFileName( argv[2] ); 79 | 80 | frameDifferenceFilter->SetFrameOffset(1); 81 | 82 | videoCaster->SetImageFilter( imageCaster ); 83 | 84 | imageThresh->ThresholdBelow( 128 ); 85 | videoThresh->SetImageFilter( imageThresh ); 86 | 87 | imageFilter->SetTimeStep( 0.5 ); 88 | imageFilter->SetNumberOfIterations( 20 ); 89 | videoFilter->SetImageFilter( imageFilter ); 90 | 91 | videoFilter->SetInput( reader->GetOutput() ); 92 | videoCaster->SetInput( videoFilter->GetOutput() ); 93 | frameDifferenceFilter->SetInput( videoCaster->GetOutput() ); 94 | videoThresh->SetInput( frameDifferenceFilter->GetOutput() ); 95 | writer->SetInput( videoThresh->GetOutput() ); 96 | 97 | try 98 | { 99 | writer->Update(); 100 | } 101 | catch( itk::ExceptionObject & excp ) 102 | { 103 | std::cerr << excp << std::endl; 104 | return EXIT_FAILURE; 105 | } 106 | 107 | return EXIT_SUCCESS; 108 | } 109 | 110 | -------------------------------------------------------------------------------- /Exercises/OpenCVIntroduction/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(exercise1) 2 | add_subdirectory(exercise2) 3 | -------------------------------------------------------------------------------- /Exercises/OpenCVIntroduction/exercise1/BasicFilteringOpenCV.cxx: -------------------------------------------------------------------------------- 1 | /*========================================================================= 2 | * 3 | * Copyright Insight Software Consortium 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0.txt 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * 17 | *=========================================================================*/ 18 | 19 | #include 20 | #include 21 | 22 | #include 23 | #include 24 | 25 | 26 | int main ( int argc, char **argv ) 27 | { 28 | if( argc < 2 ) 29 | { 30 | std::cout << "Usage: "<< argv[0] <<" input_image output_image"< 20 | #include 21 | 22 | #include 23 | #include 24 | 25 | 26 | int main ( int argc, char **argv ) 27 | { 28 | if( argc < 2 ) 29 | { 30 | std::cout << "Usage: "<< argv[0] <<" input_image output_image"< 20 | #include 21 | 22 | #include 23 | #include 24 | 25 | 26 | // Process a single frame of video and return the resulting frame 27 | cv::Mat processFrame( const cv::Mat& inputImage ) 28 | { 29 | // ADD FRAME PROCESSING CODE HERE 30 | return inputImage; 31 | } 32 | 33 | 34 | // Iterate through a video, process each frame, and display the result in a GUI. 35 | void processAndDisplayVideo(cv::VideoCapture& vidCap) 36 | { 37 | double frameRate = vidCap.get( CV_CAP_PROP_FPS ); 38 | int width = vidCap.get( CV_CAP_PROP_FRAME_WIDTH ); 39 | int height = vidCap.get( CV_CAP_PROP_FRAME_HEIGHT ); 40 | 41 | std::string windowName = "Exercise 2: Basic Video Filtering in OpenCV"; 42 | cv::namedWindow( windowName, CV_WINDOW_FREERATIO); 43 | cvResizeWindow( windowName.c_str(), width, height+50 ); 44 | 45 | unsigned delay = 1000 / frameRate; 46 | 47 | cv::Mat frame; 48 | while( vidCap.read(frame) ) 49 | { 50 | cv::Mat outputFrame = processFrame( frame ); 51 | cv::imshow( windowName, outputFrame ); 52 | 53 | if( cv::waitKey(delay) >= 0 ) 54 | { 55 | break; 56 | } 57 | } 58 | } 59 | 60 | 61 | // Iterate through a video, process each frame, and save the processed video. 62 | void processAndSaveVideo(cv::VideoCapture& vidCap, const std::string& filename) 63 | { 64 | double frameRate = vidCap.get( CV_CAP_PROP_FPS ); 65 | int width = vidCap.get( CV_CAP_PROP_FRAME_WIDTH ); 66 | int height = vidCap.get( CV_CAP_PROP_FRAME_HEIGHT ); 67 | 68 | int fourcc = CV_FOURCC('D','I','V','X'); 69 | cv::VideoWriter vidWrite( filename, fourcc, frameRate, 70 | cvSize(width, height) ); 71 | cv::Mat frame; 72 | while( vidCap.read(frame) ) 73 | { 74 | cv::Mat outputFrame = processFrame( frame ); 75 | vidWrite << outputFrame; 76 | } 77 | } 78 | 79 | 80 | int main ( int argc, char **argv ) 81 | { 82 | if( argc < 2 ) 83 | { 84 | std::cout << "Usage: "<< argv[0] <<" input_image output_image"< 20 | #include 21 | 22 | #include 23 | #include 24 | 25 | 26 | // Process a single frame of video and return the resulting frame 27 | cv::Mat processFrame( const cv::Mat& inputImage ) 28 | { 29 | cv::Mat grayImage, edgeImage, resultImage; 30 | cv::cvtColor(inputImage, grayImage, CV_BGR2GRAY); 31 | cv::Canny( grayImage, edgeImage, 128, 255 ); 32 | cv::cvtColor(edgeImage, resultImage, CV_GRAY2BGR); 33 | 34 | return resultImage; 35 | } 36 | 37 | 38 | // Iterate through a video, process each frame, and display the result in a GUI. 39 | void processAndDisplayVideo(cv::VideoCapture& vidCap) 40 | { 41 | double frameRate = vidCap.get( CV_CAP_PROP_FPS ); 42 | int width = vidCap.get( CV_CAP_PROP_FRAME_WIDTH ); 43 | int height = vidCap.get( CV_CAP_PROP_FRAME_HEIGHT ); 44 | 45 | std::string windowName = "Exercise 2: Basic Video Filtering in OpenCV"; 46 | cv::namedWindow( windowName, CV_WINDOW_FREERATIO); 47 | cvResizeWindow( windowName.c_str(), width, height+50 ); 48 | 49 | unsigned delay = 1000 / frameRate; 50 | 51 | cv::Mat frame; 52 | while( vidCap.read(frame) ) 53 | { 54 | cv::Mat outputFrame = processFrame( frame ); 55 | cv::imshow( windowName, outputFrame ); 56 | 57 | if( cv::waitKey(delay) >= 0 ) 58 | { 59 | break; 60 | } 61 | } 62 | } 63 | 64 | 65 | // Iterate through a video, process each frame, and save the processed video. 66 | void processAndSaveVideo(cv::VideoCapture& vidCap, const std::string& filename) 67 | { 68 | double frameRate = vidCap.get( CV_CAP_PROP_FPS ); 69 | int width = vidCap.get( CV_CAP_PROP_FRAME_WIDTH ); 70 | int height = vidCap.get( CV_CAP_PROP_FRAME_HEIGHT ); 71 | 72 | int fourcc = CV_FOURCC('D','I','V','X'); 73 | cv::VideoWriter vidWrite( filename, fourcc, frameRate, 74 | cvSize(width, height) ); 75 | cv::Mat frame; 76 | while( vidCap.read(frame) ) 77 | { 78 | cv::Mat outputFrame = processFrame( frame ); 79 | vidWrite << outputFrame; 80 | } 81 | } 82 | 83 | 84 | int main ( int argc, char **argv ) 85 | { 86 | if( argc < 2 ) 87 | { 88 | std::cout << "Usage: "<< argv[0] <<" input_image output_image"<