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

Add circular crop? #1561

Open
k034b363 opened this issue Jul 3, 2024 · 2 comments
Open

Add circular crop? #1561

k034b363 opened this issue Jul 3, 2024 · 2 comments
Labels
new feature New feature ideas and solutions

Comments

@k034b363
Copy link
Contributor

k034b363 commented Jul 3, 2024

Is your feature request related to a problem? Please describe.
A few times recently it has seemed like cropping to a circle would be useful, but I'm not sure how hard it would be. One specific example involves X-ray images of seeds inside of a Petri dish. The dish is very bright, so being able to crop to everything inside, even if it means just zero-ing out some padding around the outside to keep displaying a rectangle, would I think help some downstream analysis.

Describe the solution you'd like
A separate function like the current crop, but that takes a center point and radius as input for cropping.

@k034b363 k034b363 added the new feature New feature ideas and solutions label Jul 3, 2024
@nfahlgren
Copy link
Member

Hi Keely, would this approach work for you?

from plantcv import plantcv as pcv
# Read image
img, _, _ = pcv.readimage(filename="2017-01-18_1510_ch129-pos01.jpg")
# Create circle ROI
roi = pcv.roi.circle(img=img, x=1300, y=1200, r=200)
# Convert ROI to a mask
roimask = pcv.roi.roi2mask(img=img, roi=roi)
# Mask the input image
masked = pcv.apply_mask(img=img, mask=roimask, mask_color="black")

2017-01-18_1510_ch129-pos01
Figure 7

@k034b363
Copy link
Contributor Author

k034b363 commented Jul 3, 2024

Yes, thank you! That's what Pavan ended up doing, and it works great. Maybe for the sake of redundancy (and since it's only 3 steps), it doesn't make sense to have a separate function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature New feature ideas and solutions
Projects
None yet
Development

No branches or pull requests

2 participants