Colorado School of Mines. Computer Vision. Professor William Hoff Dept of Electrical Engineering &Computer Science.

Similar documents
Colorado School of Mines. Computer Vision. Professor William Hoff Dept of Electrical Engineering &Computer Science.

Morphological Image Algorithms

Image Processing Toolbox

Lab 2. Hanz Cuevas Velásquez, Bob Fisher Advanced Vision School of Informatics, University of Edinburgh Week 3, 2018

Image Segmentation. Figure 1: Input image. Step.2. Use Morphological Opening to Estimate the Background

Morphological Image Processing

INF Exercise for Thursday

Figure 8-7: Cameraman.tif Before and After Remapping, and Widening its Dynamic Range

[ ] Review. Edges and Binary Images. Edge detection. Derivative of Gaussian filter. Image gradient. Tuesday, Sept 16

Morphological Image Processing

EECS490: Digital Image Processing. Lecture #17

Image Processing. Bilkent University. CS554 Computer Vision Pinar Duygulu

Edges and Binary Image Analysis April 12 th, 2018

EE795: Computer Vision and Intelligent Systems

CITS 4402 Computer Vision

Morphological Image Processing

ECE 172A: Introduction to Intelligent Systems: Machine Vision, Fall Midterm Examination

Binary Image Processing. Introduction to Computer Vision CSE 152 Lecture 5

Morphological Image Processing

EE 584 MACHINE VISION

Processing of binary images

09/11/2017. Morphological image processing. Morphological image processing. Morphological image processing. Morphological image processing (binary)

Fig. 1. Input image. Ibw=im2bw(I, 250/255); % threshold value should be between Fig. 2. Thresholded image cercuri-stele.

Previously. Edge detection. Today. Thresholding. Gradients -> edges 2/1/2011. Edges and Binary Image Analysis

What will we learn? What is mathematical morphology? What is mathematical morphology? Fundamental concepts and operations

Introduction. Computer Vision & Digital Image Processing. Preview. Basic Concepts from Set Theory

A Simple Cigarette Butts Detection System

Identifying and Reading Visual Code Markers

Binary Image Analysis. Binary Image Analysis. What kinds of operations? Results of analysis. Useful Operations. Example: red blood cell image

Biomedical Image Analysis. Mathematical Morphology

THE BARE ESSENTIALS OF MATLAB

CSE/EE-576, Final Project

CS443: Digital Imaging and Multimedia Binary Image Analysis. Spring 2008 Ahmed Elgammal Dept. of Computer Science Rutgers University

Colorado School of Mines. Computer Vision. Professor William Hoff Dept of Electrical Engineering &Computer Science.

Edges and Binary Image Analysis. Thurs Jan 26 Kristen Grauman UT Austin. Today. Edge detection and matching

Image Analysis Lecture Segmentation. Idar Dyrdal

Image and Multidimensional Signal Processing

Machine vision. Summary # 5: Morphological operations

Statistical Approach to a Color-based Face Detection Algorithm

OBJECT SORTING IN MANUFACTURING INDUSTRIES USING IMAGE PROCESSING

Getting Started With Images, Video, and Matlab. CSE 6367 Computer Vision Vassilis Athitsos University of Texas at Arlington

Image Analysis. Morphological Image Analysis

Homework Assignment 2 - SOLUTIONS Due Monday, September 21, 2015

Chapter 9 Morphological Image Processing

Design Features Recognition Using Image Processing Techniques

Robbery Detection Camera

ECG782: Multidimensional Digital Signal Processing

10.5 Morphological Reconstruction

Lecture 7: Morphological Image Processing

Eyes extraction from facial images using edge density

3D-Modeling with Microscopy Image Browser (im_browser) (pdf version) Ilya Belevich, Darshan Kumar, Helena Vihinen

Edges and Binary Images

Mathematical Morphology and Distance Transforms. Robin Strand

Face Tracking in Video

Requirements for region detection

Image Processing: Final Exam November 10, :30 10:30

EECS490: Digital Image Processing. Lecture #23

Face Detection on Similar Color Photographs

Counting Particles or Cells Using IMAQ Vision

