Skip to content

Commit 8c1ddf2

Browse files
committed
chore: pre-publish checks
1 parent 8eca20a commit 8c1ddf2

5 files changed

Lines changed: 44 additions & 8 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ description = "Demosaicing algorithms for Bayer and X-Trans CFA sensors"
88
repository = "https://github.com/naorunaoru/demosaic"
99
keywords = ["demosaic", "bayer", "xtrans", "raw", "image-processing"]
1010
categories = ["multimedia::images"]
11+
exclude = [".github/", ".gitignore", "Cargo.lock"]
1112

1213
[features]
1314
default = ["std"]

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# demosaic
22

3+
[![crates.io](https://img.shields.io/crates/v/demosaic.svg)](https://crates.io/crates/demosaic)
4+
[![docs.rs](https://docs.rs/demosaic/badge.svg)](https://docs.rs/demosaic)
5+
[![CI](https://github.com/naorunaoru/demosaic/actions/workflows/ci.yml/badge.svg)](https://github.com/naorunaoru/demosaic/actions/workflows/ci.yml)
6+
37
Demosaicing algorithms for Bayer and X-Trans CFA sensors. Pure Rust, `no_std` compatible. *Not* blazingly fast, just moderately. Use at your own pace.
48

59
## Algorithms

src/cfa.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
use core::fmt;
22

3+
/// Color channel in a CFA pattern.
34
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
45
pub enum Channel {
6+
/// Red channel.
57
Red = 0,
8+
/// Green channel.
69
Green = 1,
10+
/// Blue channel.
711
Blue = 2,
812
}
913

@@ -94,23 +98,28 @@ impl CfaPattern {
9498
Self { pattern: shifted, width: self.width, height: self.height }
9599
}
96100

101+
/// Return the color channel at the given row and column (wraps modulo pattern size).
97102
#[inline]
98103
pub fn color_at(&self, row: usize, col: usize) -> Channel {
99104
self.pattern[(row % self.height) * self.width + (col % self.width)]
100105
}
101106

107+
/// Pattern width: 2 for Bayer, 6 for X-Trans.
102108
pub fn width(&self) -> usize {
103109
self.width
104110
}
105111

112+
/// Pattern height: 2 for Bayer, 6 for X-Trans.
106113
pub fn height(&self) -> usize {
107114
self.height
108115
}
109116

117+
/// Returns `true` if this is a 2x2 Bayer pattern.
110118
pub fn is_bayer(&self) -> bool {
111119
self.width == 2
112120
}
113121

122+
/// Returns `true` if this is a 6x6 X-Trans pattern.
114123
pub fn is_xtrans(&self) -> bool {
115124
self.width == 6
116125
}

src/error.rs

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,36 @@
11
use core::fmt;
22

3+
/// Errors returned by demosaicing operations.
34
#[derive(Debug)]
45
pub enum DemosaicError {
5-
/// Input buffer length doesn't match width * height
6-
InputSizeMismatch { expected: usize, got: usize },
7-
/// Output buffer length doesn't match 3 * width * height
8-
OutputSizeMismatch { expected: usize, got: usize },
9-
/// Algorithm not supported for this CFA pattern
10-
UnsupportedAlgorithm { algorithm: &'static str, cfa: &'static str },
11-
/// Image too small for the chosen algorithm
12-
ImageTooSmall { min_width: usize, min_height: usize },
6+
/// Input buffer length doesn't match width * height.
7+
InputSizeMismatch {
8+
/// Expected number of elements.
9+
expected: usize,
10+
/// Actual number of elements.
11+
got: usize,
12+
},
13+
/// Output buffer length doesn't match 3 * width * height.
14+
OutputSizeMismatch {
15+
/// Expected number of elements.
16+
expected: usize,
17+
/// Actual number of elements.
18+
got: usize,
19+
},
20+
/// Algorithm not supported for this CFA pattern.
21+
UnsupportedAlgorithm {
22+
/// Name of the algorithm.
23+
algorithm: &'static str,
24+
/// CFA type (e.g. "Bayer", "X-Trans").
25+
cfa: &'static str,
26+
},
27+
/// Image too small for the chosen algorithm.
28+
ImageTooSmall {
29+
/// Minimum required width.
30+
min_width: usize,
31+
/// Minimum required height.
32+
min_height: usize,
33+
},
1334
}
1435

1536
impl fmt::Display for DemosaicError {

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
//! ```
3939
4040
#![no_std]
41+
#![warn(missing_docs)]
4142

4243
extern crate alloc;
4344

0 commit comments

Comments
 (0)