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

Issue #3942 - silx compare typo #3943

Merged
merged 1 commit into from
Oct 2, 2023
Merged

Conversation

lesaintjerome
Copy link
Contributor

Fix python set(3,4) command with set([3,4]).

Fix python set(3,4) command with set([3,4]).
@@ -138,7 +138,7 @@ def readData(self, urlPath: str):

if data.ndim == 2:
return data
if data.ndim == 3 and data.shape[0] in set(3, 4):
if data.ndim == 3 and data.shape[0] in set([3, 4]):
Copy link
Member

@t20100 t20100 Sep 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I guess this is to support RGB(A) images, and so checking the number of channels which is usually the last dimension:

Suggested change
if data.ndim == 3 and data.shape[0] in set([3, 4]):
if data.ndim == 3 and data.shape[2] in {3, 4}:

attn @vallsv

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My use case was rather about comparing 2 (gray level) 3D volumes, possibly each of them with only one slice. Slice being the first index.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I don't think this is supported: It is meant to support comparing 2 images..
Otherwise the limit to 3 or 4 slices makes no sense, while it does for RGB(A).

What could be added for stack with only one slice could be:

if data.ndim == 3 and data.shape[0] == 1:
    return data[0]

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's loaded here is then passed to:

def setImage1(self, image1, updateColormap="deprecated"):
"""Set image1 to be compared.
Images can contains floating-point or integer values, or RGB and RGBA
values, but should have comparable intensities.
RGB and RGBA images are provided as an array as `[width,height,channels]`
of unsigned integer 8-bits or floating-points between 0.0 to 1.0.
:param numpy.ndarray image1: The first image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. I probably need to be more precise on the issue. The error happened when with

silx compare "bambou_hercules_0001_rec_2040.800_00000.hdf5?path=/entry0000/reconstruction/results/data" "bambou_hercules_0001_rec_2058.800_00000.hdf5?path=/entry0000/reconstruction/results/data"

, i.e. with no slice number. But when the command

silx compare "bambou_hercules_0001_rec_2040.800_00000.hdf5?path=/entry0000/reconstruction/results/data&slice=0" "bambou_hercules_0001_rec_2058.800_00000.hdf5?path=/entry0000/reconstruction/results/data&slice=0"

is used (i.e. with slice number), then it works fine. That's why I thought stacks were possible....

Copy link
Contributor

@vallsv vallsv Oct 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, to support slicing with a slider for example, you better to create another dedicated issue.

I don't think we will have time to do it now.

Optionally you could try to see if slice=* works, but i am pretty sure it is not supported.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@t20100 i agree there is something weird with the shape index which is supposed to be ordered y,x,rgb[a]. Ill check on my side.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, this shape[0] is maybe the layout provided by fabio or another lib when we load a RGB image. I have to check.

@t20100 t20100 added this to the 2.0.0 milestone Sep 28, 2023
@vallsv
Copy link
Contributor

vallsv commented Oct 2, 2023

I merge this PR for convenience.
I will rework the other proposals with the PR #3944

@vallsv vallsv merged commit 98bb6b9 into silx-kit:main Oct 2, 2023
5 of 7 checks passed
@vallsv vallsv mentioned this pull request Oct 2, 2023
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.

3 participants