Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "imageproc"
version = "0.26.0"
authors = ["theotherphil"]
rust-version = "1.81.0"
rust-version = "1.85.0"
edition = "2021"
license = "MIT"
description = "Image processing operations"
Expand All @@ -24,12 +24,13 @@ itertools = { version = "0.14.0", default-features = false, features = [
"use_std",
] }
nalgebra = { version = "0.33.0", default-features = false, features = ["std"] }
num = { version = "0.4.1", default-features = false }
rand = { version = "0.8.0", default-features = false, features = [
"std",
"std_rng",
num = { version = "0.4.0", default-features = false }
rand = { version = "0.9.0", default-features = false, features = [

"thread_rng"

] }
rand_distr = { version = "0.4.0", default-features = false }
rand_distr = { version = "0.5.0", default-features = false }
rayon = { version = "1.8.0", optional = true, default-features = false }
sdl2 = { version = "0.38.0", optional = true, default-features = false, features = [
"bundled",
Expand All @@ -38,7 +39,7 @@ katexit = { version = "0.1.4", optional = true, default-features = false }
rustdct = "0.7.1"

[target.'cfg(target_arch = "wasm32")'.dependencies]
getrandom = { version = "0.2.0", default-features = false, features = ["js"] }
getrandom = { version = "0.3.0", default-features = false, features = ["wasm_js"] }

[dev-dependencies]
assert_approx_eq = "1.1.0"
Expand Down
14 changes: 7 additions & 7 deletions src/binary_descriptors/brief.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ pub fn brief(
} else {
// generate a set of test pairs within a 31x31 grid with a Gaussian bias (sigma = 6.6)
let test_pair_distribution = Normal::new(BRIEF_PATCH_RADIUS as f32 + 1.0, 6.6).unwrap();
let mut rng = rand::thread_rng();
let mut rng = rand::rng();
let mut test_pairs: Vec<TestPair> = Vec::with_capacity(length);
while test_pairs.len() < length {
let (x0, y0, x1, y1) = (
Expand Down Expand Up @@ -330,12 +330,12 @@ mod benches {
#[ignore]
fn bench_brief_random_test_pairs_1000_keypoints(b: &mut Bencher) {
let image = gray_bench_image(640, 480);
let mut rng = rand::thread_rng();
let mut rng = rand::rng();
let keypoints = (0..1000)
.map(|_| {
Point::new(
rng.gen_range(24..image.width() - 24),
rng.gen_range(24..image.height() - 24),
rng.random_range(24..image.width() - 24),
rng.random_range(24..image.height() - 24),
)
})
.collect::<Vec<Point<u32>>>();
Expand All @@ -348,12 +348,12 @@ mod benches {
#[ignore]
fn bench_brief_fixed_test_pairs_1000_keypoints(b: &mut Bencher) {
let image = gray_bench_image(640, 480);
let mut rng = rand::thread_rng();
let mut rng = rand::rng();
let keypoints = (0..1000)
.map(|_| {
Point::new(
rng.gen_range(24..image.width() - 24),
rng.gen_range(24..image.height() - 24),
rng.random_range(24..image.width() - 24),
rng.random_range(24..image.height() - 24),
)
})
.collect::<Vec<Point<u32>>>();
Expand Down
10 changes: 5 additions & 5 deletions src/binary_descriptors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub fn match_binary_descriptors<'a, T: BinaryDescriptor>(
let mut rng = if let Some(s) = seed {
StdRng::seed_from_u64(s)
} else {
StdRng::from_entropy()
SeedableRng::from_os_rng()
};

// locality-sensitive hashing (LSH)
Expand All @@ -79,7 +79,7 @@ pub fn match_binary_descriptors<'a, T: BinaryDescriptor>(
for _ in 0..l {
// choose k random bits (not necessarily unique)
let bits = (0..k)
.map(|_| rng.gen_range(0..queries[0].get_size()))
.map(|_| rng.random_range(0..queries[0].get_size()))
.collect::<Vec<u32>>();

let mut new_hashmap = HashMap::<u128, Vec<&T>>::with_capacity(database.len());
Expand Down Expand Up @@ -144,12 +144,12 @@ mod benches {
#[ignore]
fn bench_matcher_1000_keypoints_each(b: &mut Bencher) {
let image = gray_bench_image(640, 480);
let mut rng = rand::thread_rng();
let mut rng = rand::rng();
let keypoints = (0..1000)
.map(|_| {
Point::new(
rng.gen_range(20..image.width() - 20),
rng.gen_range(20..image.height() - 20),
rng.random_range(20..image.width() - 20),
rng.random_range(20..image.height() - 20),
)
})
.collect::<Vec<Point<u32>>>();
Expand Down
9 changes: 4 additions & 5 deletions src/corners.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ use crate::{
point::Point,
};
use image::{GenericImageView, GrayImage};
use rand::{rngs::StdRng, SeedableRng};
use rand_distr::Distribution;
use rand::{distr::Distribution, rngs::StdRng, SeedableRng};

/// A location and score for a detected corner.
/// The scores need not be comparable between different
Expand Down Expand Up @@ -191,10 +190,10 @@ pub fn oriented_fast(
let mut rng = if let Some(s) = seed {
StdRng::seed_from_u64(s)
} else {
StdRng::from_entropy()
SeedableRng::from_os_rng()
};
let dist_x = rand::distributions::Uniform::new(min_x, max_x);
let dist_y = rand::distributions::Uniform::new(min_y, max_y);
let dist_x = rand::distr::Uniform::new(min_x, max_x).unwrap();
let dist_y = rand::distr::Uniform::new(min_y, max_y).unwrap();
let sample_size = NUM_SAMPLE_POINTS.min((width * height) as usize);
let sample_coords: Vec<Point<u32>> = (0..sample_size)
.map(|_| Point::new(dist_x.sample(&mut rng), dist_y.sample(&mut rng)))
Expand Down
2 changes: 1 addition & 1 deletion src/noise.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ where
P: Pixel + HasBlack + HasWhite,
{
let mut rng: StdRng = SeedableRng::seed_from_u64(seed);
let uniform = Uniform::new(0.0, 1.0);
let uniform = Uniform::new(0.0, 1.0).unwrap();

for p in image.pixels_mut() {
if uniform.sample(&mut rng) > rate {
Expand Down
4 changes: 2 additions & 2 deletions src/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ where
for (i, c) in pix.channels().iter().enumerate() {
let (current_min, current_max) = &mut ranges[i];

if current_min.map_or(true, |x| c < x) {
if current_min.is_none_or(|x| c < x) {
*current_min = Some(c);
}
if current_max.map_or(true, |x| c > x) {
if current_max.is_none_or(|x| c > x) {
*current_max = Some(c);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/union_find.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ mod benches {
let num_edges = 20 * num_nodes;

let mut rng: StdRng = SeedableRng::seed_from_u64(1);
let uniform = Uniform::new(0, num_nodes);
let uniform = Uniform::new(0, num_nodes).unwrap();

let mut forest = DisjointSetForest::new(num_nodes);
b.iter(|| {
Expand Down
Loading