1 ITK Lecture 8 - Neighborhoods Methods in Image Analysis CMU Robotics Institute 16-725 U. Pitt Bioengineering 2630 Spring Term, 2006 Methods in Image.

Slides:



Advertisements
Similar presentations
College of Information Technology & Design
Advertisements

Incremental Linear Programming Linear programming involves finding a solution to the constraints, one that maximizes the given linear function of variables.
This work by John Galeotti and Damion Shelton, © , was made possible in part by NIH NLM contract# HHSN P, and is licensed under a Creative.
MATH 224 – Discrete Mathematics
Practice Quiz Question
Sliding Window Filters and Edge Detection Longin Jan Latecki Computer Graphics and Image Processing CIS 601 – Fall 2004.
1 ITK Lecture 7 - Writing Filters, Part 1 Methods in Image Analysis CMU Robotics Institute U. Pitt Bioengineering 2630 Spring Term, 2006 Methods.
Methods in Image Analysis 2004, Damion Shelton 1 ITK Lecture 6 - The Pipeline Methods in Image Analysis CMU Robotics Institute U. Pitt Bioengineering.
Image Filtering CS485/685 Computer Vision Prof. George Bebis.
Complexity Analysis (Part I)
Segmentation Divide the image into segments. Each segment:
Gradient Methods May Preview Background Steepest Descent Conjugate Gradient.
Digital Image Processing, 2nd ed. www. imageprocessingbook.com © 2001 R. C. Gonzalez & R. E. Woods 1 Objective To provide background material in support.
1 CS 201 Passing Function as Parameter & Array Debzani Deb.
1 Image filtering
Arrays Data Structures - structured data are data organized to show the relationship among the individual elements. It usually requires a collecting mechanism.
CS4670: Computer Vision Kavita Bala Lecture 7: Harris Corner Detection.
Computer Vision Lecture 3: Digital Images
Binary Arithmetic Math For Computers.
The Game of Algebra or The Other Side of Arithmetic The Game of Algebra or The Other Side of Arithmetic © 2007 Herbert I. Gross by Herbert I. Gross & Richard.
Chapter 6Java: an Introduction to Computer Science & Programming - Walter Savitch 1 l Array Basics l Arrays in Classes and Methods l Programming with Arrays.
Edge Detection Hao Huy Tran Computer Graphics and Image Processing CIS 581 – Fall 2002 Professor: Dr. Longin Jan Latecki.
Digital Image Processing
Chapter 6.7 Determinants. In this chapter all matrices are square; for example: 1x1 (what is a 1x1 matrix, in fact?), 2x2, 3x3 Our goal is to introduce.
The mileage of a certain car can be approximated by: At what speed should you drive the car to obtain the best gas mileage? Of course, this problem isn’t.
CS559: Computer Graphics Lecture 3: Digital Image Representation Li Zhang Spring 2008.
Section 2: Finite Element Analysis Theory
Lecture 8. How to Form Recursive relations 1. Recap Asymptotic analysis helps to highlight the order of growth of functions to compare algorithms Common.
CSEB114: PRINCIPLE OF PROGRAMMING Chapter 8: Arrays.
Scientific Computing Partial Differential Equations Poisson Equation.
Basis beeldverwerking (8D040) dr. Andrea Fuster Prof.dr. Bart ter Haar Romeny dr. Anna Vilanova Prof.dr.ir. Marcel Breeuwer Convolution.
Analysis of Algorithms
Chapter 3 Sec 3.3 With Question/Answer Animations 1.
The content of these slides by John Galeotti, © Carnegie Mellon University (CMU), was made possible in part by NIH NLM contract# HHSN P,
Digital Image Processing Lecture12: Basics of Spatial Filtering.
1 EEE 431 Computational Methods in Electrodynamics Lecture 4 By Dr. Rasime Uyguroglu
Digital Image Processing CCS331 Relationships of Pixel 1.
Methods in Image Analysis 2004, Damion Shelton 1 ITK Lecture 9 - Toolbox Part I Methods in Image Analysis CMU Robotics Institute U. Pitt Bioengineering.
CSC 211 Data Structures Lecture 13
1 ITK Lecture 9 - Toolbox Part I Methods in Image Analysis CMU Robotics Institute U. Pitt Bioengineering 2630 Spring Term, 2006 Methods in Image.
CSC 221: Recursion. Recursion: Definition Function that solves a problem by relying on itself to compute the correct solution for a smaller version of.
© 2004 Pearson Addison-Wesley. All rights reserved October 15, 2007 Searching ComS 207: Programming I (in Java) Iowa State University, FALL 2007 Instructor:
CSC508 Convolution Operators. CSC508 Convolution Arguably the most fundamental operation of computer vision It’s a neighborhood operator –Similar to the.
October 7, 2014Computer Vision Lecture 9: Edge Detection II 1 Laplacian Filters Idea: Smooth the image, Smooth the image, compute the second derivative.
CS654: Digital Image Analysis Lecture 5: Pixels Relationships.
Hashing 1 Hashing. Hashing 2 Hashing … * Again, a (dynamic) set of elements in which we do ‘search’, ‘insert’, and ‘delete’ n Linear ones: lists, stacks,
CPSC 252 Hashing Page 1 Hashing We have already seen that we can search for a key item in an array using either linear or binary search. It would be better.
Advanced Engineering Mathematics, 7 th Edition Peter V. O’Neil © 2012 Cengage Learning Engineering. All Rights Reserved. CHAPTER 4 Series Solutions.
Chapter 1 First-Order Differential Equations Shurong Sun University of Jinan Semester 1,
1 Arrays of Arrays An array can represent a collection of any type of object - including other arrays! The world is filled with examples Monthly magazine:
1 ITK Lecture 6 - The Pipeline Methods in Image Analysis CMU Robotics Institute U. Pitt Bioengineering 2630 Spring Term, 2006 Methods in Image Analysis.
1 ITK Lecture 5 Intro to Iterators Methods in Image Analysis CMU Robotics Institute U. Pitt Bioengineering 2630 Spring Term, 2006 Methods in Image.
Onlinedeeneislam.blogspot.com1 Design and Analysis of Algorithms Slide # 1 Download From
CS 1114: Finding things Prof. Graeme Bailey (notes modified from Noah Snavely, Spring 2009)
Last Lecture photomatix.com. Today Image Processing: from basic concepts to latest techniques Filtering Edge detection Re-sampling and aliasing Image.
CS 31 Discussion, Week 7 Faisal Alquaddoomi, Office Hours: BH 2432, W 4:30-6:30pm, F 12:30-1:30pm.
Chapter 15 Running Time Analysis. Topics Orders of Magnitude and Big-Oh Notation Running Time Analysis of Algorithms –Counting Statements –Evaluating.
Introduction to Algorithms
Lecture 19 ITK Filters: How to Write Them
Mean Shift Segmentation
Computer Vision Lecture 9: Edge Detection II
Digital Image Processing
a kind of filtering that leads to useful features
a kind of filtering that leads to useful features
Discrete Mathematics CMP-101 Lecture 12 Sorting, Bubble Sort, Insertion Sort, Greedy Algorithms Abdul Hameed
CS-447– Computer Architecture Lecture 20 Cache Memories
Real-Valued Functions
Slope Fields and Euler’s Method
Hashing.
Computer and Robot Vision I
Presentation transcript:

