Skip to content

Fix incorrect dimension handling for grayscale images in base_loader()#290

Open
Chandraveersingh1717 wants to merge 1 commit intomlverse:mainfrom
Chandraveersingh1717:fix/grayscale-image-dimensions
Open

Fix incorrect dimension handling for grayscale images in base_loader()#290
Chandraveersingh1717 wants to merge 1 commit intomlverse:mainfrom
Chandraveersingh1717:fix/grayscale-image-dimensions

Conversation

@Chandraveersingh1717
Copy link
Contributor

Description:
Fixes #289

Changes

  • Fixed bug in R/folder-dataset.R where grayscale images with singleton first dimension were incorrectly transformed
  • Changed from abind(img, img, img, along = 1) %>% aperm(c(3,1,2)) to abind(img[1,,], img[1,,], img[1,,], along = 3)

Why

The previous code stacked along dimension 1 creating (3, H, W), then permuted to (W, 3, H) which is incorrect.
The fix directly stacks the 2D image along dimension 3 to create (H, W, 3), which is the expected format.

Testing

  • Tested with grayscale images
  • Verified existing tests still pass

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix incorrect image dimension handling for grayscale images in base_loader()

1 participant