You are on page 1of 17

Distribution Statement A: Unlimited Distribution

Introduction to Blobs and using the OpenCV


Blobs Library
Distribution Statement A: Unlimited Distribution
OSSIM raining
!OV""
Distribution Statement A: Unlimited Distribution
Disclaimer
Though SSC Pacific makes every effort to perform quality
assurance on its training materials, the material in this
presentation may inadvertently include technical inaccuracies or
other errors. We would be grateful if users notify us of any errors
or inaccuracies they may find.
The presentation contains references to links and to thirdparty
websites. These are provided for the convenience and interest of
users and this implies neither responsibility for, nor approval of,
information contained in these websites on the part of the !.S.
"overnment. The !S" makes no warranty, either e#press or
implied, as to the accuracy, availability or content of information,
te#t, graphics in the links$third party websites. The !S" has not
tested any software located at these sites and does not make
any representation as to the quality, safety, reliability or suitability
of such software, nor does this presentation serve to endorse the
use of such sites.
%
OSSIM raining
!OV""
Distribution Statement A: Unlimited Distribution
O#er#ie$ o% al&
&verview of 'lob e#traction
(ntroduction to 'lob )ibrary
*#ample+ !sing 'lobs
Conclusions
OSSIM raining
!OV""
Distribution Statement A: Unlimited Distribution
O#er#ie$ o% Blob '(traction
(dentify regions in an image that differ in
properties like color or brightness
,etect connected regions in binary images
!sually done after thresholding
-any different and more comple# algorithms
We.re going to discuss the
twopass method
OSSIM raining
!OV""
Distribution Statement A: Unlimited Distribution
Blob '(traction ) $o*pass algorithm
/elatively easy to understand and implement
0irst pass records equivalences and assigns temporary labels
Second pass replaces temporary labels with the label of its equivalence class
Connectivity checks are carried out by checking the labels of pi#els that are
1orth*ast, 1orth, 1orthWest, and West of the current pi#el
0our conditions
OSSIM raining
!OV""
Distribution Statement A: Unlimited Distribution
Blob '(traction ) $o*pass algorithm
2
st
condition 3 ,oes the pi#el to the left 4west5 have
the same value6
7es 8 Same region, assign the
same label to the current pi#el
1o 8 Check ne#t condition
9
nd
condition 3 ,o the pi#els to the north and west of
the current pi#el have the same value but not the same
label6
7es 8 We know that the north and West
pi#els belong to the same region and must be
merged, assign the current pi#el the minimum of
the north and west labels and record their
equivalence relationship
1o 8 Check ne#t condition
2,a
6
2,a
2,6
2,a
OSSIM raining
!OV""
Distribution Statement A: Unlimited Distribution
Blob '(traction ) $o*pass algorithm
:
rd
condition 3 ,oes the pi#el to the left 4west5 have a
different value and the one to the north the same value6
7es 8 ;ssign the label of the north pi#el to
the current pi#el
1o 8 Check ne#t condition
<
th
condition 3 ,o the pi#el.s north and west
neighbors have different pi#el values6
7es 8 Create a new label id and assign it to
the current pi#el
2,a
=
2
2,a
=,b
=,b
OSSIM raining
!OV""
Distribution Statement A: Unlimited Distribution
;fter the first pass labels are generated for each of the pi#els according to the
four conditions and the equivalence tables are generated
Blob '(traction ) $o*pass algorithm
"
+
,
,
-
.
/ 0
1
OSSIM raining
!OV""
Distribution Statement A: Unlimited Distribution
&n the second pass the labels are merged
Blob '(traction ) $o*pass algorithm
OSSIM raining
!OV""
Distribution Statement A: Unlimited Distribution
>ow do we remove small specks and keep the blobs6
..?&penC@Threshold;nd*#tract'lobs.cpp
blobs.0ilter4blobs, 'A(1C)!,*, C'lob"et;rea45, 'A"/*;T*/, 2==5B
blobs.0ilter4blobs, 'A(1C)!,*, C'lob"et-ean45, 'A"/*;T*/, 25B
This allows us to decide how CbigD a significant blob is
Blob '(traction ) $o*pass algorithm
OSSIM raining
!OV""
Distribution Statement A: Unlimited Distribution
1ow only large blobs remain
Blob '(traction ) $o*pass algorithm
OSSIM raining
!OV""
Distribution Statement A: Unlimited Distribution
Blob '(traction ) $o*pass algorithm
2
st
condition 3 ,oes the pi#el to the left 4west5 have the same value6
7es 8 Same region, assign the same label to the current pi#el
1o 8 Check ne#t condition
9
nd
condition 3 ,o the pi#els to the north and west of the current pi#el have
the same value but not the same label6
7es 8 We know that the north and West pi#els belong to the same
region and must be merged, assign the current pi#el the minimum of the
north and west labels and record their equivalence relationship
1o 8 Check ne#t condition
:
rd
condition 3 ,oes the pi#el to the left 4west5 have a different value and the
one to the north the same value6
7es 8 ;ssign the label of the north pi#el to the current pi#el
1o 8 Check ne#t condition
<
th
condition 3 ,o the pi#el.s north and west neighbors have different pi#el
values6
7es 8 Create a new label id and assign it to the current pi#el
OSSIM raining
!OV""
Distribution Statement A: Unlimited Distribution
Introduction to Blobs Library %or OpenCV
'lobs )ibrary is a plugin for &penC@.
http+$$opencv.willowgarage.com$wiki$cv'lobs)ib
/eplicates functionality of -atlab.s 'W)abel and regionprops functions
Takes binary image, and finds all of the blobs.
'lob is a Cconnected obEectD
0or each blob, finds, length, width, and orientation
Can e#tract the subimage corresponding to the blob area
Can filter out blobs below or above a certain
2. ;rea
9. -ean value
OSSIM raining
!OV""
Distribution Statement A: Unlimited Distribution
'(ample: Using the blobs library $ith OpenCV
1ow we.ll go through an e#ample using &penC@ and the blobs
library.
The code is in the folder+
..?=:A&penC@AandAblobs?e#amples?'lobsAe#amples
?&penC@Threshold;nd*#tract'lobs
OSSIM raining
!OV""
Distribution Statement A: Unlimited Distribution
'(ample: Using the blobs library $ith OpenCV
-odify the %.bat files so that the paths are correct
buildAcmakeAproEectAvs2=.bat
cmakeAarguments.bat
/un buildAcmakeAproEectAvs2=.bat and build the proEect
Compile the proEect in @isual CFF
/un ..?,ebug?runProEect.bat
OSSIM raining
!OV""
Distribution Statement A: Unlimited Distribution
Blob '(ample 2esults
OSSIM raining
!OV""
Distribution Statement A: Unlimited Distribution
Another Sample Image
This simple algorithm can work
with some CeasyD images

You might also like