-
-
Notifications
You must be signed in to change notification settings - Fork 454
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #144 from aaren/import-images
Add importable images
- Loading branch information
Showing
17 changed files
with
228 additions
and
18 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from ._readers import ascent, aero, ecg, camera |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
import os | ||
|
||
import numpy as np | ||
|
||
|
||
def ascent(): | ||
""" | ||
Get an 8-bit grayscale bit-depth, 512 x 512 derived image for | ||
easy use in demos | ||
The image is derived from accent-to-the-top.jpg at | ||
http://www.public-domain-image.com/people-public-domain-images-pictures/ | ||
Parameters | ||
---------- | ||
None | ||
Returns | ||
------- | ||
ascent : ndarray | ||
convenient image to use for testing and demonstration | ||
Examples | ||
-------- | ||
>>> import pywt.data | ||
>>> ascent = pywt.data.ascent() | ||
>>> ascent.shape | ||
(512, 512) | ||
>>> ascent.max() | ||
255 | ||
>>> import matplotlib.pyplot as plt | ||
>>> plt.gray() | ||
>>> plt.imshow(ascent) | ||
>>> plt.show() | ||
""" | ||
fname = os.path.join(os.path.dirname(__file__), 'ascent.npz') | ||
ascent = np.load(fname)['data'] | ||
return ascent | ||
|
||
|
||
def aero(): | ||
""" | ||
Get an 8-bit grayscale bit-depth, 512 x 512 derived image for | ||
easy use in demos | ||
Parameters | ||
---------- | ||
None | ||
Returns | ||
------- | ||
aero : ndarray | ||
convenient image to use for testing and demonstration | ||
Examples | ||
-------- | ||
>>> import pywt.data | ||
>>> aero = pywt.data.ascent() | ||
>>> aero.shape | ||
(512, 512) | ||
>>> aero.max() | ||
255 | ||
>>> import matplotlib.pyplot as plt | ||
>>> plt.gray() | ||
>>> plt.imshow(aero) | ||
>>> plt.show() | ||
""" | ||
fname = os.path.join(os.path.dirname(__file__), 'aero.npz') | ||
aero = np.load(fname)['data'] | ||
return aero | ||
|
||
|
||
def camera(): | ||
""" | ||
Get an 8-bit grayscale bit-depth, 512 x 512 derived image for | ||
easy use in demos | ||
Parameters | ||
---------- | ||
None | ||
Returns | ||
------- | ||
camera : ndarray | ||
convenient image to use for testing and demonstration | ||
Examples | ||
-------- | ||
>>> import pywt.data | ||
>>> camera = pywt.data.ascent() | ||
>>> camera.shape | ||
(512, 512) | ||
>>> import matplotlib.pyplot as plt | ||
>>> plt.gray() | ||
>>> plt.imshow(camera) | ||
>>> plt.show() | ||
""" | ||
fname = os.path.join(os.path.dirname(__file__), 'camera.npz') | ||
camera = np.load(fname)['data'] | ||
return camera | ||
|
||
|
||
def ecg(): | ||
""" | ||
Get 1024 points of an ECG timeseries. | ||
Parameters | ||
---------- | ||
None | ||
Returns | ||
------- | ||
ecg : ndarray | ||
convenient timeseries to use for testing and demonstration | ||
Examples | ||
-------- | ||
>>> import pywt.data | ||
>>> ecg = pywt.data.ecg() | ||
>>> ecg.shape | ||
(1024,) | ||
>>> import matplotlib.pyplot as plt | ||
>>> plt.plot(ecg) | ||
>>> plt.show() | ||
""" | ||
fname = os.path.join(os.path.dirname(__file__), 'ecg.npy') | ||
ecg = np.load(fname) | ||
return ecg |
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/env python | ||
|
||
"""Helper script for creating image .dat files by numpy.save | ||
Usage: | ||
python create_dat.py <name of image file> <name of dat file> | ||
Example (to create aero.dat): | ||
python create_dat.py aero.png aero.dat | ||
Requires Scipy and PIL. | ||
""" | ||
|
||
from __future__ import print_function | ||
|
||
import sys | ||
|
||
import numpy as np | ||
from scipy.misc import imread | ||
|
||
if len(sys.argv) != 3: | ||
print(__doc__) | ||
exit() | ||
|
||
image_fname = sys.argv[1] | ||
dat_fname = sys.argv[2] | ||
|
||
data = imread(image_fname) | ||
|
||
np.savez_compressed(dat_fname, data=data) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import numpy as np | ||
from numpy.testing import assert_allclose | ||
|
||
import pywt.data | ||
|
||
|
||
def test_data_aero(): | ||
aero = pywt.data.aero() | ||
|
||
ref = np.array([[178, 178, 179], | ||
[170, 173, 171], | ||
[185, 174, 171]]) | ||
|
||
assert_allclose(aero[:3, :3], ref) | ||
|
||
|
||
def test_data_ascent(): | ||
ascent = pywt.data.ascent() | ||
|
||
ref = np.array([[83, 83, 83], | ||
[82, 82, 83], | ||
[80, 81, 83]]) | ||
|
||
assert_allclose(ascent[:3, :3], ref) | ||
|
||
|
||
def test_data_camera(): | ||
ascent = pywt.data.camera() | ||
|
||
ref = np.array([[156, 157, 160], | ||
[156, 157, 159], | ||
[158, 157, 156]]) | ||
|
||
assert_allclose(ascent[:3, :3], ref) | ||
|
||
|
||
def test_data_ecg(): | ||
ecg = pywt.data.ecg() | ||
|
||
ref = np.array([-86, -87, -87]) | ||
|
||
assert_allclose(ecg[:3], ref) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters