Skip to content

Commit

Permalink
Add in LumaA 8 bit and 16 bit images (#74)
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
xd009642 authored Jul 20, 2023
1 parent aa4be21 commit 8575691
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
1 change: 0 additions & 1 deletion .github/workflows/lints.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,3 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: clippy
args: -- -D warnings
20 changes: 20 additions & 0 deletions akaze/src/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,26 @@ impl GrayFloatImage {
Luma([f32::from(gray_image[(x, y)][0]) / 65535f32])
})
}
DynamicImage::ImageLumaA8(gray_image) => {
info!(
"Loaded a {} x {} 8-bit image",
input_image.width(),
input_image.height()
);
ImageBuffer::from_fn(gray_image.width(), gray_image.height(), |x, y| {
Luma([f32::from(gray_image[(x, y)][0]) / 255f32])
})
}
DynamicImage::ImageLumaA16(gray_image) => {
info!(
"Loaded a {} x {} 16-bit image",
input_image.width(),
input_image.height()
);
ImageBuffer::from_fn(gray_image.width(), gray_image.height(), |x, y| {
Luma([f32::from(gray_image[(x, y)][0]) / 65535f32])
})
}
DynamicImage::ImageRgb32F(float_image) => {
info!(
"Loaded a {} x {} 32-bit RGB float image",
Expand Down
4 changes: 2 additions & 2 deletions akaze/src/scale_space_extrema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ impl Akaze {
/// # Argument
/// * `evolutions` - evolutions to mutate in place.
/// * `options` - options to use.
fn find_scale_space_extrema(&self, evolutions: &mut [EvolutionStep]) -> Vec<KeyPoint> {
fn find_scale_space_extrema(&self, evolutions: &[EvolutionStep]) -> Vec<KeyPoint> {
let mut keypoint_cache: Vec<KeyPoint> = vec![];
let smax = 10.0f32 * f32::sqrt(2.0f32);
for (e_id, evolution) in evolutions.iter().enumerate() {
Expand Down Expand Up @@ -150,7 +150,7 @@ impl Akaze {
/// * `options` - The options to use.
/// # Return value
/// The resulting keypoints.
pub fn detect_keypoints(&self, evolutions: &mut [EvolutionStep]) -> Vec<KeyPoint> {
pub fn detect_keypoints(&self, evolutions: &[EvolutionStep]) -> Vec<KeyPoint> {
let mut keypoints = self.find_scale_space_extrema(evolutions);
keypoints = do_subpixel_refinement(&keypoints, evolutions);
keypoints
Expand Down

0 comments on commit 8575691

Please sign in to comment.