Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
uva
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
uva
Commits
1a0c8b6c
Commit
1a0c8b6c
authored
Sep 22, 2011
by
Sander Mathijs van Veen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improc ass2 code cleanup.
parent
799b1ac6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
20 deletions
+19
-20
improc/ass2/interpolation.py
improc/ass2/interpolation.py
+19
-20
No files found.
improc/ass2/interpolation.py
View file @
1a0c8b6c
...
...
@@ -6,33 +6,32 @@ def inImage(image, x, y):
return
x
>=
0
and
y
>=
0
and
x
<
image
.
shape
[
0
]
and
y
<
image
.
shape
[
1
]
def
pV
(
image
,
x
,
y
,
method
):
global
bgcolor
if
inImage
(
image
,
x
,
y
):
if
method
==
'nearest'
:
return
image
[
round
(
x
)][
round
(
y
)]
elif
method
==
'linear'
:
x1
=
floor
(
x
)
x2
=
ceil
(
x
)
y1
=
floor
(
y
)
y2
=
ceil
(
y
)
return
image
[
x1
][
y1
]
*
(
x2
-
x
)
*
(
y2
-
y
)
\
+
image
[
x2
][
y1
]
*
(
x
-
x1
)
*
(
y2
-
y
)
\
+
image
[
x1
][
y2
]
*
(
x2
-
x
)
*
(
y
-
y1
)
\
+
image
[
x2
][
y2
]
*
(
x
-
x1
)
*
(
y
-
y1
)
else
:
print
'Interpolation method "%s" is not supported'
%
method
else
:
if
not
inImage
(
image
,
x
,
y
):
return
bgcolor
if
method
==
'nearest'
:
return
image
[
round
(
x
)][
round
(
y
)]
if
method
==
'linear'
:
x1
=
floor
(
x
)
x2
=
ceil
(
x
)
y1
=
floor
(
y
)
y2
=
ceil
(
y
)
return
image
[
x1
][
y1
]
*
(
x2
-
x
)
*
(
y2
-
y
)
\
+
image
[
x2
][
y1
]
*
(
x
-
x1
)
*
(
y2
-
y
)
\
+
image
[
x1
][
y2
]
*
(
x2
-
x
)
*
(
y
-
y1
)
\
+
image
[
x2
][
y2
]
*
(
x
-
x1
)
*
(
y
-
y1
)
raise
ValueError
,
'Interpolation method "%s" is not supported'
%
method
if
__name__
==
'__main__'
:
from
pylab
import
linspace
,
show
,
imread
,
plot
,
array
"""Profile of an image along line in n points."""
def
profile
(
image
,
x0
,
y0
,
x1
,
y1
,
n
,
method
):
return
array
([
pV
(
image
,
x
,
y
,
method
)
for
x
,
y
in
zip
(
linspace
(
x0
,
\
x1
,
n
),
linspace
(
y0
,
y1
,
n
))
])
dataset
=
zip
(
linspace
(
x0
,
x1
,
n
),
linspace
(
y0
,
y1
,
n
))
return
array
([
pV
(
image
,
x
,
y
,
method
)
for
x
,
y
in
dataset
])
a
=
imread
(
'cameraman.png'
)
for
method
in
[
'nearest'
,
'linear'
]:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment