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

different intensity dynamic with import #15

Closed
SReich-EMI opened this issue Mar 25, 2020 · 4 comments
Closed

different intensity dynamic with import #15

SReich-EMI opened this issue Mar 25, 2020 · 4 comments

Comments

@SReich-EMI
Copy link
Contributor

Dear all,
I use a Phantom highspeed camera which saves the data in cine-files. Therefore I use pycine to open the files and work with them. Overall it works quite nice.
But I found a discepancy between images I export directly from the Phantom software compared to the imported frames via pycine. It is not only a difference in global intensity values as expected for 8, 12 or 16 bit. It is also a different dynamic! Here you see a plot for two different exports from the Software (CV) with different bit depths and from pycine (Python). It is normalized to [0,1] to see the different dynamics.
intensity_Import

I used the following code for saving the frames as tif files:
raw_images, setup, bpp = pycine.raw.read_frames(pin, start_frame=1) for i, raw_image in enumerate(raw_images): imsave(os.path.join(pout, 'frame_py_{}.tif'.format(str(i).zfill(4))), raw_image)

Can someone tell my, why I get different dynamics and how I can solve this issue?

Kind regards
Stefan

@SReich-EMI
Copy link
Contributor Author

OK, I found the problem. It is not pycine, this is fine. It's the output into tiff files from CineViewer. There he takes into account the parameters gain, brightness and gamma, which were not at default. If I put them to default, the output is (almost) the same as the import via pycine. Only in the case of 16bit export the intensities are by a factor of 16 higher. It's because the four bits are filled at the end and not at the front.
Thanks for this nice pycine package!

@cbenhagen
Copy link
Collaborator

Wouldn't the CineViewer also apply the color correction matrix and white balance when exporting a tiff? That's something you would need to do on your own when using the raw .cine files. I would love to add the correct color pipeline. There is some old code from before we got the example code from VRI in https://github.com/OTTOMATIC-IO/pycine/blob/master/pycine/color.py but it's not working correctly. Porting the C example to Python or Cython or using it with CFFI would be the solution. I currently do not have the time to work on this but if you want to work on this I would be happy to help.

@SReich-EMI
Copy link
Contributor Author

Actually I only have gray-scale cameras. So I don't have accesss to any color cine files. If you can send me sample files I can try if I can figure out a good code. As it is nothig for work for me I have to do in spare times, so I will not be very fast. And the link to the request to VR in the color.py code does not wwork any more. It would be nice to have these infromation too.

@cbenhagen
Copy link
Collaborator

I added the output from VRIs cine2tiff to https://github.com/OTTOMATIC-IO/pycine/tree/master/testfiles. The comments in color.py represent the exact words in that forum entry. Unfortunately cine2tiff is only available under NDA.

You can get the latest (public) .cine file format documentation here. Unfortunately it does not yet contain the information about the 3x3 calibration matrix present as cmCalib in the setup. This is only in the 2013 version I have here.

I will ask VRI to release the latest version of the specs. Maybe they are even willing to release the cine2tiff sample code under a permissive license. That would allow to use that code directly from a public python library.

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