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

ocioview: Cube Inspector #1875

Closed

Conversation

michdolan
Copy link
Collaborator

@michdolan michdolan commented Oct 1, 2023

This PR adds a cube inspector to ocioview, which is a 3D viewport that plots a color cube or image as a point cloud, with the current viewer's processor applied.

Individual points can be clicked to sample them, displaying RGB output values and a swatch, similar to the image viewer. I had originally implemented sampling on hover, but depending on the image density, this can get slow, so I removed it for now.

Other options provide control of cube size, image sample density, sample decimal precision, whether to clamp samples to the source cube, and whether to display source cube edges. Left click pans around the cube and the scroll wheel zooms towards or away from its center.

ocioview with Cube Inspector
image

33x33x33 cube
image

9x9x9 cube
image

image point cloud:
image

image point cloud, clamped
image

image point cloud, clamped, cube edges hidden
image

Comment on lines +684 to +699
if self._input_src == InputSource.IMAGE and self._image_buf is not None:
image_spec = self._image_buf.spec()
identity_grid = self._image_buf.get_pixels(
oiio.FLOAT,
roi=oiio.ROI(
# fmt: off
image_spec.x,
image_spec.x + image_spec.width,
image_spec.y,
image_spec.y + image_spec.height,
0, 1,
0, 3,
# fmt: on
),
).reshape((image_spec.width * image_spec.height, 3))[:: self._image_detail]
sample_count = identity_grid.size // 3
Copy link
Contributor

@KelSolaar KelSolaar Oct 8, 2023

Choose a reason for hiding this comment

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

I haven't looked at all the code yet but as I'm working on the chromaticity diagram and I need a ndarray, I'm wondering if rather than passing an OIIO ImageBuf around, it would not be better to be in Numpy land.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Agree with that, in #1853 I'm making OIIO an optional dependency (same for Imath, basically everything that doesn't have PyPI package ideally).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point. I can change it to a ndarray.

self._mouse_button = None
self._mouse_last_pos = None
self._cpu_proc = None
self._image_buf: np.ndarray = None
Copy link
Contributor

@KelSolaar KelSolaar Oct 8, 2023

Choose a reason for hiding this comment

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

Type is oiio.ImageBuf here I think.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good catch. Thanks!

@michdolan
Copy link
Collaborator Author

I'm going to close this for now, and will open a new PR once we settle on a graphics framework for this and other ocioview 3D inspectors.

@michdolan michdolan closed this Nov 21, 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.

4 participants