Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kmeans function changes image size #1552

Closed
k034b363 opened this issue Jun 17, 2024 · 3 comments · Fixed by #1570
Closed

Kmeans function changes image size #1552

k034b363 opened this issue Jun 17, 2024 · 3 comments · Fixed by #1570
Assignees
Labels
bugfix Bug fixes

Comments

@k034b363
Copy link
Contributor

Describe the bug
Somewhere in the kmeans clustering pipeline, the image size is changing. We think this is a feature of the patch-based approach maybe change dimensions to be divisible by the specified patch size. The proposed fix is to add padding to the right and bottom of the image with some background average value to make sure the patch size is divisible by each dimension, and then slice back to the original dimensions when finished.

To Reproduce

  1. Starting with a set of images, train a model using plantcv.learn.train_kmeans making sure to specify a patch size that doesn't divide evenly into the image pixel dimensions
  2. Using a focal image, classify the pixels in the image using plantcv.predict_kmeans
  3. Check the shape of both the original focal image and the output from the prediction step. If the patch size doesn't divide evenly, the image will be smaller after prediction.

Expected behavior
We expect the kmeans function not to change the image size. This is making some downstream checks using the overlay of cluster masks on the original image impossible.

Local environment (please complete the following information):

  • OS: macOS
  • Environment: conda plantcv dev environment
  • PlantCV Version: dev

Additional context
Add any other context about the problem here.

@k034b363 k034b363 added the bugfix Bug fixes label Jun 17, 2024
@k034b363 k034b363 self-assigned this Jun 17, 2024
@HaleySchuhl
Copy link
Contributor

Thank you to @jbraley1107 for your help reviewing the iterations of bugfixes. We are trying to adjust for the loss of detection along borders by adding some image padding prior to patch extraction in predict_kmeans .

@HaleySchuhl
Copy link
Contributor

@all-contributors please add @jbraley1107 for review, userTesting

Copy link
Contributor

@HaleySchuhl

I've put up a pull request to add @jbraley1107! 🎉

@k034b363 k034b363 mentioned this issue Oct 24, 2024
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix Bug fixes
Projects
None yet
2 participants