BrownBiomechanics / Autoscoper

Autoscoper is a 2D-3D image registration software package.
https://autoscoper.readthedocs.io
Other
8 stars 5 forks source link

Large Tiff Scaling #45

Open NicerNewerCar opened 2 years ago

NicerNewerCar commented 2 years ago

Issue where larger 24-bit images are not rendered properly in autoscoper.

Issue from Madalyn Hague:

The problem is that when I create a new project in Autoscoper, the XROMM images are not at their full scale (I've included a screenshot). The bone models are in mm as they should be and I have done the calibration in XMALab like I have before. I used the mm version of the lego cube calibration object ref file and the MayaCam 2.0 files are approximately the same as the MayaCam files from past subjects (meaning not off by a scale of 10 or something). I tried using the cm version of the lego cube file just to make sure, and that did not work either. The images are somewhat registering because as I move through the slices you can partially see the knee. It seems like the scaling is incorrect, but I can't figure out where!

image image (1)

The workaround she found:

I just used MATLAB to convert the 24-bit images to 8-bit and I can now see the whole image in Autoscoper. It definitely is the problem, but now the resolution or compression is altering the image

The tiff images in question are 2048x2048 24-bit images with LZW compression, currently we are usning 512x512 8-bit images with LZW compression to preform our tests.

If you would like to see the dataset in question please don't hesitate to reach out to me.

Examples

Good Quaility

good_quality_ex_oldcams

Matlab Converted

matlab_converted

Python Converted

python_converted

amymmorton commented 1 year ago

Example tiff files 02-010_R_Hop_11_Cam01_UND.0002.txt 02-010_R_Hop_11_Cam02_UND.0001.txt 02-010_R_Hop_11_Cam02_UND.0002.txt 02-010_R_Hop_11_Cam01_UND.0001.txt

rename .txt .tif

NicerNewerCar commented 7 months ago

Looking through my notes, I found some comments on this that I never posted.

The primary issue here is that both the CUDA and OpenCL backends only support Greyscale radiograph images (8/16/32 bit images) and not RGB (24/48?/96? bit images). Here is my proposed solution along with a brief overview of the rendering pipeline.

AutoscoperMainWindow::frame_changed passes some information to the GPU renderers and then calls GLView::PaintGL to perform the rendering [This sets the viewport then calls View::Render which then calls all GPU renderers]. When we are passing the info to GPU we should include the samplesPerPixel field from the Videos current image_ . This will be 1 for Greyscale images and 3 for RGB images.

Within RadRenderer::set_rad we need to ensure that we are accounting for the samplesPerPixel when we are binding the image to the GPU. Within the kernel, I think we should cast to Greyscale on the fly using channel weighting such as this.