Skip to content

Commit a481754

Browse files
committed
Merge branch 'develop'
2 parents 79aba53 + b6377a0 commit a481754

File tree

26 files changed

+1832
-317
lines changed

26 files changed

+1832
-317
lines changed

.github/FUNDING.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# These are supported funding model platforms
2+
3+
github: xd009642
4+
patreon: xd009642
5+
open_collective: # Replace with a single Open Collective username
6+
ko_fi: # Replace with a single Ko-fi username
7+
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9+
liberapay: # Replace with a single Liberapay username
10+
issuehunt: # Replace with a single IssueHunt username
11+
otechie: # Replace with a single Otechie username
12+
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

.travis.yml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ addons:
55
apt:
66
packages:
77
- libssl-dev
8+
- gfortran
89
cache: cargo
910
rust:
1011
- stable
@@ -14,18 +15,21 @@ matrix:
1415
allow_failures:
1516
- rust: nightly
1617

17-
before_cache: |
18-
if [[ "$TRAVIS_RUST_VERSION" == nightly ]]; then
19-
RUSTFLAGS="--cfg procmacro2_semver_exempt" cargo install cargo-tarpaulin
20-
fi
18+
before_install:
19+
- curl https://blas-lapack-rs.github.io/travis/fortran.sh | bash
20+
21+
#before_cache: |
22+
# if [[ "$TRAVIS_RUST_VERSION" == nightly ]]; then
23+
# cargo install cargo-tarpaulin
24+
# fi
2125

2226
script:
2327
- cargo clean
2428
- cargo build
2529
- cargo test
2630

27-
after_success: |
28-
if [[ "$TRAVIS_RUST_VERSION" == nightly ]]; then
31+
# after_success: |
32+
# if [[ "$TRAVIS_RUST_VERSION" == nightly ]]; then
2933
# Uncomment the following line for coveralls.io
30-
cargo tarpaulin --ciserver travis-ci --coveralls $TRAVIS_JOB_ID
31-
fi
34+
# cargo tarpaulin --ciserver travis-ci --coveralls $TRAVIS_JOB_ID
35+
# fi

CHANGELOG.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Change Log
2+
3+
## [Unreleased]
4+
### Added
5+
6+
### Changed
7+
8+
### Removed
9+
10+
## [0.2.0] 2020-06-06
11+
### Added
12+
* Padding strategies (`NoPadding`, `ConstantPadding`, `ZeroPadding`)
13+
* Threshold module with Otsu and Mean threshold algorithms
14+
* Image transformations and functions to create affine transform matrices
15+
* Type alias `Image` for `ImageBase<OwnedRepr<T>, _>` replicated old `Image` type
16+
* Type alias `ImageView` for `ImageBase<ViewRepr<&'a T>, _>`
17+
* Morphology module with dilation, erosion, union and intersection of binary images
18+
19+
### Changed
20+
* Integrated Padding strategies into convolutions
21+
* Updated `ndarray-stats` to 0.2.0 adding `noisy_float` for median change
22+
* [INTERNAL] Disabled code coverage due to issues with tarpaulin and native libraries
23+
* Renamed `Image` to `ImageBase` which can take any implementor of the ndaray `Data` trait
24+
* Made images have `NoPadding` by default
25+
* No pad behaviour now keeps pixels near the edges the same as source value instead of making them black
26+
* Various performance enhancements in convolution and canny functions
27+
28+
### Removed
29+
30+
## [0.1.1] - 2019-07-31
31+
### Added
32+
33+
### Changed
34+
* Applied zero padding by default in convolutions
35+
36+
### Removed
37+
38+
## [0.1.0] - 2019-03-24
39+
### Added
40+
* Image type
41+
* Colour Models (RGB, Gray, HSV, CIEXYZ, Channel-less)
42+
* Histogram equalisation
43+
* Image convolutions
44+
* `PixelBound` type to aid in rescaling images
45+
* Canny edge detector
46+
* `KernelBuilder` and `FixedDimensionKernelBuilder` to create kernels
47+
* Builder implementations for Sobel, Gaussian, Box Linear filter, Laplace
48+
* Median filter
49+
* Sobel Operator
50+
* PPM encoding and decoding for images

Cargo.toml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
11
[package]
22
name = "ndarray-vision"
3-
version = "0.1.1"
3+
version = "0.2.0"
44
authors = ["xd009642 <danielmckenna93@gmail.com>"]
55
description = "A computer vision library built on top of ndarray"
66
repository = "https://github.com/xd009642/ndarray-vision"
77
readme = "README.md"
88
license = "MIT/Apache-2.0"
99
keywords = ["image", "vision", "image-processing"]
10-
categories = ["Science", "Multimedia"]
10+
categories = ["science", "science::robotics", "multimedia", "multimedia::images", "graphics"]
1111
edition = "2018"
1212

1313
[dependencies]
14-
ndarray = "0.12"
15-
ndarray-stats = "0.1"
16-
num-traits = "0.2"
14+
ndarray = { version = "0.13", default-features = false }
15+
ndarray-stats = { version = "0.3", default-features = false }
16+
ndarray-linalg = { version = "0.12", default-features = false }
17+
noisy_float = { version = "0.1", default-features = false }
18+
num-traits = { version = "0.2", default-features = false }
1719

1820
[dev-dependencies]
19-
ndarray-rand = "0.9.0"
20-
rand = "0.6.5"
21+
ndarray-rand = "0.11.0"
22+
rand = "0.7"
23+
assert_approx_eq = "1.1.0"
24+
noisy_float = "0.1.11"
25+
png = "0.16"
26+
ndarray-linalg = { version = "0.12", features = ["intel-mkl"] }

examples/transforms.rs

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
use ndarray_vision::core::*;
2+
use ndarray_vision::format::netpbm::*;
3+
use ndarray_vision::format::*;
4+
use ndarray_vision::transform::affine::*;
5+
use ndarray_vision::transform::*;
6+
use std::env::current_exe;
7+
use std::f64::consts::FRAC_PI_4;
8+
use std::fs::File;
9+
use std::io::BufWriter;
10+
use std::path::{Path, PathBuf};
11+
12+
fn get_lena() -> Option<Image<u8, RGB>> {
13+
if let Ok(mut root) = current_exe() {
14+
root.pop();
15+
root.pop();
16+
root.pop();
17+
root.pop();
18+
let mut lena = PathBuf::from(&root);
19+
lena.push("images/lena.ppm");
20+
21+
let decoder = PpmDecoder::default();
22+
let image: Image<u8, _> = decoder.decode_file(lena).expect("Couldn't open Lena.ppm");
23+
Some(image)
24+
} else {
25+
None
26+
}
27+
}
28+
29+
fn main() {
30+
let lena = get_lena().expect("Couldn't load lena");
31+
32+
// Create transformation matrix
33+
let x = 0.5 * (lena.cols() as f64) - 0.5;
34+
let y = 0.5 * (lena.rows() as f64) - 0.5;
35+
let trans = rotate_around_centre(FRAC_PI_4, (x, y)).dot(&scale(0.7, 0.7));
36+
37+
let transformed = lena
38+
.transform(trans.view(), None)
39+
.expect("Transform failed");
40+
41+
// save
42+
let path = Path::new("transformed_lena.png");
43+
let file = File::create(path).expect("Couldn't create output file");
44+
let ref mut w = BufWriter::new(file);
45+
46+
let mut encoder = png::Encoder::new(w, transformed.cols() as u32, transformed.rows() as u32);
47+
encoder.set_color(png::ColorType::RGB);
48+
encoder.set_depth(png::BitDepth::Eight);
49+
50+
println!(
51+
"Writing image with resolution {}x{}",
52+
transformed.cols(),
53+
transformed.rows()
54+
);
55+
56+
let mut writer = encoder.write_header().expect("Failed to write file header");
57+
if let Some(data) = transformed.data.view().to_slice() {
58+
writer
59+
.write_image_data(data)
60+
.expect("Failed to write image data");
61+
} else {
62+
println!("Failed to get image slice");
63+
}
64+
}

0 commit comments

Comments
 (0)