-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
45 additions
and
143 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,8 +1,7 @@ | ||
C code to be compiled on setup goes here. | ||
C++ code to generate fast_median extension goes here. | ||
|
||
fast_median.cpp is a very fast median filter for 1d and 2d ndarrays | ||
with float or double data. The glue code is in fast_median.py | ||
|
||
compile using the Makefile in src/ | ||
fast_median.cpp, fast_median.hpp: a very fast median filter for 1d and 2d ndarrays | ||
with float or double data. | ||
python/lvmdrp/external/fast_median.py: python interface for fast_median extension | ||
|
||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,40 @@ | ||
import numpy as np | ||
from lvmdrp.external.fast_median import fast_median_filter_2d, fast_median_filter_1d | ||
from scipy.ndimage import median_filter | ||
import time | ||
import pytest | ||
|
||
|
||
def test_median_filter_1d_speed(): | ||
np.random.seed(123) | ||
img = np.random.random(size=100)*3 + 1000 | ||
img = img.astype(np.float32) | ||
|
||
t = time.time() | ||
img_fm = fast_median_filter_1d(img, size=5) | ||
dt_fm = time.time()-t | ||
|
||
t = time.time() | ||
img_om = median_filter(img, size=5) | ||
dt_om = time.time()-t | ||
|
||
assert dt_om > dt_fm | ||
assert img_om == pytest.approx(img_fm, rel=0.01) | ||
|
||
|
||
def test_median_filter_2d_speed(): | ||
np.random.seed(456) | ||
img = np.random.random(size=[100,100])*3 + 1000 | ||
img = img.astype(np.float32) | ||
|
||
t = time.time() | ||
img_fm = fast_median_filter_2d(img, size=(5,5)) | ||
dt_fm = time.time()-t | ||
|
||
t = time.time() | ||
img_om = median_filter(img, size=(5,5)) | ||
dt_om = time.time()-t | ||
|
||
assert dt_om > dt_fm | ||
assert img_om == pytest.approx(img_fm, rel=0.01) | ||
|