1 ITK Lecture 8 - Neighborhoods Methods in Image Analysis CMU Robotics Institute U. Pitt Bioengineering 2630 Spring Term, 2006 Methods in Image Analysis CMU Robotics Institute U. Pitt Bioengineering 2630 Spring Term, 2006 Damion Shelton

2 Goals for this lecture  Understand what a neighborhood is and and the different ways of accessing pixels using one  Use neighborhoods to implement a convolution/correlation filter  Understand what a neighborhood is and and the different ways of accessing pixels using one  Use neighborhoods to implement a convolution/correlation filter

3 What is a neighborhood?  You may already be familiar with the concept of pixels having neighbors  Standard terminology in 2D image processing will refer to the 4 neighborhood (N,E,S,W) and the 8 neighborhood (4 neighborhood + NE, SE, SW, NW)  You may already be familiar with the concept of pixels having neighbors  Standard terminology in 2D image processing will refer to the 4 neighborhood (N,E,S,W) and the 8 neighborhood (4 neighborhood + NE, SE, SW, NW)

4 Neighborhoods in ITK  ITK carries this concept a bit further  A neighborhood can be any collection of pixels that have a fixed relationship to the “center” based on offsets in data space  See 11.4 in the ITK Software Guide  ITK carries this concept a bit further  A neighborhood can be any collection of pixels that have a fixed relationship to the “center” based on offsets in data space  See 11.4 in the ITK Software Guide

