Skip to content

Commit

Permalink
Add a method for pixel size in sophus::ImageView
Browse files Browse the repository at this point in the history
Without this method it's difficult to calculate the actual size in bytes
of subviews because they normally inherit the layout from the parent
image, which has a pitch_bytes indicating the full width times pixel
size.

This simplifies that to expose the pixel size directly.
  • Loading branch information
wylderkeane committed Oct 9, 2023
1 parent 89520c0 commit 1a4cb21
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cpp/sophus/image/image_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ struct ImageView {
[[nodiscard]] auto sizeBytes() const -> size_t {
return layout().sizeBytes();
}
[[nodiscard]] auto pixelSize() const -> size_t {
return sizeof(Pixel);
}

/// Returns true if u is in [0, width).
[[nodiscard]] auto colInBounds(int u) const -> bool {
Expand Down

0 comments on commit 1a4cb21

Please sign in to comment.