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

How to implement custom colored volume loader? #293

Closed
mapseamoff opened this issue Nov 11, 2022 · 1 comment
Closed

How to implement custom colored volume loader? #293

mapseamoff opened this issue Nov 11, 2022 · 1 comment

Comments

@mapseamoff
Copy link

Hello!

I'm trying to create custom loader for volume with colors associated to each voxel. I'm doing something like this:

const customVolumeLoader = (volumeId, options) => {
  return {
    promise: Promise.resolve(new ImageVolume({
        volumeId,
        dimensions:  [10, 10, 10],
        spacing:     [1, 1, 1],
        origin:      [0, 0, 0],
        metadata:    {
          FrameOfReferenceUID: 'default',
          Modality: 'CT',
          PhotometricInterpretation: 'RGB',
          PixelRepresentation: 0,
        },
        direction:   [1, 0, 0, 0, 1, 0, 0, 0, 1],
        scalarData:  Uint8Array.from(new Array(10 * 10 * 10 * 3).fill(255)),
        sizeInBytes: 10 * 10 * 10 * 3,
      });
    }),
    cancel: undefined /* TODO */
  }
}

The volume loader is registred in cornerstone and called in createAndCacheVolume. I expect it to display white cube but in viewport it shows nothing (same for Float32Array filled with 1.0).

P.S. Is it possible to add opacity to voxels in this case? One of the workarounds for my use case is to force vtkColorTransferFunction to map scalar colors as identity, i.e. 0xRRGGBB -> 0xRRGGBB, but is it actually possible?

Many thanks!

@sedghi sedghi assigned jbocce and unassigned jbocce Jan 12, 2023
@sedghi sedghi closed this as completed in 34b7561 Jan 27, 2023
@mapseamoff
Copy link
Author

I tested the above code and it is still not working: it shows black cube in the viewport instead of white. Am I doing something wrong?

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

No branches or pull requests

2 participants