From 5e8486f68c91b58ee5f0e852b82381da112b0366 Mon Sep 17 00:00:00 2001 From: catree Date: Sun, 9 Oct 2016 23:45:04 +0200 Subject: [PATCH] Try to clarify the morphological operations in the tutorial to avoid possible confusions. --- .../erosion_dilatation.markdown | 15 +++++++++++++++ ...Morphology_1_Tutorial_Theory_Dilatation_2.png | Bin 0 -> 1558 bytes .../Morphology_1_Tutorial_Theory_Erosion_2.png | Bin 0 -> 1533 bytes .../Morphology_2_Tutorial_Theory_Closing_2.png | Bin 0 -> 1383 bytes .../Morphology_2_Tutorial_Theory_Opening_2.png | Bin 0 -> 1341 bytes .../opening_closing_hats.markdown | 11 ++++++++++- 6 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 doc/tutorials/imgproc/erosion_dilatation/images/Morphology_1_Tutorial_Theory_Dilatation_2.png create mode 100644 doc/tutorials/imgproc/erosion_dilatation/images/Morphology_1_Tutorial_Theory_Erosion_2.png create mode 100644 doc/tutorials/imgproc/opening_closing_hats/images/Morphology_2_Tutorial_Theory_Closing_2.png create mode 100644 doc/tutorials/imgproc/opening_closing_hats/images/Morphology_2_Tutorial_Theory_Opening_2.png diff --git a/doc/tutorials/imgproc/erosion_dilatation/erosion_dilatation.markdown b/doc/tutorials/imgproc/erosion_dilatation/erosion_dilatation.markdown index 444e0c4f87..947bd6fc2b 100644 --- a/doc/tutorials/imgproc/erosion_dilatation/erosion_dilatation.markdown +++ b/doc/tutorials/imgproc/erosion_dilatation/erosion_dilatation.markdown @@ -44,6 +44,14 @@ Morphological Operations The background (bright) dilates around the black regions of the letter. +To better grasp the idea and avoid possible confusion, in this another example we have inverted the original +image such as the object in white is now the letter. We have performed two dilatations with a rectangular +structuring element of size `3x3`. + +![Left image: original image inverted, right image: resulting dilatation](images/Morphology_1_Tutorial_Theory_Dilatation_2.png) + +The dilatation makes the object in white bigger. + ### Erosion - This operation is the sister of dilation. What this does is to compute a local minimum over the @@ -56,6 +64,13 @@ The background (bright) dilates around the black regions of the letter. ![](images/Morphology_1_Tutorial_Theory_Erosion.png) +In the same manner, the corresponding image resulting of the erosion operation on the inverted original image (two erosions +with a rectangular structuring element of size `3x3`): + +![Left image: original image inverted, right image: resulting erosion](images/Morphology_1_Tutorial_Theory_Erosion_2.png) + +The erosion makes the object in white smaller. + Code ---- diff --git a/doc/tutorials/imgproc/erosion_dilatation/images/Morphology_1_Tutorial_Theory_Dilatation_2.png b/doc/tutorials/imgproc/erosion_dilatation/images/Morphology_1_Tutorial_Theory_Dilatation_2.png new file mode 100644 index 0000000000000000000000000000000000000000..bdca7c62339475cb30ee30ed690759dd1e54835c GIT binary patch literal 1558 zcmV+x2I={UP)WFU8GbZ8()Nlj2>E@cM*00nwUL_t(|+U?!Ta@#r( zMNw0Q|NmuWlu1%DC6NI7vG&;4(ZxC3Xg*9GKR-XuAEf2^tR3HR970aa!x8`>7ytwV z00aYoU;yN0SOOq7XLk~J-iad^ppZ;n{WrTLLogS@^^69h%VoD@2k11|Dj z+$pL*NsIi`3&8-GE|(pWA{Y}18uf8?zX|4s#U~|zV5UlfWB`HzKrjFZ1^@_VJ|4IO z2nGPb0H`o&6O2PH#%O{8g7eO_5_QTp!2rqS^2yJcV1k9|`U^7kH(Fm!Fef{J zH`O8f^b#3@X%aL*Fa!dW>LkGcFwz1JD>H{=W-1Oz-1A>`nh3&Vt-cC6?S#uj$_9J6I_I@AKCOWf5!ILU?NNi zB!a5)dsr-=5%Qk(*;-F9JEs?7L8PwE>SI~KblWMQlMz3Y=U{>d>Mjy8zZ+?EJ%}^h z@*@{ypQKDMLBk{$J;?MqJjuJ^;3XGC>gsB_l$>C)?-b->ddc+fpY_!#QjkE21$TF1 zw%FeJe52ceJ@Y^|wIIUuvf|%-x3eag&4H2&DvG6?V0KI|#Dd)ia`f+mH^C4K5>6DW zPrbhFZ5zQvxL`&u1uLmGr^Dx$Yf7vhj2*+{iL$0w?n9;f<97N-QOWpVnGkF z?C9=Wxg6wjs z)ZvjK%)bln8xc`SE*&<*5jD(z7eC^csexF?WuaiM21*d9LHhPTOpVzUob{4SRofT8x{&?m0X00N~bg3Hp8z3^XWnV?V`GKgk2la zj5qst?CK-i4gl=xtZ90|1oO!vUy+M2vAQcWUk=}Oqn+|3@2W33GabRCUFZ~P#WfLf zK{UCTrh`l{4ti9ZT6|^j!U-nIxipa>%R%40t6>B~E|}SyZ#v}EsMrKUF32n{eZ3%< zvjulc8dc;$E&(T)Z$lv$m|O^EN;s{6frW)k9n#kYg1KX%kK+&)QXTmE`aa{%1@{-xh$5L;57FuF2EkZ-RF{ly z2M`Pp@pLK5w~rDGP*^lr&%+V`AQ%7y0{{dAfM5U+3;_JcA3*B%y~mug)Bpeg07*qo IM6N<$g5j*1WB>pF literal 0 HcmV?d00001 diff --git a/doc/tutorials/imgproc/erosion_dilatation/images/Morphology_1_Tutorial_Theory_Erosion_2.png b/doc/tutorials/imgproc/erosion_dilatation/images/Morphology_1_Tutorial_Theory_Erosion_2.png new file mode 100644 index 0000000000000000000000000000000000000000..5e666eef3614ce093e5dd178bd4d07284fcf3d90 GIT binary patch literal 1533 zcmVWFU8GbZ8()Nlj2>E@cM*00m)5L_t(|+U?!jZrd;r zMbSv$|NpZ46rfGxM3#A(8Ls_U1gXI}-aM2P`}p|yczhr&k4NqC9miqFi8(C+0D=KP zFaSU>00;&E!2kfk0GLO!1lRfc%!y|-0D|cvlV?9eGJqpece&j8SwMpUkbX0a(yTQY zjRXa=8YRaB(_tv21Q5(nNstUQZGr)|kxK*#5e%TY5Db8P5KJdLa0d_!U?U?K02O3J zFpfBoXM!)FyJ3D+~M3-FysPxC72My@+=I6Kyk5yYB9K`^uAVwi}~v`6Q#O4Dwc7K2={I=|rhTp&+HoA@0%$Nbb_Um9pm8N_FaSU>g?9?npxQ@kp1TbV z0KsT40Kovzw4c)qE%s~GuC!_m2E#PyySur`N$xavVw^+G;%?vxsQ5^+z}~=T!;nL?s7i+KWF5z z8QPrRO)i+7iIrk0BbX6#>HRy&1rgp4D{{ES5$UIe9oc?}1yP#zsw}o$1~&8TODu@c zv?JuO87{e?PKKl9uT@>>C`T}0M$?X(!B%B3q=Fqc%jh|56&IaYP&LQd^4BU4gIGW& z8wcZRyJOB;mf;WyGPjjov)3{V$1o95D$jD}d#@%4X4N8-3r6Pl zPQG@|WLq($y92T_V1-z0T7d*J>f;R}ewiAG1rr71Dm${vrFRB*&vY9#sGdV`G{R`P z^b$daFS1W1m?(doWtdnk7jza(lrI<)5JV7*_VPbxbh$VlL2KEp!MysWzdKBKjzBIO zACVkikV!7HzBX9q-#8+@(q7(KXh$QEiv}~KwPgMLQN%<}k~EkZ*F?w#y<0_vmbA?g z$(tS^mnDLkwd)urR<{>&NhTO_!3gAqV1xx4((Zy8`8AaWhOBb2=}l@dcO^kCaQq^e zA+nhD&>qk`-}1OXFyw-0&7xOBCYQm2xw@#o4fOGNkPA{thFtE`ULD$%VU7A+Ucj-a z_z`K=A{!=FwwSL?TOKDgm=(bQ-p$gdD58A4s|K@h!3`6UG9`}-1T$*k4HHo$a~y{} zu0A4Nz359Wh$NY3nU%p{g6Sa{Lq(<|6DAAh%FbZG0KwQ90CeTF1ONyI0KotN!2lo_ j00aX71OtFz02JU4O40(pVDRtD00000NkvXXu0mjfQaX&Y literal 0 HcmV?d00001 diff --git a/doc/tutorials/imgproc/opening_closing_hats/images/Morphology_2_Tutorial_Theory_Closing_2.png b/doc/tutorials/imgproc/opening_closing_hats/images/Morphology_2_Tutorial_Theory_Closing_2.png new file mode 100644 index 0000000000000000000000000000000000000000..57b790583f42933202d593d58ebb49521bd529fe GIT binary patch literal 1383 zcmYjRX;4#F6nNC|z~7weDCJ@?*o@7caHbIv&tyDi+- z#@z-009!!>Z#w{3xuSdxXpNru&@<)eWt|ii&I8_Cmb$aC3jHBwMeNB2020Nrt$;d} z#fBggMDq#bHbiH)4Gno6s0>(^zGJs6^gu>NYNiZ*0zjxVHBpwDLeEK;eNGP-M8~GE zQV9Tndnn)q?~woYYHTdCf$hXkJo(SN8!FAxQ{QbH_Ijd%4vSxffw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^xQzb4v|JXqUab5Hb^O6rCyiia1bBNWiP%dZz0ji|^kzJvHh3=roBH$fH7v=X9kH z_4${H4tv&_7u;qa*dNt9Rjh1)1$a+a+0%82!&Kt`hYk*VObnoe8@IdhZm52Li*~(b N-U;~Ic-KS3(7%}ZOS}L8 literal 0 HcmV?d00001 diff --git a/doc/tutorials/imgproc/opening_closing_hats/images/Morphology_2_Tutorial_Theory_Opening_2.png b/doc/tutorials/imgproc/opening_closing_hats/images/Morphology_2_Tutorial_Theory_Opening_2.png new file mode 100644 index 0000000000000000000000000000000000000000..973e13a2d24c11fbbceda8d89676243bc17d3b3c GIT binary patch literal 1341 zcmYL}2~d+q6oCJPB!nXea)qippvsVM=45+N8s48@}bW5G}<{nP18XJ_Ag``#Yk?CyJKqxP{0 zmd=&{01(1BtOEdmq9Aq+9*0P5$i?%B!o`QPS-`rfUHR!oHR7>2#)&-+09Ll9jsof~ znbw$RhwTkDpSHBHcOps(%qkI=+mYy)?2rtBASpc?83I5^RuVruDUo{ONOmff9kw?r z5lk`%08C>TD=0c|;?>m1xe2BCY$q8JVqj_S7FiaC59y6%RBsIrgCkRz5P+f8le8ijK%3z!xUTdD^wUKz zlYp9xc2buz4^XPs85vT~ve%E;KlEc=+6lBdW3+htO1C=(vgSB;=z+D9pez8eh>_2-{Uk9P#E&vbHi4zlsdRoOYGAVwyddkw zxFCBGl7EqlP1G^<{r%k0=z8NG!^vo2p#V(09NE4iV}ILg>)5Qm!M)y7Mgzs=Fy5+X zBmHCI%cDGNLTyUI9ix9U!*@SdBH%E+zu(!wzSC<9q~UV>x46}JLW)$OWNw&jzXwB` zoo*SFs`Vn{oV{`kZ|I7F{F`j-IyjLe<@jdm))E2zF{$sx_98xG-q7BJ618neU|OdSqxS?~GhPZf zEkGY%5xFh>{#EDsrK_Iw_k_pTYmaAV2X!Mei?izynKl<&l}9rrZzgU1U&~8MRmj_$ zg))O2e8}7sS~)>~D;Lwz$^G#pTAW4wMci z{=tOdr0)(drLcw+ai-XIgK9orWb9K~Sk&g!spYWnc{vpnhr4?;%vHWs7xe_`Q>E%K zmx$4Em+W_pgTGF&b`8xB!`ey-b9#9<^j%s14bMSW2ZIwux;3!5cML&#l*7ot(jJf~ zwvO6QpS@XDaN1|%*GiIIRAZiN3j38In;lb7ix^%c=zm_$@&wZ>DFHrUZfJVd)sC7& zPvfEcuq)A0RWZ)$D^+o2goV0BnKG|XB!^XZ(H2hs{@zg!P@W3a3n))64D_Fs6ZBIY zu~p0GZ&#GOt^=yoVRubQc?P}e8%aoMznS5A^}AT#A%mUcZ?~5Oler6_=WAuP;_z0( z%`d{U=Doa&t23&S1Ez@%&bZyY!eN+&WAczxQ{;#=-0M|AWJj`ehQFBL!;cGL4E|-0 xUw^-@LY1-v`%<=)o(b;Ym=YhU5dW)9i{@S4J_^mbu3S?U3k%)HY7K^p{sBv$RJH&B literal 0 HcmV?d00001 diff --git a/doc/tutorials/imgproc/opening_closing_hats/opening_closing_hats.markdown b/doc/tutorials/imgproc/opening_closing_hats/opening_closing_hats.markdown index be32508afa..c941413e50 100644 --- a/doc/tutorials/imgproc/opening_closing_hats/opening_closing_hats.markdown +++ b/doc/tutorials/imgproc/opening_closing_hats/opening_closing_hats.markdown @@ -24,7 +24,7 @@ In the previous tutorial we covered two basic Morphology operations: - Dilation. Based on these two we can effectuate more sophisticated transformations to our images. Here we -discuss briefly 05 operations offered by OpenCV: +discuss briefly 5 operations offered by OpenCV: ### Opening @@ -40,6 +40,11 @@ discuss briefly 05 operations offered by OpenCV: ![](images/Morphology_2_Tutorial_Theory_Opening.png) +For the sake of clarity, we have performed the opening operation (`7x7` rectangular structuring element) +on the same original image but inverted such as the object in white is now the letter. + +![Left image: original image inverted, right image: resulting opening](images/Morphology_2_Tutorial_Theory_Opening_2.png) + ### Closing - It is obtained by the dilation of an image followed by an erosion. @@ -50,6 +55,10 @@ discuss briefly 05 operations offered by OpenCV: ![](images/Morphology_2_Tutorial_Theory_Closing.png) +On the inverted image, we have performed the closing operation (`7x7` rectangular structuring element): + +![Left image: original image inverted, right image: resulting closing](images/Morphology_2_Tutorial_Theory_Closing_2.png) + ### Morphological Gradient - It is the difference between the dilation and the erosion of an image.