Skip to content
New issue

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

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

Already on GitHub? # to your account

Using PlantCV pcv.segment_image_series and pcv.create_labels to do image analysis #1572

Open
ariaf7 opened this issue Aug 4, 2024 · 1 comment
Labels
help wanted Request help

Comments

@ariaf7
Copy link

ariaf7 commented Aug 4, 2024

Hello! I am working with PlantCV to do image analysis of lettuce plants. I want to use the output from pcv.segment_image_series to analyze the shape and color of each of my lettuce plants. They overlap, which is why I am using pcv.segment_image_series in the first place. Here are the functions I am trying to use to do my analysis:

shape_img = pcv.analyze.size(img=img, **labeled_mask=labeled_mask**, n_labels=18)

shape_img = pcv.analyze.color(rgb_img=img, labeled_mask=labeled_mask, n_labels=18, colorspaces="RGB")

I know I need to use some sort of labeled_mask, num_plants = pcv.create_labels(mask=th_fill, rois=rois, roi_type="partial") for the labeled mask. However, I want to use the output from the pcv.segment_image_series function because it takes care of the overlap, while pcv.create_labels does not. And I can't use my output from the pcv.segment_image_series as input for pcv.create_labels or shape_img because the output isn't the right type. Sorry for not being very clear, I have very limited experience with PlantCV. I am not using the most recent version of PlantCV because I do not know how to update it as well. What do you all recommend?

@ariaf7 ariaf7 added the help wanted Request help label Aug 4, 2024
@ariaf7 ariaf7 changed the title Using pcv.segment_image_series and pcv.create_labels to do image analysis Using PlantCV pcv.segment_image_series and pcv.create_labels to do image analysis Aug 4, 2024
@HaleySchuhl
Copy link
Contributor

Hi @ariaf7 thanks for opening this issue. It has been brought up recently that the pcv.segment_image_series was a bit overlooked while we were updating the way PlantCV handles multi-object analysis in v4. This is something we're looking to address soon. In the meanwhile, here's how I was able to work around it. For more detail upstream of these steps, also see this GitHub issue.

...
analysis_image = pcv.segment_image_series(imgs_paths=paths_to_imgs_list, masks_paths=paths_to_masks_list, rois=valid_rois, save_labels=True, ksize=3)

lbl_mask = analysis_image[:,:,1]
shape_img = pcv.analyze.size(img=img, labeled_mask=lbl_mask, n_labels=20)
rgb_plot = pcv.analyze.color(rgb_img=img, labeled_mask=lbl_mask, n_labels=20, colorspaces="RGB")

Regarding updating your version of PlantCV, please refer to our updating doc page to see the recommendation depending on how you installed it. Please let us know if this helps.

Figure 24
Figure 87

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
help wanted Request help
Projects
None yet
Development

No branches or pull requests

2 participants