3.2_openCV_blobs

Embed Size (px)

Citation preview

  • 8/12/2019 3.2_openCV_blobs

    1/17

    Distribution Statement A: Unlimited Distribution

    Introduction to Blobs and using the OpenCVBlobs Library

    Distribution Statement A: Unlimited Distribution

  • 8/12/2019 3.2_openCV_blobs

    2/17

    OSSIM raining!OV"" Distribution Statement A: Unlimited Distribution

    Disclaimer

    Though SSC Pacific makes every effort to perform qualityassurance on its training materials, the material in this

    presentation may inadvertently include technical inaccuracies orother errors. We would be grateful if users notify us of any errorsor inaccuracies they may find.

    The presentation contains references to links and to third partywebsites. These are provided for the convenience and interest ofusers 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 orimplied, as to the accuracy, availability or content of information,te#t, graphics in the links$third party websites. The !S" has nottested any software located at these sites and does not makeany representation as to the quality, safety, reliability or suitabilityof such software, nor does this presentation serve to endorse theuse of such sites.

    %

  • 8/12/2019 3.2_openCV_blobs

    3/17

    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

  • 8/12/2019 3.2_openCV_blobs

    4/17

    OSSIM raining!OV"" Distribution Statement A: Unlimited Distribution

    O#er#ie$ o% Blob '(traction

    (dentify regions in an image that differ inproperties 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

    two pass method

  • 8/12/2019 3.2_openCV_blobs

    5/17

    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, 1orth West, and West of the current pi#el 0our conditions

  • 8/12/2019 3.2_openCV_blobs

    6/17

    OSSIM raining!OV"" Distribution Statement A: Unlimited Distribution

    Blob '(traction ) $o*pass algorithm

    2st condition 3 oes the pi#el to the left 4west5 havethe same value6

    7es 8 Same region, assign thesame label to the current pi#el

    1o 8 Check ne#t condition

    9nd condition 3 o the pi#els to the north and west ofthe current pi#el have the same value but not the samelabel6

    7es 8 We know that the north and West

    pi#els belong to the same region and must bemerged, assign the current pi#el the minimum ofthe north and west labels and record theirequivalence relationship 1o 8 Check ne#t condition

    2,a6

    2,a2,6

    2,a

  • 8/12/2019 3.2_openCV_blobs

    7/17

    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 adifferent value and the one to the north the same value6

    7es 8 ;ssign the label of the north pi#el tothe current pi#el 1o 8 Check ne#t condition

  • 8/12/2019 3.2_openCV_blobs

    8/17

    OSSIM raining!OV"" Distribution Statement A: Unlimited Distribution

    ;fter the first pass labels are generated for each of the pi#els according to thefour conditions and the equivalence tables are generated

    Blob '(traction ) $o*pass algorithm

    "

    +

    ,

    ,

    -

    ./ 0

    1

  • 8/12/2019 3.2_openCV_blobs

    9/17

    OSSIM raining!OV"" Distribution Statement A: Unlimited Distribution

    &n the second pass the labels are merged

    Blob '(traction ) $o*pass algorithm

  • 8/12/2019 3.2_openCV_blobs

    10/17

    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==5Bblobs.0ilter4blobs, 'A(1C)! *, C'lob"et-ean45, 'A"/*;T*/, 25B

    This allows us to decide how bigD a significant blob is

    Blob '(traction ) $o*pass algorithm

  • 8/12/2019 3.2_openCV_blobs

    11/17

    OSSIM raining!OV"" Distribution Statement A: Unlimited Distribution

    1ow only large blobs remain

    Blob '(traction ) $o*pass algorithm

  • 8/12/2019 3.2_openCV_blobs

    12/17

    OSSIM raining!OV"" Distribution Statement A: Unlimited Distribution

    Blob '(traction ) $o*pass algorithm

    2st 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

    9nd condition 3 o the pi#els to the north and west of the current pi#el havethe same value but not the same label6

    7es 8 We know that the north and West pi#els belong to the sameregion and must be merged, assign the current pi#el the minimum of thenorth 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

  • 8/12/2019 3.2_openCV_blobs

    13/17

    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 connected obEectD

    0or each blob, finds, length, width, and orientation

    Can e#tract the sub image corresponding to the blob area

    Can filter out blobs below or above a certain2. ;rea9. -ean value

  • 8/12/2019 3.2_openCV_blobs

    14/17

    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 blobslibrary.

    The code is in the folder+..?=:A&penC@AandAblobs?e#amples?'lobsAe#amples?&penC@Threshold;nd*#tract'lobs

  • 8/12/2019 3.2_openCV_blobs

    15/17

    OSSIM raining!OV"" Distribution Statement A: Unlimited Distribution

    '(ample: Using the blobs library $ith OpenCV

    -odify the %.bat files so that the paths are correctbuildAcmakeAproEectAvs2=.batcmakeAarguments.bat

    /un buildAcmakeAproEectAvs2=.bat and build the proEect

    Compile the proEect in @isual CFF

    /un ..? ebug?runProEect.bat

  • 8/12/2019 3.2_openCV_blobs

    16/17

    OSSIM raining!OV"" Distribution Statement A: Unlimited Distribution

    Blob '(ample 2esults

  • 8/12/2019 3.2_openCV_blobs

    17/17

    OSSIM raining!OV"" Distribution Statement A: Unlimited Distribution

    Another Sample Image

    This simple algorithm can workwith some easyD images