5 Neighborhoods in ITK, cont.  In general, the neighborhood is not completely arbitrary  Neighborhoods are rectangular, defined by a “radius” in N-dimensions  ShapedNeighborhoods are arbitrary, defined by a list of offsets from the center  The first form is most useful for mathematical morphology kinds of operations, convolution, etc.  In general, the neighborhood is not completely arbitrary  Neighborhoods are rectangular, defined by a “radius” in N-dimensions  ShapedNeighborhoods are arbitrary, defined by a list of offsets from the center  The first form is most useful for mathematical morphology kinds of operations, convolution, etc.

6 Neighborhood iterators  The cool & useful thing about neighborhoods is that they can be used with neighborhood iterators to allow efficient access to pixels “around” a target pixel in an image

7 Neighborhood iterators  Remember that I said access via pixel indices was slow?  Get current index = I  Upper left pixel index I UL = I - (1,1)  Get pixel at index I UL  Neighborhood iterators solve this problem by doing pointer arithmetic based on offsets  Remember that I said access via pixel indices was slow?  Get current index = I  Upper left pixel index I UL = I - (1,1)  Get pixel at index I UL  Neighborhood iterators solve this problem by doing pointer arithmetic based on offsets

8 Neighborhood layout  Neighborhoods have one primary parameter, their “radius” in N- dimensions  The side length along a particular dimension i is 2*radius i + 1  Note that the side length is always odd because the center pixel always exists  Neighborhoods have one primary parameter, their “radius” in N- dimensions  The side length along a particular dimension i is 2*radius i + 1  Note that the side length is always odd because the center pixel always exists

9 A 2x1 neighborhood in 2D

10 Stride  Neighborhoods have another parameter called stride which is the spacing (in data space) along a particular axis between adjacent pixels in the neighborhood  In the previous numbering scheme, stride in Y is amount then index value changes when you move in Y  In our example, Stride x = 1, Stride y = 5  Neighborhoods have another parameter called stride which is the spacing (in data space) along a particular axis between adjacent pixels in the neighborhood  In the previous numbering scheme, stride in Y is amount then index value changes when you move in Y  In our example, Stride x = 1, Stride y = 5

11 Neighborhood pixel access  The numbering on the previous page is important! It’s how you access that particular pixel when using a neighborhood iterator  This will be clarified in a few slides...  The numbering on the previous page is important! It’s how you access that particular pixel when using a neighborhood iterator  This will be clarified in a few slides...

12 NeighborhoodIterator access  Neighborhood iterators are created using:  The radius of the neighborhood  The image that will be traversed  The region of the image to be traversed  Their syntax largely follows that of other iterators (++, IsAtEnd(), etc.)  Neighborhood iterators are created using:  The radius of the neighborhood  The image that will be traversed  The region of the image to be traversed  Their syntax largely follows that of other iterators (++, IsAtEnd(), etc.)

13 Neighborhood pixel access, cont Let’s say there’s some region of an image that has the following pixel values

14 Pixel access, cont.  Now assume that we place the neighborhood iterator over this region and start accessing pixels  What happens?  Now assume that we place the neighborhood iterator over this region and start accessing pixels  What happens?

15 Pixel access, cont myNeigh.GetPixel(7) returns 0.7 so does myNeigh.GetCenterPixel()

16 Pixel access, cont. Next, let’s get the length of the iterator and the stride length Size() returns the #pixels in the neighborhood unsigned int c = iterator. Size () / 2; GetStride returns the stride of dimension N unsigned int s = iterator. GetStride(1); Next, let’s get the length of the iterator and the stride length Size() returns the #pixels in the neighborhood unsigned int c = iterator. Size () / 2; GetStride returns the stride of dimension N unsigned int s = iterator. GetStride(1);

17 Pixel access, cont myNeigh.GetPixel(c) returns 0.7 myNeigh.GetPixel(c-1) returns 1.1

18 Pixel access, cont myNeigh.GetPixel(c-s) returns 1.8 myNeigh.GetPixel(c-s-1) returns 1.3

19 The ++ method  In ImageRegionIterators, the ++ method moves the focus of the iterator on a per pixel basis  In NeighborhoodIterators, the ++ method moves the center pixel of the neighborhood and therefore implicitly shifts the entire neighborhood  In ImageRegionIterators, the ++ method moves the focus of the iterator on a per pixel basis  In NeighborhoodIterators, the ++ method moves the center pixel of the neighborhood and therefore implicitly shifts the entire neighborhood

20 Does this sound familiar?  If I say:  I have a region of interest defined by a certain radius around a center pixel  The ROI is symmetric  I move it around an image  What does this sound like?  If I say:  I have a region of interest defined by a certain radius around a center pixel  The ROI is symmetric  I move it around an image  What does this sound like?

21 Convolution (ahem, correlation)! To do convolution we need 3 things: 1. A kernel 2. A way to access a region of an image the same size as the kernel 3. A way to compute the inner product between the kernel and the image region To do convolution we need 3 things: 1. A kernel 2. A way to access a region of an image the same size as the kernel 3. A way to compute the inner product between the kernel and the image region

22 Item 1 - The kernel  A NeighborhoodOperator is a set of pixel values that can be applied to a Neighborhood to perform a user-defined operation (i.e. convolution kernel, morphological structuring element)  NeighborhoodOperator is derived from Neighborhood  A NeighborhoodOperator is a set of pixel values that can be applied to a Neighborhood to perform a user-defined operation (i.e. convolution kernel, morphological structuring element)  NeighborhoodOperator is derived from Neighborhood

23 Item 2 - Image access method  We already showed that this is possible using the neighborhood iterator  Just be careful setting it up so that it’s the same size as your kernel  We already showed that this is possible using the neighborhood iterator  Just be careful setting it up so that it’s the same size as your kernel

24 Item 3 - Inner product method  The NeighborhoodInnerProduct computes the inner product between two neighborhoods  Since NeighborhoodOperator is derived from Neighborhood, we can compute the IP of the kernel and the image region  The NeighborhoodInnerProduct computes the inner product between two neighborhoods  Since NeighborhoodOperator is derived from Neighborhood, we can compute the IP of the kernel and the image region

25 Good to go? 1. Create an interesting operator to form a kernel 2. Move a neighborhood through an image 3. Compute the IP of the operator and the neighborhood at each pixel in the image Voila - convolution in N-dimensions 1. Create an interesting operator to form a kernel 2. Move a neighborhood through an image 3. Compute the IP of the operator and the neighborhood at each pixel in the image Voila - convolution in N-dimensions

26 Inner product example itk::NeighborhoodInnerProduct IP; itk::DerivativeOperator operator ; operator->SetOrder(1); operator->SetDirection(0); operator->CreateDirectional(); itk::NeighborhoodIterator iterator(operator->GetRadius(), myImage, myImage->GetRequestedRegion()); itk::NeighborhoodInnerProduct IP; itk::DerivativeOperator operator ; operator->SetOrder(1); operator->SetDirection(0); operator->CreateDirectional(); itk::NeighborhoodIterator iterator(operator->GetRadius(), myImage, myImage->GetRequestedRegion());

