Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
ExoVisnum2022-2023
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
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
ivan.rigo
ExoVisnum2022-2023
Commits
36bc8d0f
Commit
36bc8d0f
authored
1 year ago
by
ivan.rigo
Browse files
Options
Downloads
Patches
Plain Diff
Ex1 S3 found his daddy
parent
2992e103
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Serie3/Ex1.py
+7
-9
7 additions, 9 deletions
Serie3/Ex1.py
with
7 additions
and
9 deletions
Serie3/Ex1.py
+
7
−
9
View file @
36bc8d0f
...
...
@@ -23,9 +23,8 @@ def show_img(img: Img) -> None:
def
xcorr
(
img
:
Img
,
kernel
:
Img
)
->
Img
:
kLen
=
int
(
kernel
.
shape
[
0
]
/
2
)
yMax
=
img
.
shape
[
0
]
xMax
=
img
.
shape
[
1
]
print
(
yMax
)
xMax
=
img
.
shape
[
0
]
yMax
=
img
.
shape
[
1
]
xcorrRes
=
np
.
zeros
((
img
.
shape
[
0
],
img
.
shape
[
1
]))
iteNp
=
np
.
nditer
(
img
,
flags
=
[
"
multi_index
"
])
while
not
iteNp
.
finished
:
...
...
@@ -41,19 +40,18 @@ def xcorr(img: Img, kernel: Img) -> Img:
for
xK
in
range
(
kernel
.
shape
[
0
]):
for
yK
in
range
(
kernel
.
shape
[
1
]):
if
xCorner
+
xK
>=
xMax
or
xCorner
+
xK
<
0
or
yCorner
+
yK
<
0
or
yCorner
+
yK
>=
yMax
:
regToApply
[
xK
,
yK
]
=
12
0
regToApply
[
xK
,
yK
]
=
12
3
else
:
print
(
str
(
xCorner
+
xK
)
+
"
|
"
+
str
(
yCorner
+
yK
))
regToApply
[
xK
,
yK
]
=
img
[
xCorner
+
xK
,
yCorner
+
yK
]
xcorrRes
[
x
,
y
]
=
np
.
sum
(
np
.
multiply
(
regToApply
,
kernel
))
iteNp
.
iternext
()
return
xcorrRes
#
fog, axe = plt.subplots(2)
fog
,
axe
=
plt
.
subplots
(
2
)
imgToModify
=
load_img
(
"
lena.png
"
)
#
axe[0].imshow(imgToModify,cmap="gray",vmin=0,vmax=256)
axe
[
0
].
imshow
(
imgToModify
,
cmap
=
"
gray
"
,
vmin
=
0
,
vmax
=
256
)
kern
=
np
.
zeros
((
3
,
3
),
dtype
=
np
.
uint8
)
kern
[
0
,
1
]
=
1
imgRes
=
xcorr
(
imgToModify
,
kern
)
#
axe[1].imshow(imgRes,cmap="gray",vmin=0,vmax=256)
#
plt.show()
axe
[
1
].
imshow
(
imgRes
,
cmap
=
"
gray
"
,
vmin
=
0
,
vmax
=
256
)
plt
.
show
()
#show_img(imgRes)
\ 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