Skip to content

Fix get_mask and display_roi#33

Open
VenissaCarolQuadros wants to merge 2 commits intojdoepfert:masterfrom
VenissaCarolQuadros:master
Open

Fix get_mask and display_roi#33
VenissaCarolQuadros wants to merge 2 commits intojdoepfert:masterfrom
VenissaCarolQuadros:master

Conversation

@VenissaCarolQuadros
Copy link
Contributor

@VenissaCarolQuadros VenissaCarolQuadros commented Apr 27, 2021

  1. get_mask: Fixing 'valueerror: too many values to unpack (expected 2)' in case of rgb (or >2 dimension) images.
  2. display_roi: Quick fix . Discretion advised during merge... 'display_roi' was not displaying image earlier

@jdoepfert
Copy link
Owner

jdoepfert commented Apr 27, 2021

tx for the contribution! If you have RGB arrays, the function get_mean_and_std() will be undefined though..
So support for RGB will be more complex to handle, it needs more than a quick fix. One option would be to only allow get_mean_and_std for 2D arrays.

Also: Pls do submit one pull request at a time for each change (i.e. not putting the display_roi quick fix into the same PR as the valueerror fix).

@jdoepfert
Copy link
Owner

Thinking about it, rather than fixing the code, you should rather call get_mask() like so:

roi.get_mask(self, img[:,:,0])

@jdoepfert
Copy link
Owner

I will update the documentation to make this clearer

@jdoepfert
Copy link
Owner

Can you tell me what was the issue with display_roi and how it can be reproduced?

@VenissaCarolQuadros
Copy link
Contributor Author

tx for the contribution! If you have RGB arrays, the function get_mean_and_std() will be undefined though..
So support for RGB will be more complex to handle, it needs more than a quick fix. One option would be to only allow get_mean_and_std for 2D arrays.

Also: Pls do submit one pull request at a time for each change (i.e. not putting the display_roi quick fix into the same PR as the valueerror fix).

Ahh yes! Sorry for not taking that into account. Do not want to complicate this further however I could suggest going with mask=mask if image.ndim!=3 else np.dstack(tuple([mask for i in range(image.shape[2])])) for the sole reason that the mean and std would yield different results depending on whether you chose img[:, :, 0] or img[:, :, 1]. Do you see any problems that could arise with this ?

@VenissaCarolQuadros
Copy link
Contributor Author

VenissaCarolQuadros commented Apr 28, 2021

Can you tell me what was the issue with display_roi and how it can be reproduced?

The issue I was facing with display_roi is that it refused to display the image.. I followed the instructions as in the documentation with plt.imshow(image) ; my_roi = RoiPoly(color='r') ; plt.imshow(image) ; my_roi.display_roi() but the image window fails to pop up.

I use Anaconda Command Prompt ...

No errors show up whatsoever hinting that perhaps plt.show() could help..

P.S: Is this an eccentric issue that's affecting only me or is there something I'm missing? It could be a problem with my environment then... :(

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.

2 participants