Skip to content

Commit

Permalink
Bugfix: show labels on segmentation images with trivial dimensions
Browse files Browse the repository at this point in the history
  • Loading branch information
jleibs committed Nov 28, 2023
1 parent 8fa6509 commit 6618a11
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion crates/re_data_ui/src/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,8 @@ fn tensor_pixel_value_ui(
ui.label(format!("{x}, {y}"));
ui.end_row();

if tensor.num_dim() == 2 {
// Check for annotations on any single-channel image
if let Some([_, _, 1]) = tensor.image_height_width_channels() {
if let Some(raw_value) = tensor.get(&[y, x]) {
if let (TensorDataMeaning::ClassId, Some(u16_val)) =
(meaning, raw_value.try_as_u16())
Expand Down
4 changes: 2 additions & 2 deletions crates/re_types/src/datatypes/tensor_data_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ impl TensorData {
2 => Some([shape_short[0].size, shape_short[1].size, 1]),
3 => {
let channels = shape_short[2].size;
if matches!(channels, 3 | 4) {
// rgb, rgba
if matches!(channels, 1 | 3 | 4) {
// mono, rgb, rgba
Some([shape_short[0].size, shape_short[1].size, channels])
} else {
None
Expand Down

0 comments on commit 6618a11

Please sign in to comment.