letmaik / rawpy

📷 RAW image processing for Python, a wrapper for libraw
https://pypi.python.org/pypi/rawpy
MIT License
587 stars 67 forks source link

flickering when converting a sequence of DNGs #195

Closed ahemberger closed 1 year ago

ahemberger commented 1 year ago

Hi there;

I have a sequence of DNG images (filmed on a Canon 5dmkiii, using Magic Lantern, converted to DNG using RAWMagic). When viewing the DNG sequence on its own, my frames look as expected. I'm trying to use rawpy to convert these images (to ACES EXRs, with the help of the colour-science library).

I notice that a handful of rawpy's postprocess params seem to cause flicker when I use them. Counterintuitively, these include:

no_auto_bright=True
highlight_mode=rawpy.HighlightMode(1)

I would have thought setting these params with these values would eliminate flicker, but I must be misunderstanding how they're intended to be used?

When I do not use these flag, the images convert and exhibit no flicker.

rawpy.imread(input_path).postprocess(
  gamma=(1, 1),
  #no_auto_bright=True,
  demosaic_algorithm=rawpy.DemosaicAlgorithm(11), l
  #highlight_mode=rawpy.HighlightMode(1),
  output_color=rawpy.ColorSpace(0), # raw
  output_bps=16,
  user_wb=numpy.hstack([RGB_w, RGB_w[1]]).tolist()
)

Would anyone happen to know why this might be?

Thank you!

ahemberger commented 1 year ago

Just discovered a thread on libraw forums indicating that no_auto_brightness can be coupled with adjust_maximum_thr=0.0, which seems to alleviate the flickering.

There's also a no_auto_scale param, which also fixes the flicker, but seems to return dramatically different colors. It's not yet clear to me why one might use this option (I suspect it has to do with normalizing RGB values after debayering, to account for the higher green pixel count...the image when using it is very green).

kmilos commented 1 year ago

There's also a no_auto_scale param

the image when using it is very green

I think unfortunately this parameter also disables any (be it auto/camera/user) white balance...

pmisson commented 1 year ago

Can happen because of other reasons. For example time-lapses with the shutter not completely open can flicker because the shutters do not stay the all the time exact same position when close and open between images.

letmaik commented 1 year ago

Closing this as it is not a rawpy issue. If a specific postprocessing parameter is needed that isn't exposed yet from libraw, please open a new issue.