2. EBImage
• EBImage is an image processing and analysis toolbox for R.
• Development of the package arose from the need for general purpose
tools for segmenting cells and extracting quantitative cellular
descriptors
• Package is hosted on Bioconductor (http://bioconductor.org/)
•
3. Read in image
readImage(files, type, all = TRUE, ...)
Supports .jpg, .png, .tiff files
all if the file contains more than
one image read all?
Apply Filtering
Thresholding &
Morphological
Operations
Labeling,
Extracting,
Analyzing
features
Basic Image Processing
4. Filtering - Basics
• Define a structuring element
• Pass structuring element over
each pixel
• Structuring element alters each
pixel it touches.
• Example: average the pixel
strength of neighboring pixels
and assign that value to the
center pixel
5. Filtering in EBImage
• makeBrush: function for defining a structuring element
• makeBrush(size, shape=c('box', 'disc', 'diamond', 'gaussian', 'line'), step=TRUE,
sigma=0.3, angle=45)
• Size must be an odd number
• Step: True binary pixel strengths/False grey scale pixel strengths
• Sigma: applies to the ‘gaussian’ shape, defines standard deviation of the Gaussian.
• Applying the filter
• img.br<-makeBrush(7,’gaussian’,sigma=10)
• img.blur<-filter2(img,img.br) : fillter2() function for filtering
11. Thresholding & Morphological Operations
• Thresholding: applies a structuring element to generate a binary
image which retains only those pixels which exceed a given threshold.
Used to find edges in an image.
• img.th<-thresh(img,w=9,h=9,offset=0.03)
• Morphological Operations: functions that dilate or erode thresholded
features.
• open.br<-makeBrush(7,shape="disc",step=TRUE)
• img.th<-thresh(img,w=9,h=9,offset=0.03)
• img.op<-opening(img.th,open.br)
• An erosion followed by a dilation is called an “opening”
• A dilation followed by an erosion is called a “closing”
14. Thresholded image after a dilation followed
by an erosion (“Closing”)
open.br<-makeBrush(7,shape="disc",step=TRUE)
img.cl<-closing(img.th,open.br)
15. Feature extraction
• Once a satisfactory threshold and erosion/dilation combination is
arrived at, features can be extracted for statistical purposes. The
binary features must be labeled. The functions for labeling and
computing features are:
imgcl.lab<-bwlabel(img.cl)
ftrs<-computeFeatures(imgcl.lab,img)
• More than 20 feature parameters may be found. Basic features such
as the center of mass of each feature, number of pixels per feature,
number of perimeter pixels, etc.
• Complex feature characteristics like Zernicke polynomial moments
and Haralick features can also be computed.