Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
BachelorDeeplearning
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
s184400
BachelorDeeplearning
Commits
3eebd6ed
Commit
3eebd6ed
authored
4 years ago
by
pjtka
Browse files
Options
Downloads
Patches
Plain Diff
fillborder
parent
9ad54125
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
Gaussian_derivative.py
+42
-0
42 additions, 0 deletions
Gaussian_derivative.py
general_cc1.py
+26
-0
26 additions, 0 deletions
general_cc1.py
with
68 additions
and
0 deletions
Gaussian_derivative.py
0 → 100644
+
42
−
0
View file @
3eebd6ed
import
numpy
as
np
import
cv2
def
fill_border
(
image
,
border_width
):
dimension
=
1
if
len
(
image
.
shape
)
==
2
:
y_height
,
x_height
=
image
.
shape
out_image
=
np
.
zeros
((
y_height
+
border_width
*
2
,
x_height
+
border_width
*
2
,
dimension
))
y_height
-=
1
x_height
-=
1
else
:
y_height
,
x_height
,
dimension
=
image
.
shape
out_image
=
np
.
zeros
((
y_height
+
border_width
*
2
,
x_height
+
border_width
*
2
,
dimension
))
y_height
-=
1
x_height
-=
1
#border_width -= 1
border_mat
=
np
.
ones
((
border_width
,
border_width
))
for
i
in
range
(
dimension
):
# Setting entire corners equal to corner values in image
out_image
[:
border_width
,:
border_width
,
i
]
=
border_mat
*
image
[
0
,
0
,
i
]
out_image
[
border_width
+
y_height
+
1
:
2
*
border_width
+
y_height
+
1
,:
border_width
,
i
]
=
border_mat
*
image
[
y_height
,
0
,
i
]
out_image
[:
border_width
,
border_width
+
x_height
+
1
:
2
*
border_width
+
x_height
+
1
,
i
]
=
border_mat
*
image
[
0
,
x_height
,
i
]
out_image
[
border_width
+
y_height
+
1
:
2
*
border_width
+
y_height
+
1
,
border_width
+
x_height
+
1
:
2
*
border_width
+
x_height
+
1
,
i
]
=
border_mat
*
image
[
y_height
,
x_height
,
i
]
# Setting the inner values equal to original image
out_image
[
border_width
:
border_width
+
y_height
+
1
,
border_width
:
border_width
+
x_height
+
1
,
i
]
=
image
[:,:,
i
]
# Copying and extending the values of the outer rows and columns of the original image
out_image
[:
border_width
,
border_width
:
border_width
+
x_height
+
1
,
i
]
=
np
.
tile
(
image
[
0
,:,
i
],(
border_width
,
1
))
out_image
[
border_width
+
y_height
+
1
:
2
*
border_width
+
y_height
+
1
,
border_width
:
border_width
+
x_height
+
1
,
i
]
=
np
.
tile
(
image
[
y_height
,:,
i
],(
border_width
,
1
))
out_image
[
border_width
:
border_width
+
y_height
+
1
,:
border_width
,
i
]
=
np
.
transpose
(
np
.
tile
(
image
[:,
0
,
i
],(
border_width
,
1
)))
out_image
[
border_width
:
border_width
+
y_height
+
1
,
border_width
+
x_height
+
1
:
2
*
border_width
+
x_height
+
1
,
i
]
=
np
.
transpose
(
np
.
tile
(
image
[:,
x_height
,
i
],(
border_width
,
1
)))
return
out_image
test_matrix
=
np
.
random
.
normal
(
0
,
1
,(
10
,
10
,
1
))
out_test
=
fill_border
(
test_matrix
,
3
)
print
(
out_test
)
print
(
out_test
[:,
-
1
])
This diff is collapsed.
Click to expand it.
general_cc1.py
0 → 100644
+
26
−
0
View file @
3eebd6ed
import
numpy
as
np
import
argparse
import
cv2
def
max_rgb_filter
(
image
):
# split the image into its BGR components
(
B
,
G
,
R
)
=
cv2
.
split
(
image
)
# find the maximum pixel intensity values for each
# (x, y)-coordinate,, then set all pixel values less
# than M to zero
M
=
np
.
maximum
(
np
.
maximum
(
R
,
G
),
B
)
R
[
R
<
M
]
=
0
G
[
G
<
M
]
=
0
B
[
B
<
M
]
=
0
# merge the channels back together and return the image
return
cv2
.
merge
([
B
,
G
,
R
])
# construct the argument parse and parse the arguments
image
=
cv2
.
imread
(
r
'
C:\Users\ptrkm\Downloads\Billedanalyse\Billedanalyse\Exercises\DTUSign1.jpg
'
,
1
)
filtered
=
max_rgb_filter
(
image
)
cv2
.
imshow
(
'
image1
'
,
filtered
)
cv2
.
waitKey
(
0
)
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