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
371d08fc
Commit
371d08fc
authored
3 weeks ago
by
Decouvelaere Antonin
Browse files
Options
Downloads
Patches
Plain Diff
fonction_masque
parent
35f1bb94
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
masque.py
+16
-6
16 additions, 6 deletions
masque.py
with
16 additions
and
6 deletions
masque.py
+
16
−
6
View file @
371d08fc
import
numpy
as
np
import
cv2
def
masque
(
image
):
image_np
=
np
.
array
(
image
)
for
k
in
range
(
np
.
shape
(
image_np
)[
0
]):
for
i
in
range
(
np
.
shape
(
image_np
)[
1
]):
pass
\ No newline at end of file
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
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