Image Registration Lecture 11: VXL March 29, 2005 Prof. Charlene Tsai.

Slides:



Advertisements
Similar presentations
ITK-Overview Insight Software Consortium. What is ITK Image Processing Segmentation Registration No Graphical User Interface (GUI) No Visualization.
Advertisements

The C ++ Language BY Shery khan. The C++ Language Bjarne Stroupstrup, the language’s creator C++ was designed to provide Simula’s facilities for program.
Lecture 3 Getting Started with ITK!. Goals for this lecture Learn how to use Cmake Build ITK Example programs that use ITK.
C++ How to Program, 7/e © by Pearson Education, Inc. All Rights Reserved.
COMP171 Data Structure & Algorithm Tutorial 1 TA: M.Y.Chan.
Copyright © 2008 Pearson Addison-Wesley. All rights reserved. Chapter 12 Separate Compilation Namespaces Simple Make Files (Ignore all class references.
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
 2006 Pearson Education, Inc. All rights reserved Midterm review Introduction to Classes and Objects.
Chapter 16 Templates. Copyright © 2006 Pearson Addison-Wesley. All rights reserved Learning Objectives  Function Templates  Syntax, defining 
U NIVERSITY OF M ASSACHUSETTS A MHERST Department of Computer Science Computer Systems Principles C/C++ Emery Berger and Mark Corner University of Massachusetts.
CS 225 Lab #2 - Pointers, Copy Constructors, Destructors, and DDD.
Guide To UNIX Using Linux Third Edition
Review of C++ Programming Part II Sheng-Fang Huang.
1 The UNIX date command myclock.cpp example The C/C++ time() and ctime() functions myclock2.cpp example Inline function definitions Inline class member.
OOP Languages: Java vs C++
LECTURE LECTURE 17 More on Templates 20 An abstract recipe for producing concrete code.
Image Registration Lecture 7: Getting Started with ITK March 15, 2005 Prof. Charlene Tsai.
CS 376b Introduction to Computer Vision 01 / 22 / 2008 Instructor: Michael Eckmann.
STL Standard Template Library ● Good reference book: – The C++ Standard Library ● A Tutorial and Reference ● by Nicolai M. Josuttis ● 1999 – Addison Wesley.
Computing IV Visual C Introduction with OpenCV Example Xinwen Fu.
C++ How to Program, 8/e © by Pearson Education, Inc. All Rights Reserved. Note: C How to Program, Chapter 22 is a copy of C++ How to Program Chapter.
What is VXL ? Vision Something Libraries A collection of Computer Vision libraries Open Source, grass roots effort, 53 developers –Supported by good community,
A First Book of C++: From Here To There, Third Edition2 Objectives You should be able to describe: Function and Parameter Declarations Returning a Single.
Variables, Functions & Parameter Passing CSci 588 Fall 2013 All material not from online sources copyright © Travis Desell, 2011.
By – Tanvir Alam.  This tutorial offers several things.  You’ll see some neat features of the language.  You’ll learn the right things to google. 
By Noorez Kassam Welcome to JNI. Why use JNI ? 1. You already have significantly large and tricky code written in another language and you would rather.
Creating your first C++ program
CSE 332: C++ Type Programming: Associated Types, Typedefs and Traits A General Look at Type Programming in C++ Associated types (the idea) –Let you associate.
File ▪ File – Unit of logical storage – Aid in manipulating exact sector of file data ▪ Abstract view of secondary physical storage devices ▪ Without files.
Chapter 13. Procedural programming vs OOP  Procedural programming focuses on accomplishing tasks (“verbs” are important).  Object-oriented programming.
Pointers OVERVIEW.
C++ History C++ was designed at AT&T Bell Labs by Bjarne Stroustrup in the early 80's Based on the ‘C’ programming language C++ language standardised in.
Copyright © Curt Hill Generic Classes Template Classes or Container Classes.
C++ Memory Overview 4 major memory segments Key differences from Java
Lecture 3: Getting Started & Input / Output (I/O) “TRON” Copyright 1982 (Walt Disney Productions)
Monday, Jan 6, 2003Kate Gregory with material from Deitel and Deitel CO 204 Object Oriented Programming 2003 Trent University Kate Gregory.
CS 376b Introduction to Computer Vision 01 / 23 / 2008 Instructor: Michael Eckmann.
C++ Programming Part 2 Michael Griffiths Corporate Information and Computing Services The University of Sheffield
Slicer3 for developers – S.Pujol -1- National Alliance for Medical Image Computing Slicer3 Course for developers Sonia Pujol, Ph.D. Surgical Planning Laboratory.
Lecture 19 CIS 208 Wednesday, April 06, Welcome to C++ Basic program style and I/O Class Creation Templates.
C++ / G4MICE Course Session 2 Basic C++ types. Control and Looping Functions in C Function/method signatures and scope.
CIS 234: Project 1 Issues Dr. Ralph D. Westfall April, 2010.
Topic 3: C Basics CSE 30: Computer Organization and Systems Programming Winter 2011 Prof. Ryan Kastner Dept. of Computer Science and Engineering University.
Templates “Generic Programming” ECE Templates A way to write code once that works for many different types of variables –float, int, char, string,
C++ / G4MICE Course Session 1 - Introduction Edit text files in a UNIX environment. Use the g++ compiler to compile a single C++ file. Understand the C++
1 Today’s Objectives  Announcements Homework #3 is due on Monday, 10-Jul, however you can earn 10 bonus points for this HW if you turn it in on Wednesday,
Computer Graphics 3 Lecture 1: Introduction to C/C++ Programming Benjamin Mora 1 University of Wales Swansea Pr. Min Chen Dr. Benjamin Mora.
Fall 2015CISC/CMPE320 - Prof. McLeod1 CISC/CMPE320 Assignment 4 is due Nov. 20 (next Friday). After today you should know everything you need for assignment.
Computing and Statistical Data Analysis Lecture 6 Glen Cowan RHUL Physics Computing and Statistical Data Analysis Introduction to classes and objects:
1 Becoming More Effective with C++ … Day Two Stanley B. Lippman
Today… “Hello World” ritual. Brief History of Java & How Java Works. Introduction to Java class structure. But first, next slide shows Java is No. 1 programming.
1 Classes II Chapter 7 2 Introduction Continued study of –classes –data abstraction Prepare for operator overloading in next chapter Work with strings.
Lecture Set 2 Part A: Creating an Application with Visual Studio – Solutions, Projects, Files 8/10/ :35 PM.
Lecture 01a: C++ review Topics: Setting up projects, main program Memory Diagrams Variables / Types (some of) the many-types-of-const's Input / Output.
CSE 332: C++ pointers, arrays, and references Overview of Pointers and References Often need to refer to another object –Without making a copy of the object.
CSIS 123A Lecture 7 Static variables, destructors, & namespaces.
Fall 2015CISC/CMPE320 - Prof. McLeod1 CISC/CMPE320 Assignment 4 is due Nov. 20 (this Friday). Today: –Templates. –STL –Smart Pointers.
Module 9: Operator overloading #1 2000/01Scientific Computing in OOCourse code 3C59 Module 9: Operator Overloading In this module we will cover Overloading.
C++ Functions A bit of review (things we’ve covered so far)
Defining Data Types in C++ Part 2: classes. Quick review of OOP Object: combination of: –data structures (describe object attributes) –functions (describe.
C++ Programming Michael Griffiths Corporate Information and Computing Services The University of Sheffield
Unit 10 Code Reuse. Key Concepts Abstraction Header files Implementation files Storage classes Exit function Conditional compilation Command-line arguments.
Eine By: Avinash Reddy 09/29/2016.
The Machine Model Memory
APPENDIX a WRITING SUBROUTINES IN C
ITK-Overview Insight Software Consortium.
Tonga Institute of Higher Education
What is VXL ? Vision Something Libraries
ENERGY 211 / CME 211 Lecture 29 December 3, 2008.
SPL – PS1 Introduction to C++.
Presentation transcript:

Image Registration Lecture 11: VXL March 29, 2005 Prof. Charlene Tsai

Image RegistrationLecture 11 2 VXL - History  Early 1990’s:  GE’s TargetJr  DARPA’s Image Understanding Environment (IUE)  Both are complicated and cumbersome  VXL (1999-present):  Rewrite / retain best of TargetJr and IUE  Stresses simplicity and discipline  Early 1990’s:  GE’s TargetJr  DARPA’s Image Understanding Environment (IUE)  Both are complicated and cumbersome  VXL (1999-present):  Rewrite / retain best of TargetJr and IUE  Stresses simplicity and discipline

Image RegistrationLecture 11 3 VXL - Warning  High-quality code, but not professional  Documentation, while good, is somewhat spartan  Not as many examples as ITK  No significant notion of releases  Outside the core, development code is mixed with stable code  We will not touch this development code, except in the actual registration library  High-quality code, but not professional  Documentation, while good, is somewhat spartan  Not as many examples as ITK  No significant notion of releases  Outside the core, development code is mixed with stable code  We will not touch this development code, except in the actual registration library

Image RegistrationLecture 11 4 VXL Documentation  Homepage   VXL “Book”  Linked from the homepage  ks/core/book.html  Homepage   VXL “Book”  Linked from the homepage  ks/core/book.html

Image RegistrationLecture 11 5 VXL Layout - Overview  src/vcl -  Fixes for “non-standard” compiler  src/core  Main vxl libraries, fairly stable  src/v3p  3rd party code, such as jpeg, mpeg2, netlib…  src/contrib  Libraries written at contributing sites  Code has not yet been “promoted” to the core  We will use a restricted subset of the contributed libraries  src/vcl -  Fixes for “non-standard” compiler  src/core  Main vxl libraries, fairly stable  src/v3p  3rd party code, such as jpeg, mpeg2, netlib…  src/contrib  Libraries written at contributing sites  Code has not yet been “promoted” to the core  We will use a restricted subset of the contributed libraries

Image RegistrationLecture 11 6 VXL - Copying from the Website  Copy source into a different directory from the Insight (ITK) source!  You can rename the source direction to anything you wish (as long as it is meaningful to you)  Copy source into a different directory from the Insight (ITK) source!  You can rename the source direction to anything you wish (as long as it is meaningful to you)

Image RegistrationLecture 11 7 Configuring VXL  Out of tree build is recommended, just as with ITK  In my course software directory I have four primary subdirectories:  itk_src, itk_bin, vxl_src, vxl_bin  I will use the names vxl_src and vxl_bin generically to refer to the main source and binary directories  Out of tree build is recommended, just as with ITK  In my course software directory I have four primary subdirectories:  itk_src, itk_bin, vxl_src, vxl_bin  I will use the names vxl_src and vxl_bin generically to refer to the main source and binary directories

Image RegistrationLecture 11 8 Configuring VXL - MS-Windows  Run CMake, just as you did with ITK  Select the SOURCE directory, the BINARY directory, and your compiler  Disable BUILD_EXAMPLES  Disable BUILD_SHARED_LIBS  Disable BUILD_TESTING  Click “Configure”  Click “Ok”  Run CMake, just as you did with ITK  Select the SOURCE directory, the BINARY directory, and your compiler  Disable BUILD_EXAMPLES  Disable BUILD_SHARED_LIBS  Disable BUILD_TESTING  Click “Configure”  Click “Ok”

Image RegistrationLecture 11 9 Configuring VXL - Unix  Create the BINARY directory  Change directory to the BINARY directory  Set the environment variables for the compiler: CC and CXX  Type ccmake with argument the SOURCE directory  Create the BINARY directory  Change directory to the BINARY directory  Set the environment variables for the compiler: CC and CXX  Type ccmake with argument the SOURCE directory

Image RegistrationLecture Configuring VXL - Unix  Disable BUILD_EXAMPLES  Enable BUILD_SHARED_LIBS  Disable BUILD_TESTING  Type “c” to configure  Type “g” to generate (ends ccmake)  Type “make” (in the top-level bin directory)  Disable BUILD_EXAMPLES  Enable BUILD_SHARED_LIBS  Disable BUILD_TESTING  Type “c” to configure  Type “g” to generate (ends ccmake)  Type “make” (in the top-level bin directory)

Image RegistrationLecture Building VXL - MS-Windows (VC 6.0)  Open vxl.dsw in the Binary Directory  Select ALL_BUILD project  Build it …It will take more than 15 minutes…  Open vxl.dsw in the Binary Directory  Select ALL_BUILD project  Build it …It will take more than 15 minutes…

Image RegistrationLecture Building VXL - MS-Windows (VC.NET)  Open vxl.sln in the Binary Directory  Select ALL_BUILD project  Build it …It will take more than 15 minutes …  Open vxl.sln in the Binary Directory  Select ALL_BUILD project  Build it …It will take more than 15 minutes …

Image RegistrationLecture Verifying the Build  Libraries will be found in  In MS-Windows  vxl_bin / lib / { Debug, Release }  In UNIX  vxl_bin / lib  Libraries will be found in  In MS-Windows  vxl_bin / lib / { Debug, Release }  In UNIX  vxl_bin / lib

Image RegistrationLecture Verifying the Build  Many libraries  From the core: vcl, vcl, vgl, vgl_algo, vidl, vnl, vnl_algo, vsl, vul  Third-party: netlib, ….  The number of entries here depends on how many “built-in” libraries were found  From contrib: mbl, rrel, rsdl  Many libraries  From the core: vcl, vcl, vgl, vgl_algo, vidl, vnl, vnl_algo, vsl, vul  Third-party: netlib, ….  The number of entries here depends on how many “built-in” libraries were found  From contrib: mbl, rrel, rsdl

Image RegistrationLecture VXL - Hello World Example #include int main() { vcl_cout << "VXL Hello world!" << vcl_endl; return 0; }

Image RegistrationLecture Hello World Compilation  Two options:  Follow the instructions for writing your own CMakeLists.txt files from Lecture 6 (recommended).  Create code under the main source in vxl_src/contrib/rpl  We’ll follow the latter, for now  Two options:  Follow the instructions for writing your own CMakeLists.txt files from Lecture 6 (recommended).  Create code under the main source in vxl_src/contrib/rpl  We’ll follow the latter, for now

Image RegistrationLecture Hello World - CMake  Create subdirectory vxl_src/contrib/rpl/course and place the source code in a file called hello_world.cxx in the new subdirectory  Edit vxl_src/contrib/rpl/CMakeLists.txt  Add line SUBDIRS( course )  Create rpl/course/CMakeLists.txt with just two lines in it: ADD_EXECUTABLE( hello_world hello_world.cxx ) TARGET_LINK_LIBRARIES( vcl )  Create subdirectory vxl_src/contrib/rpl/course and place the source code in a file called hello_world.cxx in the new subdirectory  Edit vxl_src/contrib/rpl/CMakeLists.txt  Add line SUBDIRS( course )  Create rpl/course/CMakeLists.txt with just two lines in it: ADD_EXECUTABLE( hello_world hello_world.cxx ) TARGET_LINK_LIBRARIES( vcl )

Image RegistrationLecture Building Hello World - MS-Windows  Run CMake again (click “Configure”, click “Ok”)  Open vxl.dsw (or.sln) generated by CMake  Select hello_world project  Build it  Locate the file hello_world.exe in vxl_bin/contrib/rpl/courses/{ Debug, Release }  Run CMake again (click “Configure”, click “Ok”)  Open vxl.dsw (or.sln) generated by CMake  Select hello_world project  Build it  Locate the file hello_world.exe in vxl_bin/contrib/rpl/courses/{ Debug, Release }

Image RegistrationLecture Building Hello World - Unix  Change into vxl_bin/contrib/rpl  Run make  This creates the courses subdirectory and compiles hello_world.cxx  The executable is in the new courses subdirectory.  Change into vxl_bin/contrib/rpl  Run make  This creates the courses subdirectory and compiles hello_world.cxx  The executable is in the new courses subdirectory.

Image RegistrationLecture VXL - src/vcl  Written to allow use of compilers that aren’t (weren’t at the time) standards-compliant  Combination of  Slightly restricted subset of C++  Compiler work-arounds, gathered into one directory.  No use of namespaces  Instead of using std: every name from the standard library is pre-fixed as vcl_  Written to allow use of compilers that aren’t (weren’t at the time) standards-compliant  Combination of  Slightly restricted subset of C++  Compiler work-arounds, gathered into one directory.  No use of namespaces  Instead of using std: every name from the standard library is pre-fixed as vcl_ #include int main() { vcl_cout << "VXL Hello world!" << vcl_endl; return 0; }

Image RegistrationLecture vcl - another example #include //string #include // cout #include // vector #include // copy #include //ostream_iterator int main() { vcl_vector strings; strings.push_back("Hello, "); strings.push_back("World."); vcl_copy(strings.begin(), strings.end(), vcl_ostream_iterator (vcl_cout)); return 0; }

Image RegistrationLecture vcl Header Files  Within directory vcl under top-level source directory  At same level as core and contrib  Each time you would like to type the name of a std library header file, such as foo, instead type vcl_foo.h  This is annoying at first, but after a while you become accustomed to it  Within directory vcl under top-level source directory  At same level as core and contrib  Each time you would like to type the name of a std library header file, such as foo, instead type vcl_foo.h  This is annoying at first, but after a while you become accustomed to it

Image RegistrationLecture VXL Naming Conventions  File names end with .h for header files .cxx for source files .txx for templated source files  We’ll discuss more about templates soon  File names end with .h for header files .cxx for source files .txx for templated source files  We’ll discuss more about templates soon

Image RegistrationLecture vxl_src/core  Many libraries. We are primarily interested in four:  vbl - basic utilities libraries, including arrays, sparse arrays, smart ptr, etc.  vgl - geometric objects libraries  vil - image I/o, representation, views and access  vnl - numerics library  Algorithm libraries sit as subdirectories:  vgl/algo, vil/algo, vnl/algo  Other libraries we may touch  vsl - binary I/0 stream library  vul - utilities for timing, I/o, command-line parameter parsing, etc.  vgui - graphical user-interface  There are still others that we will not touch  Many libraries. We are primarily interested in four:  vbl - basic utilities libraries, including arrays, sparse arrays, smart ptr, etc.  vgl - geometric objects libraries  vil - image I/o, representation, views and access  vnl - numerics library  Algorithm libraries sit as subdirectories:  vgl/algo, vil/algo, vnl/algo  Other libraries we may touch  vsl - binary I/0 stream library  vul - utilities for timing, I/o, command-line parameter parsing, etc.  vgui - graphical user-interface  There are still others that we will not touch

Image RegistrationLecture vbl  A library of basic structures:  Arrays in 1d, 2d, and 3d  Smart pointer  Bounding box  Sparse arrays  We’ll discuss the first two  A library of basic structures:  Arrays in 1d, 2d, and 3d  Smart pointer  Bounding box  Sparse arrays  We’ll discuss the first two

Image RegistrationLecture vbl_array_2d #include int main() { vbl_array_2d example( 3, 5 ); example.fill( 1 ); for ( int i = 0; i < example.rows() && i < example.cols(); ++i ) example(i, i ) = 10-i; vcl_cout << "The example array has " << example.rows() << " rows and " << example.cols() << " columns\n" << "Here are the contents: \n" << example << vcl_endl; return 0; } Note paths of header files Templated object

Image RegistrationLecture Changes to CMakeLists.txt  Placed in same directory as my hello world program  My CMakeLists.txt file is now  For MS-Windows you need to re-run Cmake, which will detect the changes.  For UNIX you do not need to re-run ccmake explicitly. Running make in the bin directory will re-run cmake automatically, as necessary.  Placed in same directory as my hello world program  My CMakeLists.txt file is now  For MS-Windows you need to re-run Cmake, which will detect the changes.  For UNIX you do not need to re-run ccmake explicitly. Running make in the bin directory will re-run cmake automatically, as necessary. ADD_EXECUTABLE( hello_world hello_world.cxx ) ADD_EXECUTABLE( vbl_array_example main_vbl_array.cxx ) TARGET_LINK_LIBRARIES( hello_world vcl ) TARGET_LINK_LIBRARIES( vbl_array_example vcl vbl )

Image RegistrationLecture Naming Conventions in VXL  File names tend to be the same as the single class the file defines  vbl_array_2d.h, vbl_array_2d.txx  All objects and files in directory are prefaced with the name of the library  Avoids name clashes  Makes finding objects simple  It’s a bit annoying as well  File names tend to be the same as the single class the file defines  vbl_array_2d.h, vbl_array_2d.txx  All objects and files in directory are prefaced with the name of the library  Avoids name clashes  Makes finding objects simple  It’s a bit annoying as well

Image RegistrationLecture Templates and Template Instantiation  Template classes and functions are specified in both.h and.txx files  Vbl_array_2d.txx is pretty small, but this isn’t always the case  Template instantiation is done explicitly rather than implicitly (as in ITK)  Each.txx has a C++ instantiation macro at the end. Here is the one from vbl_array_2d.txx #undef VBL_ARRAY_2D_INSTANTIATE #define VBL_ARRAY_2D_INSTANTIATE(type) \ template class vbl_array_2d ;\ template vcl_ostream& operator const& )  Source directories will often have subdirectories called Templates, where templated classes and functions are instantiated explicitly.  CMake finds and compiles these instantiation files automatically, without having to specify the file names in CMakeLists.txt  Template classes and functions are specified in both.h and.txx files  Vbl_array_2d.txx is pretty small, but this isn’t always the case  Template instantiation is done explicitly rather than implicitly (as in ITK)  Each.txx has a C++ instantiation macro at the end. Here is the one from vbl_array_2d.txx #undef VBL_ARRAY_2D_INSTANTIATE #define VBL_ARRAY_2D_INSTANTIATE(type) \ template class vbl_array_2d ;\ template vcl_ostream& operator const& )  Source directories will often have subdirectories called Templates, where templated classes and functions are instantiated explicitly.  CMake finds and compiles these instantiation files automatically, without having to specify the file names in CMakeLists.txt

Image RegistrationLecture Templates, continued  For example, there are six files for instantiating vbl_array_2d objects in vbl/Templates: vbl_array_2d+bool-.cxx vbl_array_2d+double-.cxx vbl_array_2d+int-.cxx vbl_array_2d+short-.cxx vbl_array_2d+unsigned-.cxx vbl_array_2d+unsignedchar-.cxx  Here is the interior of vbl_array_2d+int-.cxx #include VBL_ARRAY_2D_INSTANTIATE(int);  Note: if you were instantiating a templated object to contain a class that you had defined, you would have to #include that class’s.h file as well  For example, there are six files for instantiating vbl_array_2d objects in vbl/Templates: vbl_array_2d+bool-.cxx vbl_array_2d+double-.cxx vbl_array_2d+int-.cxx vbl_array_2d+short-.cxx vbl_array_2d+unsigned-.cxx vbl_array_2d+unsignedchar-.cxx  Here is the interior of vbl_array_2d+int-.cxx #include VBL_ARRAY_2D_INSTANTIATE(int);  Note: if you were instantiating a templated object to contain a class that you had defined, you would have to #include that class’s.h file as well

Image RegistrationLecture Where to Put Template Instantiations?  Generic, widely used instantiations are placed where the templated class is declared  E.g. vbl/Templates  More specialized instantiations involving user-defined classes are placed with the user-defined class.  For example, if you created a class myl_foo in directory myl, then an instantiation file would be placed in myl/Templates:  vbl_array_2d+myl_foo-.cxx  Generic, widely used instantiations are placed where the templated class is declared  E.g. vbl/Templates  More specialized instantiations involving user-defined classes are placed with the user-defined class.  For example, if you created a class myl_foo in directory myl, then an instantiation file would be placed in myl/Templates:  vbl_array_2d+myl_foo-.cxx

Image RegistrationLecture Templates, Final Comments  Remember: you do not need to change anything in vxl_src/vcl, vxl_src/core or vxl_src/contrib to use templated classes declared there.  We don’t anticipate that you will be writing your own templated classes or functions  You may need to write your own template instantiations  Work from examples and look at Appendix C of the vxl book.  Remember: you do not need to change anything in vxl_src/vcl, vxl_src/core or vxl_src/contrib to use templated classes declared there.  We don’t anticipate that you will be writing your own templated classes or functions  You may need to write your own template instantiations  Work from examples and look at Appendix C of the vxl book.

Image RegistrationLecture Smart Pointers in VXL  Automatic deletion of reference counted objects so that you don’t need to keep track of pointers  Never invoke delete on a smart pointer!  What’s needed to use smart pointers in vxl:  Class pointed to from a smart pointer must inherit from vbl_ref_count  Smart pointer class vbl_smart_ptr is templated  Automatic deletion of reference counted objects so that you don’t need to keep track of pointers  Never invoke delete on a smart pointer!  What’s needed to use smart pointers in vxl:  Class pointed to from a smart pointer must inherit from vbl_ref_count  Smart pointer class vbl_smart_ptr is templated

Image RegistrationLecture Simple Smart Pointer Example #include class big_foo : public vbl_ref_count { public: big_foo( double dflt=0.0 ) { for ( int i=0; i<1024; ++i ) data[i] = dflt; } double get( int i ) const { return data[i]; } void set( int i, double x ) { data[i] = x; } private: double data[1024]; }; // Create a typedef for the big_foo smart pointer typedef vbl_smart_ptr big_foo_sptr;

Image RegistrationLecture Simple Smart Pointer Example int main() { big_foo_sptr p = new big_foo( 1.0 ); { big_foo_sptr q = p; // alias q->set( 0, 23.0 ); } // q is out of scope so it is gone // p remains, but its data has been changed. vcl_cout << "p's first value = " get( 0 ) << vcl_endl; return 0; } // Instantiating here. This isn't the common practice #include VBL_SMART_PTR_INSTANTIATE(big_foo);

Image RegistrationLecture vil  Image representation and access library  2d images only and no associated physical coordinates  Reflects difference between medical images and video images  A 3d image library exists in vxl_src/contrib/mul  Image processing and feature detection algorithms exist in subdirectory vil/algo  Image representation and access library  2d images only and no associated physical coordinates  Reflects difference between medical images and video images  A 3d image library exists in vxl_src/contrib/mul  Image processing and feature detection algorithms exist in subdirectory vil/algo

Image RegistrationLecture vil - Basic Operations  Load images using vil_load  Save images using vil_save  Access pixels using a vil_image_view  Load images using vil_load  Save images using vil_save  Access pixels using a vil_image_view

Image RegistrationLecture vil - Threshold Example #include int main(int argc, char **argv) { vil_image_view img; img = vil_load(argv[1]); for (unsigned j = 0; j < img.nj(); ++j) for (unsigned i = 0; i < img.ni(); ++i) if (img(i,j) < 200 ) img(i,j) = vxl_byte(0); vil_save(img, argv[2]); return 0; }

Image RegistrationLecture vil/algo  Image analysis algorithms are in a subdirectory of vxl_src/core/vil called algo  Examples include morphological openings and closings, smoothing operators, Sobel edge detectors, etc.  Placing algorithms in an algo subdirectory is also used in the numerics and geometry libraries  Image analysis algorithms are in a subdirectory of vxl_src/core/vil called algo  Examples include morphological openings and closings, smoothing operators, Sobel edge detectors, etc.  Placing algorithms in an algo subdirectory is also used in the numerics and geometry libraries

Image RegistrationLecture vil/algo - Example #include #include // generated file #include #include // vnl_math_rnd int main(int argc, char **argv) { vil_image_view img; img = vil_load(argv[1]); vil_image_view line_dir; // results storage vil_image_view line_str; // Apply line finder vil_line_filter line_filter; line_filter. dark_lines_5x5( line_dir, line_str, img );

Image RegistrationLecture vil/algo - Example // Find the maximum strength line output float max_str = 0.0; for ( unsigned int i=0; i<line_str.ni(); ++i ) for ( unsigned int j=0; j<line_str.nj(); ++j ) if ( line_str(i,j) > max_str ) max_str = line_str(i,j); // Create scaled image of results vil_image_view scaled_results( line_str.ni(), line_str.nj() ); for ( unsigned int i=0; i<line_str.ni(); ++i ) for ( unsigned int j=0; j<line_str.nj(); ++j ) scaled_results(i,j) = vnl_math_rnd( line_str(i,j) / max_str * 255 ); vil_save(scaled_results, argv[2]); return 0; }

Image RegistrationLecture vil/algo - Example Results

Image RegistrationLecture vil vs. vil1  You will see references for the library vil1  The imaging library was completely rewritten and improved significantly last year  Most libraries have been rewritten, but a few, such as vidl have not.  This is not a major concern, but don’t let yourself be confused by it  You will see references for the library vil1  The imaging library was completely rewritten and improved significantly last year  Most libraries have been rewritten, but a few, such as vidl have not.  This is not a major concern, but don’t let yourself be confused by it

Image RegistrationLecture vnl  Numerics library  Shared with ITK, although it is usually buried inside higher-level classes  vnl/ contains  Vectors and their (compile-time) fixed specializations  Matrices and sparse matrices  vnl_math.h - handy things like vnl_math_rnd which you wish math.h had  Quaternions  vnl/algo  SVD and other matrix decompositions  Various optimization techniques  Numerics library  Shared with ITK, although it is usually buried inside higher-level classes  vnl/ contains  Vectors and their (compile-time) fixed specializations  Matrices and sparse matrices  vnl_math.h - handy things like vnl_math_rnd which you wish math.h had  Quaternions  vnl/algo  SVD and other matrix decompositions  Various optimization techniques

Image RegistrationLecture vnl and vnl/algo - SVD Example #include int main() { vnl_vector p(4); // 4-component vector p(0) = 1.0; p(1) = 0.3; p(2) = -0.5; p(3) = 2.0; // 4x4 matrix, filled with 0.0 vnl_matrix m(4, 4, 0.0); m(0,0) = 1.0; m(0,1) = 5.0; m(0,2) = -2.0; m(0,3) = 0.5; m(1,0) = 0.0; m(1,1) = 1.0; m(1,2) = 3.0; m(1,3) = -3.0; m(2,0) = -2.0; m(2,1) = 15.0; m(2,2) = 4.0; m(2,3) = 0.5; m(3,0) = 1.0; m(3,1) = -0.2; m(3,2) = 1.0; m(3,3) = 9.5;

Image RegistrationLecture vnl and vnl/algo - SVD Example vcl_cout << "p = " << p << "\n" << "m = \n" << m << "\n" << vcl_endl; // The computation of the svd is computed in the constructor. vnl_svd svd(m); vcl_cout << "SVD of m:\n" << "U = " << svd.U() << "\n" << "V = " << svd.V() << vcl_endl; vcl_cout << "Singular values: "; for ( unsigned int i=0; i<4; ++i ) vcl_cout << svd.W(i) << " "; vcl_cout << vcl_endl; return 0; }

Image RegistrationLecture vgl  Geometric library  Represent points, lines, planes, polygons, ellipses, etc…  Very few numerical techniques in vgl  Prevents dependence between vgl and vnl  Numerical techniques are in vgl/algo  Geometric library  Represent points, lines, planes, polygons, ellipses, etc…  Very few numerical techniques in vgl  Prevents dependence between vgl and vnl  Numerical techniques are in vgl/algo

Image RegistrationLecture Command Lines and GUIs  Many programs can be written and run from the command-line  Use other programs - xv, matlab, etc. to view images and results  vgui  Graphical interface  See xcv and the vxl book  Many programs can be written and run from the command-line  Use other programs - xv, matlab, etc. to view images and results  vgui  Graphical interface  See xcv and the vxl book

Image RegistrationLecture vxl_src/contrib  Contributed libraries  Some excellent code, but “use at your own risk”  We will concentrate on the Rensselaer library  rgrl - the generalized registration library  rrel - the robust estimation library  rsdl - the spatial data structures library  Lecture 12 will focus on rgrl  Contributed libraries  Some excellent code, but “use at your own risk”  We will concentrate on the Rensselaer library  rgrl - the generalized registration library  rrel - the robust estimation library  rsdl - the spatial data structures library  Lecture 12 will focus on rgrl

Image RegistrationLecture Summary  Read the book!  Look at the.h files and the documentation  Read the book!  Look at the.h files and the documentation