Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
Bildverarbeitung
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Moh Kh
Bildverarbeitung
Commits
88559f8a
Commit
88559f8a
authored
1 year ago
by
Midras Lappe
Browse files
Options
Downloads
Patches
Plain Diff
Gitter erweitert sodass Felder mit weniger als zwei Nnachbarn entfernt werden
parent
5fd72477
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
filter_pipeline.py
+3
-1
3 additions, 1 deletion
filter_pipeline.py
filters.py
+61
-2
61 additions, 2 deletions
filters.py
with
64 additions
and
3 deletions
filter_pipeline.py
+
3
−
1
View file @
88559f8a
...
@@ -7,6 +7,7 @@ import pandas as pd
...
@@ -7,6 +7,7 @@ import pandas as pd
import
filters
import
filters
VIDEO
=
'
Videomaterial/WIN_20230602_14_45_52_Pro.mp4
'
VIDEO
=
'
Videomaterial/WIN_20230602_14_45_52_Pro.mp4
'
#VIDEO = 'Videomaterial/WIN_20230414_13_41_55_Pro.mp4'
capture
=
cv2
.
VideoCapture
(
VIDEO
)
capture
=
cv2
.
VideoCapture
(
VIDEO
)
capture
.
set
(
cv2
.
CAP_PROP_POS_FRAMES
,
30
*
0
)
# skip 40 seconds
capture
.
set
(
cv2
.
CAP_PROP_POS_FRAMES
,
30
*
0
)
# skip 40 seconds
...
@@ -57,8 +58,9 @@ pipeline = [
...
@@ -57,8 +58,9 @@ pipeline = [
(
'
Green filter abs
'
,
filters
.
green_absfilter
),
(
'
Green filter abs
'
,
filters
.
green_absfilter
),
(
'
Canny edge detection
'
,
filters
.
filter_canny
),
(
'
Canny edge detection
'
,
filters
.
filter_canny
),
(
'
Morph close
'
,
filters
.
filter_close
),
(
'
Morph close
'
,
filters
.
filter_close
),
(
'
gitter_filter
'
,
filters
.
gitter
),
#
('gitter_filter', filters.gitter),
#('Morph open', filters.filter_open),
#('Morph open', filters.filter_open),
(
'
Einzelne Rauswerfen
'
,
filters
.
sortOut
),
(
'
Point extraction
'
,
filters
.
points_extract
),
(
'
Point extraction
'
,
filters
.
points_extract
),
(
'
Polyfit lines
'
,
filters
.
points_overlay
)
(
'
Polyfit lines
'
,
filters
.
points_overlay
)
]
]
...
...
This diff is collapsed.
Click to expand it.
filters.py
100644 → 100755
+
61
−
2
View file @
88559f8a
...
@@ -2,6 +2,7 @@ import cv2 as cv
...
@@ -2,6 +2,7 @@ import cv2 as cv
import
numpy
as
np
import
numpy
as
np
import
pandas
as
pd
import
pandas
as
pd
import
matplotlib.pyplot
as
plt
import
matplotlib.pyplot
as
plt
from
scipy
import
signal
from
collections
import
deque
from
collections
import
deque
currentfig
=
None
currentfig
=
None
...
@@ -39,7 +40,8 @@ def gitter(info, image, state):
...
@@ -39,7 +40,8 @@ def gitter(info, image, state):
ax
.
grid
(
True
,
which
=
'
major
'
)
ax
.
grid
(
True
,
which
=
'
major
'
)
diff_x
=
40
diff_x
=
40
diff_y
=
40
diff_y
=
40
treshold
=
30
treshold
=
5
haspoints
=
np
.
zeros
([(
int
)(
1280
/
diff_x
),(
int
)(
720
/
diff_y
)])
ax
.
set_xticks
(
range
(
0
,
1280
,
diff_x
))
ax
.
set_xticks
(
range
(
0
,
1280
,
diff_x
))
ax
.
set_yticks
(
range
(
0
,
720
,
diff_y
))
ax
.
set_yticks
(
range
(
0
,
720
,
diff_y
))
...
@@ -49,6 +51,15 @@ def gitter(info, image, state):
...
@@ -49,6 +51,15 @@ def gitter(info, image, state):
subimg
=
image
[
y
:
y
+
diff_y
,
x
:
x
+
diff_x
]
subimg
=
image
[
y
:
y
+
diff_y
,
x
:
x
+
diff_x
]
indices
=
np
.
where
(
subimg
>
0
)
indices
=
np
.
where
(
subimg
>
0
)
if
(
indices
[
1
].
size
>
treshold
):
if
(
indices
[
1
].
size
>
treshold
):
haspoints
[(
int
)(
x
/
diff_x
),(
int
)(
y
/
diff_y
)]
=
1
neighbours
=
findneighbours
(
haspoints
)
for
x
in
range
(
0
,
1280
,
diff_x
):
for
y
in
range
(
0
,
720
,
diff_y
):
subimg
=
image
[
y
:
y
+
diff_y
,
x
:
x
+
diff_x
]
indices
=
np
.
where
(
subimg
>
0
)
if
(
neighbours
[(
int
)(
x
/
diff_x
),(
int
)(
y
/
diff_y
)]
>
2
):
x_so
=
indices
[
1
]
+
x
x_so
=
indices
[
1
]
+
x
y_so
=
indices
[
0
]
+
y
y_so
=
indices
[
0
]
+
y
...
@@ -68,8 +79,56 @@ def gitter(info, image, state):
...
@@ -68,8 +79,56 @@ def gitter(info, image, state):
return
image
,
False
return
image
,
False
def
sortOut
(
info
,
image
,
state
):
# image Range ((1280, 720))
diff_x
=
40
diff_y
=
40
treshold
=
30
haspoints
=
np
.
zeros
([(
int
)(
1280
/
diff_x
),(
int
)(
720
/
diff_y
)])
for
x
in
range
(
0
,
1280
,
diff_x
):
for
y
in
range
(
0
,
720
,
diff_y
):
subimg
=
image
[
y
:
y
+
diff_y
,
x
:
x
+
diff_x
]
indices
=
np
.
where
(
subimg
>
0
)
if
(
indices
[
1
].
size
>
treshold
):
haspoints
[(
int
)(
x
/
diff_x
),(
int
)(
y
/
diff_y
)]
=
1
neighbours
=
findneighbours
(
haspoints
)
for
x
in
range
(
0
,
1280
,
diff_x
):
for
y
in
range
(
0
,
720
,
diff_y
):
if
(
neighbours
[(
int
)(
x
/
diff_x
),(
int
)(
y
/
diff_y
)]
<
3
):
image
[
y
:
y
+
diff_y
,
x
:
x
+
diff_x
]
=
0
return
image
,
False
def
findneighbours
(
haspoints
):
#print(haspoints)
#flat = np.ravel(haspoints)
# Definition des Kernel-Filters für die Nachbarschaft (umliegenden Felder)
#kernel = np.ones((3, 3)) # 3x3 Kernel aus Einsen
# Berechnung der Summe der umliegenden Felder
#sum_neighbors = np.convolve2d(haspoints, kernel, mode='same')
kernel
=
np
.
ones
([
3
,
3
])
# 3x3 Kernel aus Einsen
result
=
signal
.
convolve2d
(
haspoints
,
kernel
,
mode
=
'
same
'
)
result
[
result
<
3
]
=
0
result
=
result
*
haspoints
return
result
# Cut green kanal
# Cut green kanal
def
greenfilter
(
info
,
image
,
state
):
def
greenfilter
(
info
,
image
,
state
):
# Umwandeln des Bildes in den Farbraum HSV
# Umwandeln des Bildes in den Farbraum HSV
...
...
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