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
Show 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,12 +6,13 @@ def inImage(image, x, y):
...
@@ -6,12 +6,13 @@ def inImage(image, x, y):
return
x
>=
0
and
y
>=
0
and
x
<
image
.
shape
[
0
]
and
y
<
image
.
shape
[
1
]
return
x
>=
0
and
y
>=
0
and
x
<
image
.
shape
[
0
]
and
y
<
image
.
shape
[
1
]
def
pV
(
image
,
x
,
y
,
method
):
def
pV
(
image
,
x
,
y
,
method
):
global
bgcolor
if
not
inImage
(
image
,
x
,
y
):
return
bgcolor
if
inImage
(
image
,
x
,
y
):
if
method
==
'nearest'
:
if
method
==
'nearest'
:
return
image
[
round
(
x
)][
round
(
y
)]
return
image
[
round
(
x
)][
round
(
y
)]
elif
method
==
'linear'
:
if
method
==
'linear'
:
x1
=
floor
(
x
)
x1
=
floor
(
x
)
x2
=
ceil
(
x
)
x2
=
ceil
(
x
)
y1
=
floor
(
y
)
y1
=
floor
(
y
)
...
@@ -21,18 +22,16 @@ def pV(image, x, y, method):
...
@@ -21,18 +22,16 @@ def pV(image, x, y, method):
+
image
[
x2
][
y1
]
*
(
x
-
x1
)
*
(
y2
-
y
)
\
+
image
[
x2
][
y1
]
*
(
x
-
x1
)
*
(
y2
-
y
)
\
+
image
[
x1
][
y2
]
*
(
x2
-
x
)
*
(
y
-
y1
)
\
+
image
[
x1
][
y2
]
*
(
x2
-
x
)
*
(
y
-
y1
)
\
+
image
[
x2
][
y2
]
*
(
x
-
x1
)
*
(
y
-
y1
)
+
image
[
x2
][
y2
]
*
(
x
-
x1
)
*
(
y
-
y1
)
else
:
print
'Interpolation method "%s" is not supported'
%
method
raise
ValueError
,
'Interpolation method "%s" is not supported'
%
method
else
:
return
bgcolor
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
from
pylab
import
linspace
,
show
,
imread
,
plot
,
array
from
pylab
import
linspace
,
show
,
imread
,
plot
,
array
"""Profile of an image along line in n points."""
"""Profile of an image along line in n points."""
def
profile
(
image
,
x0
,
y0
,
x1
,
y1
,
n
,
method
):
def
profile
(
image
,
x0
,
y0
,
x1
,
y1
,
n
,
method
):
return
array
([
pV
(
image
,
x
,
y
,
method
)
for
x
,
y
in
zip
(
linspace
(
x0
,
\
dataset
=
zip
(
linspace
(
x0
,
x1
,
n
),
linspace
(
y0
,
y1
,
n
))
x1
,
n
),
linspace
(
y0
,
y1
,
n
))
])
return
array
([
pV
(
image
,
x
,
y
,
method
)
for
x
,
y
in
dataset
])
a
=
imread
(
'cameraman.png'
)
a
=
imread
(
'cameraman.png'
)
for
method
in
[
'nearest'
,
'linear'
]:
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