Title: ECSE6963, BMED 6961 Cell
1ECSE-6963, BMED 6961Cell Tissue Image Analysis
- Lecture 11 Fundamentals of Image Analysis - VII
- Badri Roysam
- Rensselaer Polytechnic Institute, Troy, New York
12180.
2Recap Labeling Connected Components
Adaptive Smoothing Thresholding
Connected Components Labeling
Binary image
Regions labeled
image
Image
Connected Components Labeling
Binary Segmentation
3CC labeling A Versatile Tool
- MATLAB Function
- L,num bwlabel(BW,n) for 2-D images only
- BW binarized image
- n 4 or 8 (default) connectivity
- L label array, same size as BW
- num number of connected components
- L,NUM bwlabeln(BW,CONN) for n-dimensional
images - CONN 6/18/26 connectivity in 3-D space
- RGB label2rgb(L,map,zerocolor) for displaying
the CC labels - Can use CC labeling in diverse ways limited only
by our imagination - Find the background
- Count components
- Measure size (area, volume, radius), extent
(feret box, diameter), location, shape
(convexity, circularity), and orientation (min.
enclosing rectangle) features - Filter components by size shape
- Find and fill holes
- Cleanup results of edge detection
4Recap Features of Connected Components
- Area
- Feret box, and minimum enclosing rectangle
- Diameter
- Centroid
5Want to Invent More Features with Me?
- Before we think up more features, we must pause
and learn a few lessons - Examine if a given features value can change
when the imaging conditions are adjusted - Features that are invariant or at least robust
or insensitive to the expected range of imaging
distortions are preferable. For example, ask if
the features value changes when the
magnification is changed (scale invariance), or
the specimen is rotated (rotational invariance). - Dimensionless ratios of some features can
sometimes provide some kind of invariance
6Recall More Accurate Size Measurement
- Most of the variation in area measurement occurs
due to the pixels at the border. - Approximate calculation
- Assume object is roughly circular, with radius R
- Random Poisson sampling of the border region
gives a mean and variance of - More generally,
- Denser sampling leads to better precision
http//www.ph.tn.tudelft.nl/People/albert/papers/I
SBI2004_LVPVTY.pdf
7Pixels at the Border the Perimeter
- Simplest Definition Count the number of boundary
pixels - Boundaries often associated with membranes
- Extremely important sites of biochemical activity
- CC pixels with at least one 4-connected
background neighbor are boundary pixels - In MATLAB, BW2 bwperim(BW1,CONN) identifies
perimeter pixels - CONN specifies the type of connectivity
- Two types of boundary pixels
- Type I only one 4-connected background neighbor
- Type II Two 4-connected background neighbors
- For a more accurate estimation, necessary to
perform contour following - Professor Freemans algorithm
- Weight for Type I pixels 1
- Weight for Type II pixels ??2
2
2
1
8More Accurate Estimation of Perimeter
- Kulpas Algorithm
- Start with 8-connected contour
- Scale Freemans estimate by 0.948
- Many other formulas discussed in the literature
- 3-D case is analogous
- Surface area of a connected component
Correction factor for closed surfaces
9Contours External Internal
- Usually, external contours are better behaved
- Form closed curves when object contains no holes
- Even if parts of object are just 1 pixel wide
Practical notes 1. Internal contour would work
better if we had a single-pixel-wide tunnel 2.
Often convenient to either erode or widen
single-pixel-wide structures to 2 pixels
10Contour Following
Starting Point
- Need a way to represent a contour
- Need algorithms to
- Find a starting point
- Find the next point on contour
- Recognize when contour following is complete
11Neighbor Labeling
- A contour can be written as a series of 3-bit
numbers - Chain code directions
- Invented by Herb Freeman in the 60s
- An RPI professor
12Finding the Starting Point
- Just scan from upper left to bottom right
- The first background pixel that has a foreground
neighbor to the right is our starting point for
contour following - Pixel (2, 6) in this example
13Finding the Second Point
- Search the neighbors that have not been tested
before (from 4 to 7) - Look for first transition from background to
foreground - Pick the background pixel as the next point on
the external contour - Will always yield counter-clockwise contour
14Subsequent Points
- We need a way to keep track of whats already
been traced and whats not - P Previous pixel
- C Current pixel
- N Next pixel
Directions
15The invert() function
Directions
16Finding Subsequent Points
- Starting from , search the neighborhood
counter clockwise for contour candidates,
including the previous point - Allows algorithm to enter and leave a tunnel
- Pick the last candidate as the next direction
Directions
17Finding Subsequent Points
- Note that the previous pixel is also a candidate
in the search - Need that to handle single-pixel wide entrances
- Taken only when there are no other candidates to
avoid getting stuck
18End Point
- Stop when you encounter the start point while
finding the subsequent points - Works when you dont have holes
19Doing this in MATLAB
(x, y) sequences, one for each object
Label Matrix
No. of objects
Boundary Array
Adjacency matrix
- B,L,N,A bwboundaries (BW, CONN, options)
Binarized image
How holes should be treated holes or noholes
Type of Connectivity (4 or 8)
20Freemans Perimeter Estimate - Revisited
Directions
Number of odd direction codes in contour
Number of even direction codes in contour
21Perimeter Comments
- Perimeters, surface areas, and curve lengths are
notoriously susceptible to estimation errors - Small segmentation errors can cause big changes
- The fractal nature of object perimeters
- The answer depends the wiggliness of the border
- More wiggly borders can be dramatically longer
- Often more meaningful to define these
measurements at a specific scale - We would like to smooth the contour to an
appropriate extent (scale), and then measure
perimeter/surface area. - We would exercise caution in terms of how the
perimeter feature is used it is only valid for
a stated scale, and must be re-estimated for any
other scale value.
22Perimeter Based Features
Exercise caution if/when you use these
features! Which of these are dimensionless?
23Radius Circularity
- The circularity, C, is defined as the variance of
the distances around the radius
Circularity of a circular object is zero, and for
non-circular objects, it is greater than 0
24Convex Hull
- Convex Hull
- Smallest convex polygon that encloses the shape
- Convex Deficiency
- The difference between the shape and the convex
hull - Simple Algorithm
- For each point on the boundary, see if it is
enclosed in a triangle formed by three other
boundary points - Points that are not enclosed are the vertices of
the convex hull - Faster algorithms are available.
Convex deficiency
25Convex Hull in MATLAB
- The convex hull is a versatile operation, just
like connected components - Applications are limited only by our imaginaton
- Computational geometry researchers have developed
some very fast and effective algorithms - Quick Hull (www.qhull.org) is a free software
library - MATLAB uses the routine from Qhull
K, A convhull(x,y) returns indices into the
x and y vectors of the points on the convex
hull, so xk, yk are points on the convex
hull. A is the area of the convex hull.
26Convexity
Intuition If the convex deficiency is minimal,
then object area and area of the convex hull are
nearly the same. The object is very convex. If
the convex deficiency is a lot, then the object
is not very convex, and the convexity measure is
low
27Example Compactness
Compact
Invariant to linear image transformations,
but Watch for scale-dependent error in perimeter
estimate
Not so compact
28Curvature
- Basic Concept
- Curvature is the rate of change of the slope of a
curve - Positive curvature means convex, and vice versa
- Using curvature, we can locate special points of
interest
29Curvature Estimation
- The derivatives can be approximated by differences
30Practical Method
m is a scale parameter Notwithstanding m, we
still need to smooth the boundary
31Doing it in MATLAB
- There is no direct function for estimating
boundary curvature in MATLAB - One method is to fit a polygon to the sequence of
boundary pixels using the MATLAB polyfit routine - p polyfit(x,y,n)
- n degree of the polynomial
- Now you can use the calculus-based formulas we
just discussed to estimate curvature identify
the special points using your own program!
32Shape Complexity Feature
- Find the nearest distance of each pixel to the
boundary - Efficient algorithms, known as Distance
Transforms are available to do this (coming up
shortly) - Find the average ? of the above distances
Suppose the two shapes had the same area, which
one will have more complexity?
33Using CC labels as cookie cutters(region of
interest indicators)
- Keep in mind that the original image data is
available, and spatially aligned with
segmentation labels - CC labels can help define regions of interest in
the image - Make spatially selective measurements over the
original image - Fluorescence intensity measurements
- Optical density measurements
34Example Absorption features
Feret Box
- Important for transmitted-light images
- Total Optical Density
- Measure background within a local neighborhood,
usually a slightly expanded Feret box, or a
rounder approximation - Mean Optical Density
- Variance of optical density
- A texture measure
35Looking Ahead
6 iterations of smoothing with anisotropic
diffusions
After grayscale min smoothing
Rat hippocampus Nuclei
Big Question How do we begin to clean up these
messy-looking edges??
Adaptive Thresholding of gradient
Gradient
36Looking Ahead
- Still need to learn
- More features, especially boundary features
- How to separate connected nuclei
37Reference
- Shape analysis Classification Theory and
Practice by Luciano da Fontura Costa - Available on-line through the RPI library catalog
- Chapter 5.2 describes the contour following
algorithm
38Summary
- We covered several common region features today
- Need to keep in mind the cautionary notes
- Need to understand what kinds of features are
better! - Invariant
- Dimensionless
- Sensitive to desired aspects of objects, but
insensitive to expected/possible image
distortions - Perimeters and surface areas are tricky features
- Keep in mind the issue of applicable scale
- The convex hull is another powerful and versatile
operation, just like CC labeling - Can be used in diverse ways, limited only by our
imagination - Well explore more features next class
- Good News
- We now have a grader (Adarsh)!
39Instructor Contact Information
- Badri Roysam
- Professor of Electrical, Computer, Systems
Engineering - Office JEC 7010
- Rensselaer Polytechnic Institute
- 110, 8th Street, Troy, New York 12180
- Phone (518) 276-8067
- Fax (518) 276-8715
- Email roysam_at_ecse.rpi.edu
- Website http//www.ecse.rpi.edu/roysam
- Course website http//www.ecse.rpi.edu/roysam/CT
IA - Secretary Laraine Michaelides, JEC 7012, (518)
276 8525, michal_at_.rpi.edu - Grader
Center for Sub-Surface Imaging Sensing