27 Inner product example, cont. iterator.SetToBegin(); while ( ! iterator. IsAtEnd () ) { std::cout << "Derivative at index " << iterator.GetIndex () << is << IP(iterator, operator) << std::endl; ++iterator; } iterator.SetToBegin(); while ( ! iterator. IsAtEnd () ) { std::cout << "Derivative at index " << iterator.GetIndex () << is << IP(iterator, operator) << std::endl; ++iterator; }

28 Note  No explicit reference to dimensionality in neighborhood iterator   easy to make N-d  No explicit reference to dimensionality in neighborhood iterator   easy to make N-d

29 This suggests a filter...  NeighborhoodOperatorImageFilter wraps this procedure into a filter that operates on an input image  So, if the main challenge is coming up with an interesting neighborhood operator, ITK can do the rest  NeighborhoodOperatorImageFilter wraps this procedure into a filter that operates on an input image  So, if the main challenge is coming up with an interesting neighborhood operator, ITK can do the rest

30 Your arch-nemesis... image boundaries  One obvious problem with inner product techniques is what to do when you reach the edge of your image  Is the operation undefined?  Does the image wrap?  Should we assume the rest of the world is empty/full/something else?  One obvious problem with inner product techniques is what to do when you reach the edge of your image  Is the operation undefined?  Does the image wrap?  Should we assume the rest of the world is empty/full/something else?

31 ImageBoundaryCondition  Subclasses of itk::ImageBoundaryCondition can be used to tell neighborhood iterators what to do if part of the neighborhood is not in the image

32 ConstantBoundaryCondition  The rest of the world is filled with some constant value of your choice  The default is 0  Be careful with the value you choose - you can (for example) detect edges that aren’t really there  The rest of the world is filled with some constant value of your choice  The default is 0  Be careful with the value you choose - you can (for example) detect edges that aren’t really there

33 PeriodicBoundaryCondition  The image wraps, so that if I exceed the length of a particular axis, I wrap back to 0 and start over again  If you enjoy headaches, imagine this in 3D  This isn’t a bad idea, but most medical images are not actually periodic  The image wraps, so that if I exceed the length of a particular axis, I wrap back to 0 and start over again  If you enjoy headaches, imagine this in 3D  This isn’t a bad idea, but most medical images are not actually periodic

34 ZeroFluxNeumannBoundary Condition  I am not familiar with how this functions  The documentation states that it’s useful for solving certain classes of differential equations  A quick look online suggests a thermodynamic motivation  I am not familiar with how this functions  The documentation states that it’s useful for solving certain classes of differential equations  A quick look online suggests a thermodynamic motivation

35 Using boundary conditions  With NeighborhoodOperatorImageFilter, you can call OverrideBoundaryCondition

36 SmartNeighborhoodIterator  This is the iterator that’s being used internally by the previous filter; you can specify its boundary behavior using OverrideBoundaryCondition too  In general, I would suggest using the “smart” version - bounds checking is good!  This is the iterator that’s being used internally by the previous filter; you can specify its boundary behavior using OverrideBoundaryCondition too  In general, I would suggest using the “smart” version - bounds checking is good!

37 An aside: numeric traits  This has nothing to do with Neighborhoods but is good to know  Question: given some arbitrary pixel type, what do we know about it from a numerics perspective?  This has nothing to do with Neighborhoods but is good to know  Question: given some arbitrary pixel type, what do we know about it from a numerics perspective?

38 itk::NumericTraits  NumericTraits is class that’s specialized to provide information about pixel types  Examples include:  min and max values  IsPositive(), IsNegative()  Definitions of Zero and One  NumericTraits is class that’s specialized to provide information about pixel types  Examples include:  min and max values  IsPositive(), IsNegative()  Definitions of Zero and One

39 Using traits  What’s the maximum value that can be represented by an unsigned char?  itk::NumericTraits ::max()  Look at vnl_numeric_limits for more data that can be provided  What’s the maximum value that can be represented by an unsigned char?  itk::NumericTraits ::max()  Look at vnl_numeric_limits for more data that can be provided