Skip to content

Commit 37c5091

Browse files
committed
FEATURE: one dimensional median filter for images
1 parent 95458f7 commit 37c5091

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/image/mod.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ extern {
6565
fn af_medfilt(out: MutAfArray, input: AfArray,
6666
wlen: DimT, wwid: DimT, etype: uint8_t) -> c_int;
6767

68+
fn af_medfilt1(out: MutAfArray, input: AfArray, wlen: DimT, etype: uint8_t) -> c_int;
69+
6870
fn af_minfilt(out: MutAfArray, input: AfArray,
6971
wlen: DimT, wwid: DimT, etype: uint8_t) -> c_int;
7072

@@ -1183,3 +1185,24 @@ pub fn moments_all(input: &Array, moment: MomentType) -> f64 {
11831185
temp
11841186
}
11851187
}
1188+
1189+
/// One dimensional median filter on image
1190+
///
1191+
/// # Parameters
1192+
///
1193+
/// - `input` is the input image(Array)
1194+
/// - `wlen` is the horizontal length of the filter
1195+
/// - `etype` is enum of type [BorderType](./enum.BorderType.html)
1196+
///
1197+
/// # Return Values
1198+
///
1199+
/// An Array with filtered image data.
1200+
pub fn medfilt1(input: &Array, wlen: u64, etype: BorderType) -> Array {
1201+
unsafe {
1202+
let mut temp: i64 = 0;
1203+
let err_val = af_medfilt1(&mut temp as MutAfArray, input.get() as AfArray,
1204+
wlen as DimT, etype as uint8_t);
1205+
HANDLE_ERROR(AfError::from(err_val));
1206+
Array::from(temp)
1207+
}
1208+
}

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ pub use image::{resize, transform, rotate, translate, scale, skew};
7272
pub use image::{dilate, dilate3, erode, erode3, minfilt, maxfilt};
7373
pub use image::{gradient, histogram, hist_equal, regions};
7474
pub use image::{gray2rgb, rgb2gray, hsv2rgb, rgb2hsv, color_space};
75-
pub use image::{bilateral, mean_shift, medfilt, sobel};
75+
pub use image::{bilateral, mean_shift, medfilt, sobel, medfilt1};
7676
pub use image::{unwrap, wrap, sat, rgb2ycbcr, ycbcr2rgb, is_imageio_available, transform_coords};
7777
pub use image::{moments, moments_all};
7878
mod image;

0 commit comments

Comments
 (0)