Skip to content

Commit 8575691

Browse files
authored
Add in LumaA 8 bit and 16 bit images (#74)
LumaA or images that would turn into LumaA when `.grayscale()` is called were panicking with unsupported image type. This PR adds in the conversion for these types to Luma via the image crates automatic pixel conversion (likely removing the alpha channel).
1 parent aa4be21 commit 8575691

3 files changed

Lines changed: 22 additions & 3 deletions

File tree

.github/workflows/lints.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,3 @@ jobs:
5454
uses: actions-rs/cargo@v1
5555
with:
5656
command: clippy
57-
args: -- -D warnings

akaze/src/image.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,26 @@ impl GrayFloatImage {
6464
Luma([f32::from(gray_image[(x, y)][0]) / 65535f32])
6565
})
6666
}
67+
DynamicImage::ImageLumaA8(gray_image) => {
68+
info!(
69+
"Loaded a {} x {} 8-bit image",
70+
input_image.width(),
71+
input_image.height()
72+
);
73+
ImageBuffer::from_fn(gray_image.width(), gray_image.height(), |x, y| {
74+
Luma([f32::from(gray_image[(x, y)][0]) / 255f32])
75+
})
76+
}
77+
DynamicImage::ImageLumaA16(gray_image) => {
78+
info!(
79+
"Loaded a {} x {} 16-bit image",
80+
input_image.width(),
81+
input_image.height()
82+
);
83+
ImageBuffer::from_fn(gray_image.width(), gray_image.height(), |x, y| {
84+
Luma([f32::from(gray_image[(x, y)][0]) / 65535f32])
85+
})
86+
}
6787
DynamicImage::ImageRgb32F(float_image) => {
6888
info!(
6989
"Loaded a {} x {} 32-bit RGB float image",

akaze/src/scale_space_extrema.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ impl Akaze {
1111
/// # Argument
1212
/// * `evolutions` - evolutions to mutate in place.
1313
/// * `options` - options to use.
14-
fn find_scale_space_extrema(&self, evolutions: &mut [EvolutionStep]) -> Vec<KeyPoint> {
14+
fn find_scale_space_extrema(&self, evolutions: &[EvolutionStep]) -> Vec<KeyPoint> {
1515
let mut keypoint_cache: Vec<KeyPoint> = vec![];
1616
let smax = 10.0f32 * f32::sqrt(2.0f32);
1717
for (e_id, evolution) in evolutions.iter().enumerate() {
@@ -150,7 +150,7 @@ impl Akaze {
150150
/// * `options` - The options to use.
151151
/// # Return value
152152
/// The resulting keypoints.
153-
pub fn detect_keypoints(&self, evolutions: &mut [EvolutionStep]) -> Vec<KeyPoint> {
153+
pub fn detect_keypoints(&self, evolutions: &[EvolutionStep]) -> Vec<KeyPoint> {
154154
let mut keypoints = self.find_scale_space_extrema(evolutions);
155155
keypoints = do_subpixel_refinement(&keypoints, evolutions);
156156
keypoints

0 commit comments

Comments
 (0)