UNIVERSITY OF OSLO. Faculty of Mathematics and Natural Sciences

CHAPTER 3 IMAGE ENHANCEMENT IN THE SPATIAL DOMAIN

ECG782: Multidimensional Digital Signal Processing

International Journal of Advance Engineering and Research Development. Applications of Set Theory in Digital Image Processing

Solving Word Jumbles

Image segmentation. Stefano Ferrari. Università degli Studi di Milano Methods for Image Processing. academic year

IN5520 Digital Image Analysis. Two old exams. Practical information for any written exam Exam 4300/9305, Fritz Albregtsen

CHAPTER 3 SYSTEM DESCRIPTION

CMPSCI 119 LAB #2 Anime Eyes Professor William T. Verts

Cartoon Transformation

Depatment of Computer Science Rutgers University CS443 Digital Imaging and Multimedia Assignment 4 Due Apr 15 th, 2008

Lecture: Segmentation I FMAN30: Medical Image Analysis. Anders Heyden

COMPUTER AND ROBOT VISION

Mathematical morphology (1)

CMPSCI 119 Spring 2014 Friday, November 7, 2014 Midterm #2 Solution Key Professor William T. Verts

CMPSCI 119 LAB #2 Greebles / Anime Eyes Professor William T. Verts

Digital Image Processing COSC 6380/4393

morphology on binary images

HCR Using K-Means Clustering Algorithm

Estimating Speed, Velocity, Acceleration and Angle Using Image Addition Method

Working with images and scenes

An Introduction to Processing

PPKE-ITK. Lecture

Automatic object detection and tracking in video

CS 5540 Spring 2013 Assignment 3, v1.0 Due: Apr. 24th 11:59PM

Lecture 6: Segmentation by Point Processing

Film Line scratch Detection using Neural Network and Morphological Filter

Optical Verification of Mouse Event Accuracy

Structural Analysis of Aerial Photographs (HB47 Computer Vision: Assignment)

Segmentation

Transition Region-Based Thresholding using Maximum Entropy and Morphological Operations

Colorado School of Mines. Computer Vision. Professor William Hoff Dept of Electrical Engineering &Computer Science.

Topic 6 Representation and Description

An adaptive container code character segmentation algorithm Yajie Zhu1, a, Chenglong Liang2, b

Segmentation

Making Backgrounds With Paint Shop Pro

Albert M. Vossepoel. Center for Image Processing

Mathematical morphology... M.1 Introduction... M.1 Dilation... M.3 Erosion... M.3 Closing... M.4 Opening... M.5 Summary... M.6

- Low-level image processing Image enhancement, restoration, transformation

CS 490: Computer Vision Image Segmentation: Thresholding. Fall 2015 Dr. Michael J. Reale

GIMP WEB 2.0 ICONS. GIMP is all about IT (Images and Text) OPEN GIMP

Transcription:

Professor William Hoff Dept of Electrical Engineering &Computer Science http://inside.mines.edu/~whoff/ 1

Binary Image Processing 2

Binary means 0 or 1 values only Also called logical type (true/false) Binary Images Obtained from Thresholding gray level images Or, the result of feature detectors Often want to count or measure shape of 2D binary image regions 3

Thresholding Convert gray scale image to binary (0s and 1s) Simplifies processing and computation of features Can use a single threshold value (global) or a local value (adaptive) 3000 Thresholding in Matlab: B = I > t; 2500 2000 1500 1000 500 0 0 50 100 150 200 250 Image eight.tif 4

Otsu s Method for Global Thresholding Choose threshold to minimize the variance within groups W P P 2 2 2 1 1 2 2 0.03 Used in Matlab s graythresh function Or equivalently, maximize the variance between groups where 2 2 2 B P1 m1 mg P2 m2 mg k L 1 P p, P p 1 i 2 i 0 i k 1 i 0.025 0.02 0.015 0.01 0.005 0 0 50 100 150 200 250 300 m G is the global mean; m k is the mean of class k 5

Matlab Examples Images cameraman.tif, eight.tif, coins.png Functions t = graythresh(i) % Otsu algorithm BW = im2bw(i,t); % performs thresholding 6

