Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
IA detection leucémie
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Decouvelaere Antonin
IA detection leucémie
Commits
58c198f1
Commit
58c198f1
authored
1 week ago
by
Decouvelaere Antonin
Browse files
Options
Downloads
Patches
Plain Diff
ajout d'un masque
parent
5835246a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Test_traitement_image.py
+7
-3
7 additions, 3 deletions
Test_traitement_image.py
masque.py
+8
-16
8 additions, 16 deletions
masque.py
with
15 additions
and
19 deletions
Test_traitement_image.py
+
7
−
3
View file @
58c198f1
...
...
@@ -5,11 +5,15 @@ from RGB_LAB import *
from
K_clustering
import
*
from
binary_thresholding
import
*
from
Retour_RGB
import
*
from
masque
import
remove_isolated_pixels
image_RGB
=
resizing1
(
"
exemple_image.jpg
"
)
image_traitee
=
Binary_tresholding
(
K_clustering
(
RGB_LAB
(
resizing1
(
"
exemple_image.jpg
"
))))
image_RGB
=
resizing1
(
"
C:
\\
Users
\\
antod
\\
Desktop
\\
Projet S6
\\
ia-detection-leucemie
\\
exemple_image.jpg
"
)
image_traitee
=
Binary_tresholding
(
K_clustering
(
RGB_LAB
(
resizing1
(
"
C:
\\
Users
\\
antod
\\
Desktop
\\
Projet S6
\\
ia-detection-leucemie
\\
exemple_image.jpg
"
))))
removed_pixel
=
remove_isolated_pixels
(
image_traitee
,
k
=
7
)
cv2
.
imshow
(
"
image de base
"
,
image_RGB
)
cv2
.
imshow
(
'
Image traitée
'
,
image_traitee
)
cv2
.
imshow
(
'
Retour aux origines
'
,
mask_RGB
(
image_RGB
,
image_traitee
))
cv2
.
imshow
(
'
Retour aux origines
'
,
mask_RGB
(
image_RGB
,
removed_pixel
))
cv2
.
imshow
(
'
masque
'
,
removed_pixel
)
cv2
.
waitKey
(
0
)
cv2
.
destroyAllWindows
()
\ No newline at end of file
This diff is collapsed.
Click to expand it.
masque.py
+
8
−
16
View file @
58c198f1
import
cv2
as
cv
import
numpy
as
np
import
cv2
def
remove_isolated_pixels
(
img
,
k
=
7
):
"""
k est la taile du motif pour supprimer le bruit avec la focntion otsu
"""
blur
=
cv
.
GaussianBlur
(
img
,(
k
,
k
),
0
)
ret3
,
img_th3
=
cv
.
threshold
(
blur
,
0
,
255
,
cv
.
THRESH_BINARY
+
cv
.
THRESH_OTSU
)
return
img_th3
def
remove_isolated_pixels
(
src
):
kernel
=
np
.
ones
((
3
,
3
),
np
.
uint8
)
# Kernel 3x3 pour compter les voisins
neighbor_count
=
cv2
.
filter2D
(
src
,
ddepth
=-
1
,
kernel
=
kernel
)
# Comptage des pixels blancs autour de chaque pixel
# Masques pour les pixels isolés
isolated_white
=
(
src
==
255
)
&
(
neighbor_count
<=
255
*
2
)
# Pixels blancs isolés
isolated_black
=
(
src
==
0
)
&
(
neighbor_count
>=
255
*
7
)
# Pixels noirs isolés
# Création d'une copie et correction des pixels isolés
result
=
src
.
copy
()
result
[
isolated_white
]
=
0
# Remplace les pixels blancs isolés par du noir
result
[
isolated_black
]
=
255
# Remplace les pixels noirs isolés par du blanc
return
result
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment