Skip to content
This repository has been archived by the owner on Jul 30, 2024. It is now read-only.

Commit

Permalink
remove last reference to lena in examples and scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
rjw57 committed Aug 3, 2015
1 parent 68ac377 commit d33e325
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 44 deletions.
44 changes: 22 additions & 22 deletions examples/resampling_highpass_coefficients.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@
import numpy as np
from matplotlib.pyplot import *

# Get a copy of the famous 'lena' image. In the default dtcwt tree, we ship
# one with the tests. The lena image is 512x512, floating point and has pixel
# Get a copy of the famous 'mandrill' image. In the default dtcwt tree, we ship
# one with the tests. The mandrill image is 512x512, floating point and has pixel
# values on the interval (0, 1].
lena = np.load(
os.path.join(os.path.dirname(__file__), '..', 'tests', 'lena.npz')
)['lena']
mandrill = np.load(
os.path.join(os.path.dirname(__file__), '..', 'tests', 'mandrill.npz')
)['mandrill']

# Chop a window out
lena = lena[224:288,224:288]
mandrill = mandrill[224:288,224:288]

# We will try to re-scale lena by this amount and method
# We will try to re-scale mandrill by this amount and method
scale = 1.2
scale_method = 'lanczos'

Expand All @@ -38,44 +38,44 @@ def scale_highpass(im):
"""Scale image assuming it to be wavelet highpass coefficients."""
return dtcwt.sampling.scale_highpass(im, (im.shape[0]*scale, im.shape[1]*scale), scale_method)

# Rescale lena directly using default (Lanczos) sampling
lena_direct = scale_direct(lena)
# Rescale mandrill directly using default (Lanczos) sampling
mandrill_direct = scale_direct(mandrill)

# Transform lena
lena_l, lena_h = dtcwt.compat.dtwavexfm2(lena, nlevels=4)
# Transform mandrill
mandrill_l, mandrill_h = dtcwt.compat.dtwavexfm2(mandrill, nlevels=4)

# Re-scale each component and transform back. Do this both with and without
# shifting back to DC.
lena_l = scale_direct(lena_l)
lena_h_a, lena_h_b = [], []
mandrill_l = scale_direct(mandrill_l)
mandrill_h_a, mandrill_h_b = [], []

for h in lena_h:
lena_h_a.append(scale_direct(h))
lena_h_b.append(scale_highpass(h))
for h in mandrill_h:
mandrill_h_a.append(scale_direct(h))
mandrill_h_b.append(scale_highpass(h))

# Transform back
lena_a = dtcwt.compat.dtwaveifm2(lena_l, lena_h_a)
lena_b = dtcwt.compat.dtwaveifm2(lena_l, lena_h_b)
mandrill_a = dtcwt.compat.dtwaveifm2(mandrill_l, mandrill_h_a)
mandrill_b = dtcwt.compat.dtwaveifm2(mandrill_l, mandrill_h_b)

figure(figsize=(10,10))

subplot(2,2,1)
imshow(lena, cmap=cm.gray, clim=(0,1), interpolation='none')
imshow(mandrill, cmap=cm.gray, clim=(0,1), interpolation='none')
axis('off')
title('Original')

subplot(2,2,2)
imshow(lena_direct, cmap=cm.gray, clim=(0,1), interpolation='none')
imshow(mandrill_direct, cmap=cm.gray, clim=(0,1), interpolation='none')
axis('off')
title('Directly up-sampled')

subplot(2,2,3)
imshow(lena_a, cmap=cm.gray, clim=(0,1), interpolation='none')
imshow(mandrill_a, cmap=cm.gray, clim=(0,1), interpolation='none')
axis('off')
title('Up-sampled in the wavelet domain')

subplot(2,2,4)
imshow(lena_b, cmap=cm.gray, clim=(0,1), interpolation='none')
imshow(mandrill_b, cmap=cm.gray, clim=(0,1), interpolation='none')
axis('off')
title('Up-sampled in the wavelet domain with shifting')

Expand Down
44 changes: 22 additions & 22 deletions scripts/benchmark_opencl.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from dtcwt.coeffs import biort, qshift
from dtcwt.opencl.lowlevel import NoCLPresentError, get_default_queue

lena = np.load(os.path.join(os.path.dirname(__file__), '..', 'tests', 'lena.npz'))['lena']
mandrill = np.load(os.path.join(os.path.dirname(__file__), '..', 'tests', 'mandrill.npz'))['mandrill']
h0o, g0o, h1o, g1o = biort('near_sym_b')
h0a, h0b, g0a, g0b, h1a, h1b, g1a, g1b = qshift('qshift_d')

Expand All @@ -32,7 +32,7 @@ def format_time(t):
def benchmark(statement='pass', setup='pass'):
number, repeat = (1, 3)
min_time = 0

try:
while min_time < 0.2:
number *= 10
Expand All @@ -55,47 +55,47 @@ def main():
print('Skipping OpenCL benchmark since OpenCL is not present')

print('Running NumPy colfilter...')
a = benchmark('colfilter(lena, h1o)',
'from dtcwt.numpy.lowlevel import colfilter; from __main__ import lena, h1o')
a = benchmark('colfilter(mandrill, h1o)',
'from dtcwt.numpy.lowlevel import colfilter; from __main__ import mandrill, h1o')
print('Running OpenCL colfilter...')
b = benchmark('colfilter(lena, h1o)',
'from dtcwt.opencl.lowlevel import colfilter; from __main__ import lena, h1o')
b = benchmark('colfilter(mandrill, h1o)',
'from dtcwt.opencl.lowlevel import colfilter; from __main__ import mandrill, h1o')
print('Speed up: x{0:.2f}'.format(a/b))
print('=====')

print('Running NumPy coldfilt...')
a = benchmark('coldfilt(lena, h0b, h0a)',
'from dtcwt.numpy.lowlevel import coldfilt; from __main__ import lena, h0b, h0a')
a = benchmark('coldfilt(mandrill, h0b, h0a)',
'from dtcwt.numpy.lowlevel import coldfilt; from __main__ import mandrill, h0b, h0a')
print('Running OpenCL coldfilt...')
b = benchmark('coldfilt(lena, h0b, h0a)',
'from dtcwt.opencl.lowlevel import coldfilt; from __main__ import lena, h0b, h0a')
b = benchmark('coldfilt(mandrill, h0b, h0a)',
'from dtcwt.opencl.lowlevel import coldfilt; from __main__ import mandrill, h0b, h0a')
print('Speed up: x{0:.2f}'.format(a/b))
print('=====')

print('Running NumPy colifilt...')
a = benchmark('colifilt(lena, h0b, h0a)',
'from dtcwt.numpy.lowlevel import colifilt; from __main__ import lena, h0b, h0a')
a = benchmark('colifilt(mandrill, h0b, h0a)',
'from dtcwt.numpy.lowlevel import colifilt; from __main__ import mandrill, h0b, h0a')
print('Running OpenCL colifilt...')
b = benchmark('colifilt(lena, h0b, h0a)',
'from dtcwt.opencl.lowlevel import colifilt; from __main__ import lena, h0b, h0a')
b = benchmark('colifilt(mandrill, h0b, h0a)',
'from dtcwt.opencl.lowlevel import colifilt; from __main__ import mandrill, h0b, h0a')
print('Speed up: x{0:.2f}'.format(a/b))
print('=====')

print('Running NumPy dtwavexfm2...')
a = benchmark('dtwavexfm2(lena)',
'from dtcwt.compat import dtwavexfm2; from __main__ import lena')
a = benchmark('dtwavexfm2(mandrill)',
'from dtcwt.compat import dtwavexfm2; from __main__ import mandrill')
print('Running OpenCL dtwavexfm2...')
b = benchmark('dtwavexfm2(lena)',
'from dtcwt.opencl.transform2d import dtwavexfm2; from __main__ import lena')
b = benchmark('dtwavexfm2(mandrill)',
'from dtcwt.opencl.transform2d import dtwavexfm2; from __main__ import mandrill')
print('Speed up: x{0:.2f}'.format(a/b))
print('=====')

print('Running NumPy dtwavexfm2 (non-POT)...')
a = benchmark('dtwavexfm2(lena[:510,:480])',
'from dtcwt.compat import dtwavexfm2; from __main__ import lena')
a = benchmark('dtwavexfm2(mandrill[:510,:480])',
'from dtcwt.compat import dtwavexfm2; from __main__ import mandrill')
print('Running OpenCL dtwavexfm2 (non-POT)...')
b = benchmark('dtwavexfm2(lena[:510,:480])',
'from dtcwt.opencl.transform2d import dtwavexfm2; from __main__ import lena')
b = benchmark('dtwavexfm2(mandrill[:510,:480])',
'from dtcwt.opencl.transform2d import dtwavexfm2; from __main__ import mandrill')
print('Speed up: x{0:.2f}'.format(a/b))
print('=====')

Expand Down

0 comments on commit d33e325

Please sign in to comment.