Connected Components Define adjacency 4-adjacent 8-adjacent 4-connected 8-connected Two pixels are connected in S if there is a path between them consisting entirely of pixels in S S is a (4- or 8-) connected component ( blob ) if there exists a path between every pair of pixels Labeling is the process of assigning the same label number to every pixel in a connected component 7

Example Hand label simple binary image 4-connected 8-connected 1 1 1 1 1 1 1 1 1 1 1 1 Binary image Labeled image (4- connected) Labeled image (8- connected) 8

A Fast Labeling Algorithm One pass through image to assign temporary labels and record equivalences Second pass to replace temporary labels with equivalence labels Let B(r,c) is the input binary image L(r,c) is the output image of labels Side note faster labeling algorithms do exist. They use 2x2 blocks to search for connected components and use the fact that all the pixels within the block are 8-connected. C. Grana, D. Borghesani, and R. Cucchiara. Fast block based connected components labeling. Proc of ICIP, pages 4061-4064, 2009. 9

Let: B(MAXROWS, MAXCOLS) be the input binary image Also, L(MAXROWS, MAXCOLS) will be the output label image for r=1 to MAXROWs for c=1 to MAXCOLS if B(r,c) == 0 then L(r,c) = 0; % if pixel not white, assign no label else if B(r-1,c)==0 && B(r,c-1)==0 L(r,c) = NUMLABEL++; % New component label else if B(r-1,c)==1 && B(r,c-1)==0 L(r,c) = L(r-1,c); % Use label from above neighbor else if B(r,c-1)==1 && B(r-1,c)==0 L(r,c) = L(r,c-1); % Use label from left neighbor else if B(r,c-1)==1 && B(r-1,c)==1 L(r,c) = L(r-1,c); % Use either neighbor s label record equivalence of L(r,c-1) and L(r-1,c) end end end end Then go through L and replace temporary labels with equivalence labels 10

Example 1 1 1 1 1 1 1 1 1 1 1 1 Binary image Temporary labels after 1 st pass Final (equivalence) labels after 2 nd pass 11

Matlab Example Labeling connected components (white blobs) im2bw threshold to convert to binary image bwlabel do connected component labeling generate an image of labels label2rgb for visualization converts each label to a random color If we want to find black blobs B=~B or B=imcomplement(B); Flip black and white regions then repeat steps Image Fig9-16(a).jpg 12

>> I = imread('fig9.16(a).jpg'); >> imshow(i,[]) >> whos Name Size Bytes Class Attributes I 512x512 262144 uint8 >> BW = im2bw(i, graythresh(i)); >> figure, imshow(bw) >> [L,num] = bwlabel(bw); >> figure, imshow(l,[]) >> num num = 17 >> RGB = label2rgb(l); >> figure, imshow(rgb) >> BW = imcomplement(bw); >> [L,num] = bwlabel(bw); >> RGB = label2rgb(l); >> figure, imshow(rgb) 13

Binary Image Morphology Operations on binary images: dilation and erosion opening and closing Can be used to clean up image shrink and expand regions eliminate small regions or holes Operations are performed with a structuring element S a small binary image like a filter mask 14

Defined as B Dilation S b where b B S b is the structuring element S, shifted to b Procedure Sweep S over B Everywhere the origin of S touches a 1, OR S with B Expands regions S 1 1 1 1 1 1 S 1 1 1 1 1 1 1 B B S 15

16

Defined as B S b b s B, Procedure Sweep S over B Erosion Everywhere S is completely contained in B, output a 1 at the origin of S Shrinks regions s S 1 1 1 1 1 1 S 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 B B S 17

Matlab To create a structuring element S = strel( disk, 5) % disk shape, radius=5 Note that this creates a rounder shape: S = strel( disk, 5, 0); Dilation I2 = imdilate(i,s); Erosion I2 = imerode(i,s); 18

Openings and Closings Opening Erosion followed by dilation Eliminate small regions and projections B S B S S Closing Dilation followed by erosion Fill in small holes and gaps B S B S S Matlab functions: imopen, imclose 19

