hanayik / niivue

a WebGL2 based NIFTI volume viewer.
https://hanayik.github.io/niivue
BSD 3-Clause "New" or "Revised" License
11 stars 7 forks source link

Reorient and scale overlays #86

Closed neurolabusc closed 3 years ago

neurolabusc commented 3 years ago

Please validate. This should correctly reslice overlay images to match background image. Consider the images:

hanayik commented 3 years ago

@neurolabusc does the overlay appear translated left?

screenshot

Screenshot 2021-03-16 at 15 29 35

neurolabusc commented 3 years ago

I suggest you merge this PR. It seems pretty close. Perhaps there is a 0.5 voxel difference (I tried to compensate for voxel center versus texture edge). This will be easier to fine tune once other features are implemented (e.g. better control of opacity, contrast, and allowing the user to load custom files). I actually solved the equation the wrong way around (hence mat.mat4.invert(mtx, mtx);). I could either retain the current solution, change my solution, or retain the current solution without the inversion and change the shader. Regardless, this is pretty close and will allow us to resolve other issues.

hanayik commented 3 years ago

NVM, when I pulled your branch down the images were different than what you listed in your commit, so that explains the slight difference I guess. Set it to LAS, and IPL and then it looked great.

hanayik commented 3 years ago

niivue.prototype.setOpacity(volIdx, newOpacity) now accepts the volume index and the new opacity for each volume in the list. The sliders for the loaded images are independent now. You should also be able to reference this.volumes[idx].opacity when setting up the textures.

setOpacity is more for redrawing the canvas when a slider changes the value.