381 lines
9.9 KiB
Markdown
381 lines
9.9 KiB
Markdown
|
---
|
||
|
|
||
|
settings:
|
||
|
enabled_extensions:
|
||
|
- default
|
||
|
- extra
|
||
|
- tables
|
||
|
- tasklist
|
||
|
- codehilite(linenums=true)
|
||
|
---
|
||
|
<style>
|
||
|
body{
|
||
|
max-width: 1000px;
|
||
|
width: 95%;
|
||
|
margin-bottom: 60vh;
|
||
|
}
|
||
|
h1 {
|
||
|
counter-reset: countA;
|
||
|
text-align: center;
|
||
|
color: #004335;
|
||
|
background-color: #EDFFFF;
|
||
|
padding-top: 10px;
|
||
|
border-top: 5px solid #EEEEEE !important;
|
||
|
border-bottom: 5px solid #EEEEEE !important;
|
||
|
margin-top: 3em !important;
|
||
|
left: -30px;
|
||
|
width: calc(100% + 60px);
|
||
|
}
|
||
|
.markdown-body>h1:first-of-type{
|
||
|
margin-top: 0px !important;
|
||
|
padding: 20px;
|
||
|
font-size: 3em;
|
||
|
top: -30px;
|
||
|
border-top: none !important;
|
||
|
}
|
||
|
h1 .headeranchor-link{
|
||
|
margin-left: 0px !important;
|
||
|
}
|
||
|
h2 {
|
||
|
counter-reset: countB;
|
||
|
color: #004335;
|
||
|
margin-top: 2em !important;
|
||
|
left: -15px;
|
||
|
width: calc(100% + 30px);
|
||
|
}
|
||
|
h2 .headeranchor-link{
|
||
|
margin-left: -20px !important;
|
||
|
}
|
||
|
h3 { counter-reset: countC; }
|
||
|
h3 { counter-reset: countD; }
|
||
|
h1::before, h1::after {content: " - ";}
|
||
|
h2::before {
|
||
|
content: counter(countA) ". ";
|
||
|
counter-increment: countA;
|
||
|
}
|
||
|
h3::before {
|
||
|
content: counter(countA) "-" counter(countB) ". ";
|
||
|
counter-increment: countB;
|
||
|
}
|
||
|
h4::before {
|
||
|
content: counter(countA) "-" counter(countB) "-" counter(countC) ". ";
|
||
|
counter-increment: countC;
|
||
|
}
|
||
|
h5::before {
|
||
|
content: counter(countA) "-" counter(countB) "-" counter(countC) "-" counter(countD) ". ";
|
||
|
counter-increment: countD;
|
||
|
}
|
||
|
info, good, warn, err{
|
||
|
border-left: 4px solid #000;
|
||
|
padding: 5px;
|
||
|
padding-left: 15px;
|
||
|
display: inline-block;
|
||
|
}
|
||
|
|
||
|
info {
|
||
|
background-color: #E8FAFF;
|
||
|
border-left-color: #8BE8FF;
|
||
|
}
|
||
|
good {
|
||
|
background-color: #E8FFEA;
|
||
|
border-left-color: #6DFF7B;
|
||
|
}
|
||
|
warn {
|
||
|
background-color: #FFF5EB;
|
||
|
border-left-color: #FFE28B;
|
||
|
}
|
||
|
err {
|
||
|
background-color: #fceded;
|
||
|
border-left-color: #dfb5b4;
|
||
|
}
|
||
|
.toc{
|
||
|
margin-left: 5%;
|
||
|
padding-left: 5%;
|
||
|
border-left: 5px solid #EEEEEE;
|
||
|
}
|
||
|
.toc>ul:first-child>li:first-child{
|
||
|
display: none;
|
||
|
}
|
||
|
.linenos{
|
||
|
color: #BBB;
|
||
|
padding: 0px;
|
||
|
border-right: 4px solid #EEE !important;
|
||
|
}
|
||
|
.linenos pre{
|
||
|
padding-right: 5px;
|
||
|
}
|
||
|
.suppr{
|
||
|
display: none;
|
||
|
content: "";
|
||
|
}
|
||
|
todo::before{
|
||
|
color: #F00;
|
||
|
content: "TODO";
|
||
|
background-color: #0FF;
|
||
|
font-weight: bold;
|
||
|
padding: 2px;
|
||
|
margin-right: 5px;
|
||
|
}
|
||
|
|
||
|
.codehilite pre{
|
||
|
background-color: #272822;
|
||
|
}
|
||
|
.hidden{
|
||
|
display: none;
|
||
|
}
|
||
|
|
||
|
img{
|
||
|
width: 70%;
|
||
|
}
|
||
|
.dual, .quad{
|
||
|
text-align: center;
|
||
|
}
|
||
|
.dual img{
|
||
|
max-width: calc(100% / 2 - 10px);
|
||
|
margin: 5px;
|
||
|
}
|
||
|
.quad img{
|
||
|
max-width: calc(50% / 2 - 10px);
|
||
|
margin: 5px;
|
||
|
}
|
||
|
|
||
|
</style>
|
||
|
|
||
|
# TP 2 ImageJ : Filtrage, Contours, Morphologie Mathématique
|
||
|
|
||
|
__Thomas ABOT__
|
||
|
__Thibaut CHARLES__
|
||
|
|
||
|
|
||
|
<div class="hidden">
|
||
|
katia.charriere@telecom-bretagne.eu
|
||
|
</div>
|
||
|
[TOC]
|
||
|
|
||
|
Partie I : Filtrage spatial, Contours
|
||
|
===============================================================================
|
||
|
|
||
|
Exercice 1 : Filtrage linéaire bidimensionnel non récursif dans le domaine spatial
|
||
|
-------------------------------------------------------------------------------
|
||
|
|
||
|
### Filtres
|
||
|
#### Smooth
|
||
|
<span class="dual">
|
||
|
![](moly_orig.PNG)![](moly_smooth.PNG)
|
||
|
![](freq_moly_orig.PNG)![](freq_moly_smooth.PNG)
|
||
|
</span>
|
||
|
|
||
|
#### Sharpen
|
||
|
<span class="dual">
|
||
|
![](moly_orig.PNG)![](moly_sharpen.PNG)
|
||
|
![](freq_moly_orig.PNG)![](freq_moly_sharpen.PNG)
|
||
|
</span>
|
||
|
|
||
|
#### Shadows
|
||
|
<span class="dual">
|
||
|
![](moly_orig.PNG)![](moly_shadow.PNG)
|
||
|
![](freq_moly_orig.PNG)![](freq_moly_shadow.PNG)
|
||
|
</span>
|
||
|
|
||
|
#### Convolution
|
||
|
|
||
|
##### Tests
|
||
|
<span class="dual">
|
||
|
![](TestConvolve_orig.PNG)![](TestConvolve_customkernel.PNG)
|
||
|
</span>
|
||
|
> La convolution est correcte
|
||
|
|
||
|
##### Flou Gaussien
|
||
|
<span class="dual">
|
||
|
![](moly_orig.PNG)![](moly_gaussien.PNG)
|
||
|
![](freq_moly_orig.PNG)![](freq_moly_gaussien.PNG)
|
||
|
</span>
|
||
|
|
||
|
##### Gradient N
|
||
|
<span class="dual">
|
||
|
![](moly_orig.PNG)![](moly_gradientN.PNG)
|
||
|
![](freq_moly_orig.PNG)![](freq_moly_gradientN.PNG)
|
||
|
</span>
|
||
|
|
||
|
##### Laplacien
|
||
|
<span class="dual">
|
||
|
![](moly_orig.PNG)![](moly_laplacien.PNG)
|
||
|
![](freq_moly_orig.PNG)![](freq_moly_laplacien.PNG)
|
||
|
</span>
|
||
|
|
||
|
### Commentaires
|
||
|
|
||
|
- <todo/>
|
||
|
|
||
|
|
||
|
|
||
|
Exercice 2 : Filtres non-linéaires bidimensionnels, les filtres médians
|
||
|
-------------------------------------------------------------------------------
|
||
|
|
||
|
### Médian
|
||
|
<span class="dual">![](cornee_orig.PNG)![](cornee_median.PNG)</span>
|
||
|
|
||
|
### Moyenne
|
||
|
<span class="dual">![](cornee_orig.PNG)![](cornee_mean.PNG)</span>
|
||
|
|
||
|
|
||
|
### Bateau, Salt and Pepper
|
||
|
<span class="dual">![](bateau_orig.PNG)![](bateau_saltandpepper.PNG)</span>
|
||
|
|
||
|
#### Médian, taille 3
|
||
|
<span class="dual">![](bateau_saltandpepper.PNG)![](bateau_saltandpepper_median3.PNG)</span>
|
||
|
#### Moyenne, taille 3
|
||
|
<span class="dual">![](bateau_saltandpepper.PNG)![](bateau_saltandpepper_mean3.PNG)</span>
|
||
|
|
||
|
|
||
|
|
||
|
Exercice 3 : Introduction à la détection de contours
|
||
|
-------------------------------------------------------------------------------
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
Partie II : Morphologie Mathématique
|
||
|
===============================================================================
|
||
|
|
||
|
Traitement d'images binaires
|
||
|
-------------------------------------------------------------------------------
|
||
|
|
||
|
### Importance du choix de l'élément structurant (voisinage)
|
||
|
|
||
|
#### Érosion de taille 3 sur l'image partB
|
||
|
|
||
|
##### Érosion carrée
|
||
|
<span class="quad">![](partb_orig.PNG)![](partb_carre.PNG)</span>
|
||
|
##### Érosion héxagonale
|
||
|
<span class="quad">![](partb_orig.PNG)![](partb_hexagonal.PNG)</span>
|
||
|
##### Érosion Circulaire
|
||
|
<span class="quad">![](partb_orig.PNG)![](partb_cercle.PNG)</span>
|
||
|
|
||
|
#### Cercle1
|
||
|
<span class="quad">![](cercle_orig.PNG)</span>
|
||
|
|
||
|
##### Érosion carrée/hexagonale/circulaire
|
||
|
<span class="quad">![](cercle_erode_carre.PNG)![](cercle_erode_hexa.PNG)![](cercle_erode_cercle.PNG)</span>
|
||
|
##### Dilatation carrée/hexagonale/circulaire
|
||
|
<span class="quad">![](cercle_dilate_carre.PNG)![](cercle_dilate_hexa.PNG)![](cercle_dilate_cercle.PNG)</span>
|
||
|
|
||
|
#### Cercle2
|
||
|
- Idem que pour Cercle1
|
||
|
- Disparition du cercle quand l'érosion est trop forte
|
||
|
|
||
|
#### Rectangles
|
||
|
<span class="quad">![](rectangle_orig.PNG)</span>
|
||
|
|
||
|
|
||
|
##### Érosion carrée/hexagonale/circulaire
|
||
|
<span class="quad">![](rectangle_erode_carre.PNG)![](rectangle_erode_hexa.PNG)![](rectangle_erode_cercle.PNG)</span>
|
||
|
##### Dilatation carrée/hexagonale/circulaire
|
||
|
<span class="quad">![](rectangle_dilate_carre.PNG)![](rectangle_dilate_hexa.PNG)![](rectangle_dilate_cercle.PNG)</span>
|
||
|
|
||
|
|
||
|
#### Deviner le type de voisinage
|
||
|
|
||
|
On prend une forme de base, puis on le dilate beaucoup.
|
||
|
|
||
|
> Dilatation circulaire / rectangulaire
|
||
|
<span class="quad">![](binary_dilate_cercle.PNG)![](binary_dilate_rectangle.PNG)</span>
|
||
|
|
||
|
|
||
|
#### Choix du voisinage
|
||
|
|
||
|
Il dépend de l'image source:
|
||
|
- On préférera un voisinage carré pour conserver les angles de l'image
|
||
|
- Le voisinage circulaire est plus adapté pour les images avec des formes courbes
|
||
|
|
||
|
### Utilisation des transformations élémentaires
|
||
|
|
||
|
#### Circuit
|
||
|
|
||
|
Obtention des frontières par différence entre l'image érodée/dilatée et l'image originale
|
||
|
|
||
|
> Image originale/érodée/différence entre les deux
|
||
|
<span class="quad">![](circuit_orig.PNG)![](circuit_erode.PNG)![](circuit_diff.PNG)</span>
|
||
|
|
||
|
#### Grains de café
|
||
|
On érode les grains de café pour faire disparaître les plus petits, puis on dilate puis compte les grains restants.
|
||
|
|
||
|
> Image originale/érodée/dilatée/comptage
|
||
|
<span class="quad">![](cafe_orig.PNG)![](cafe_erodeCercle3.PNG)![](cafe_dilateCercle2.PNG)![](cafe_count.PNG)</span>
|
||
|
|
||
|
#### Circuit (bis)
|
||
|
On érode le circuit afin de faire disparaître les pistes puis dilate autant qu'on a érodé afin de retrouver la taille originale des pastilles.
|
||
|
Une fois qu'on a les pastilles, on fait la différence entre l'originale et les pastilles.
|
||
|
|
||
|
> Image originale/érodée/re-dilatée/différence
|
||
|
<span class="quad">![](circuit_orig.PNG)![](circuit_pastilles_erodeCercle4.PNG)![](circuit_pastilles_erodeCercle4_dilateCercle4.PNG)![](circuit_pistes.PNG)</span>
|
||
|
|
||
|
Pour isoler les pistes obliques, il faut éroder l'image suivant une ligne oblique.
|
||
|
|
||
|
### Transformations utiles
|
||
|
|
||
|
#### Remplissage des trous
|
||
|
|
||
|
On peut boucher les trous en dilatant puis érodant l'image.
|
||
|
> Image originale/binarisée/érodée/re-dilatée
|
||
|
<span class="quad">![](circuit_2_color.PNG)![](circuit_2_binary.PNG)![](circuit_2_erode.PNG)![](circuit_2_dilate.PNG)</span>
|
||
|
|
||
|
#### Étiquetage
|
||
|
|
||
|
> Image originale/étiquetée
|
||
|
<span class="quad">![](partb_orig.PNG)![](partb_etiquetteRGB.PNG)</span>
|
||
|
|
||
|
### Exercice
|
||
|
|
||
|
> Image originale/binarisée/érodée/re-dilatée/Comptage
|
||
|
<span class="quad">![](riz_orig.PNG)![](riz_binary.PNG)![](riz_erodeHorizontal4.PNG)![](riz_dilateHorizontal4.PNG)![](riz_count.PNG)</span>
|
||
|
|
||
|
Morphologie décimale
|
||
|
-------------------------------------------------------------------------------
|
||
|
|
||
|
### Cornée
|
||
|
|
||
|
> Originale / érosion / soustraction & binarisation
|
||
|
<span class="quad">![](cornee_orig.PNG)![](cornee_erosion8hexa.PNG)![](cornee_substractbinary.PNG)</span>
|
||
|
|
||
|
|
||
|
> Approximation des contours via érosion
|
||
|
<span class="quad">![](Cornee_erodeCercle1_approxContour.PNG)</span>
|
||
|
|
||
|
### Gradient morphologique
|
||
|
|
||
|
> Originale / Gradient de Sobel
|
||
|
<span class="quad">![](babouin_orig.PNG)![](babouin_sobel.PNG)</span>
|
||
|
|
||
|
> Originale / Dilatée / Érodée / Gradient morphologique
|
||
|
<span class="quad">![](babouin_orig.PNG)![](babouin_dilate2cercle.PNG)![](babouin_erosion2cercle.PNG)![](babouin_sobel.PNG)</span>
|
||
|
|
||
|
|
||
|
### Filtrage morphologique
|
||
|
|
||
|
#### Fermeture
|
||
|
> Originale / ... / Fermeture
|
||
|
<span class="quad">![](babouin_orig.PNG)![](babouin_fermeture1.PNG)![](babouin_diffFermeture.PNG)</span>
|
||
|
|
||
|
#### Ouverture
|
||
|
> Originale / ... / Ouverture
|
||
|
<span class="quad">![](babouin_orig.PNG)![](babouin_ouverture1.PNG)![](babouin_diffOuverture.PNG)</span>
|
||
|
|
||
|
|
||
|
Exercices d'application
|
||
|
-------------------------------------------------------------------------------
|
||
|
|
||
|
### Image partB
|
||
|
|
||
|
<todo/>
|
||
|
|
||
|
### Image meb
|
||
|
|
||
|
> Originale / Binarisation / Érosion / Dilatation / Comptage
|
||
|
<span class="quad">![](meb_orig.PNG)![](meb_binary.PNG)![](meb_erodeCercle2.PNG)![](meb_dilate4.PNG)![](meb_countIs407.PNG)</span>
|
||
|
|
||
|
|
||
|
### Image circuit "binarisée"
|
||
|
|
||
|
<todo/>
|