Example Segment all the dark regions in the lower half of the image bag.png Namely, generate a binary (or logical ) image which is white (1) in the regions of interest, and black (0) elsewhere Want: No gaps in the regions No extraneous white pixels in the background Image bag.png from Matlab image processing toolbox demo folder For this example, ignore the upper half of the image Then do connected component labeling on these regions 20

Threshold the image Use graythresh to pick the threshold automatically B = im2bw(i, graythresh(i)); Approach Complement the resulting binary image B = ~B; % Make the target regions white Clean up Do an opening to get rid of small noise white regions B2 = imopen(b, SA); where SA = strel( disk, radius, 0); Do a closing to fill in gaps in the target regions B3 = imclose(b2, SB); Do connected component labeling [L, n] = bwlabel(b3); You can find the value of radius experimentally You can use a different structuring element for opening and closing 21

Example (continued) Original bag.png image Segmented binary image after thresholding and morphological operations After connected component labeling. Each color indicates a different label of a foreground object (and white represents the background) 22

Basic features Area Centroid A r Region Properties 1 ( r, c) R 1 A r, ( r, c) R c 1 A c ( r, c) R Bounding box The smallest rectangle containing the region Can be specified by The location of the upper left corner The width and height Matlab function regionprops(l) This function computes region properties You pass in a label image, produced by bwlabel It returns an array of structures each contains the properties for one region 23

Matlab Structures A structure is an object with named fields Example >> I = imread('fig9.16(a).jpg'); >> BW = im2bw(i); >> [L,n] = bwlabel(bw); >> blobs = regionprops(l); >> blobs blobs = 17x1 struct array with fields: Area Centroid BoundingBox Access fields using: structurename.fieldname >> blobs(1) ans = Area: 2058 Centroid: [15.7216 179.8717] BoundingBox: [0.5000 133.5000 34 93] 24

Properties from regionprops >> blobs(5) ans = Area: 2369 Centroid: [93.5293 157.4690] BoundingBox: [65.5000 129.5000 57 57] Centroid is represented as [xc, yc] Bounding box is represented as [x0 y0 w h], where x0,y0 are the coordinates of the upper left point w,h are the width and height (x0,y0) w (xc,yc) h 25

To draw a rectangle on an image: Matlab Graphics rectangle('position', [x y w h]), EdgeColor, r ); (x,y) w h (x1,y1) (x2,y2) To draw a line on an image: line([x1 x2], [y1 y2], Color, r ); 26

Matlab Example Draw bounding box around all blobs Draw cross hairs on the centroids clear all close all I = imread('fig9.16(a).jpg'); B = im2bw(i, graythresh(i)); imshow(b); % Threshold image L = bwlabel(b); % Do connected component labeling blobs = regionprops(l); % Get region properties for i=1:length(blobs) % Draw a rectangle around each blob rectangle('position', blobs(i).boundingbox, 'EdgeColor', 'r'); end % Draw crosshair at center of each blob c = blobs(i).centroid; % Get centroid of blob line([c(1)-5 c(1)+5], [c(2) c(2)], 'Color', 'g'); line([c(1) c(1)], [c(2)-5 c(2)+5], 'Color', 'g'); 27

Concentric contrasting circle (CCC) target The target is a white ring surrounding a black dot This feature is fairly unique in the image, because the centroid of the white ring will coincide with the centroid of the black dot image robot.jpg on course website You can automatically find the target by finding a white region whose centroid coincides with the centroid of a black region 28

CCC targets (continued) For more discrimination power, you can also place constraints on the binary regions, e.g., The white area must be > the black area) The white bounding box must enclose the black bounding box Sometimes local thresholding is better than global thresholding; especially when the lighting varies across the image For these simple black-and-white targets, a easy way to do local thresholding is: Apply an averaging filter to the image (whose size is greater than the size of the target). This creates an image of local means. Subtract the local average image from the original. Threshold at zero. I = double(i); % Convert image to double I2 = imfilter(i, fspecial('average', sz)); Idiff = I - I2; % Segment white blobs W = Idiff>0; figure, imshow(w, []); 29

Example See if your program can locate the CCC target in each image of the video oneccc.wmv on the course website 30