Skip to content

Commit

Permalink
Merge pull request #488 from thewtex/dim-2d
Browse files Browse the repository at this point in the history
fix(2DImageRendering): Set color level, color window
  • Loading branch information
thewtex authored May 19, 2022
2 parents 8084f37 + 5b3aa65 commit 0aec56c
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/Rendering/VTKJS/Images/applyRenderedImage.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,19 @@ function applyRenderedImage(context, event) {
const actorProperty = actor.getProperty()
actorProperty.setIndependentComponents(actorContext.independentComponents)
actor.getMapper().setInputData(actorContext.fusedImage)
let minRangeUse2D = Infinity
let maxRangeUse2D = -Infinity
actorContext.visualizedComponents.forEach(
(componentIndex, fusedImageIndex) => {
if (!context.images.lookupTableProxies.has(componentIndex)) {
return
}
if (actorContext.colorRanges.has(componentIndex)) {
const range = actorContext.colorRanges.get(componentIndex)
minRangeUse2D = Math.min(minRangeUse2D, range[0])
maxRangeUse2D = Math.max(maxRangeUse2D, range[1])
}

const colorTransferFunction = context.images.lookupTableProxies
.get(componentIndex)
.getLookupTable()
Expand All @@ -126,6 +134,14 @@ function applyRenderedImage(context, event) {
)
}
)
if (
context.use2D &&
minRangeUse2D !== Infinity &&
maxRangeUse2D !== -Infinity
) {
actorProperty.setColorLevel((maxRangeUse2D - minRangeUse2D) / 2.0)
actorProperty.setColorWindow(maxRangeUse2D - minRangeUse2D)
}
})

// Visualized components may have updated -> set color transfer function, piecewise function, component visibility, independent components in volumes
Expand Down

0 comments on commit 0aec56c

Please sign in to comment.