-
Notifications
You must be signed in to change notification settings - Fork 3
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
The blacklevel confusion of Sony sensor & Missed saturation clipping after wb #12
Comments
Hi @shuwei666, thank you for your interest about our work. |
Thanks Dongyoung! In addition, I noticed that your code may have a slight mistake after performing black level correction. It appears that you did not apply saturation clipping after white balancing, resulting in the issue of bright pink colors, as shown below. Since the multi-illu estimation is pixel-based, this oversight could potentially impact the final performance. and here is the added code:
Furthermore, I observed that your code in '2_pre_process_data.py' only masks the Macbeth chart in the training dataset, but not in the validation and test datasets. This could lead to unfair comparisons with other methods. For example, using a simple max-RGB method may also yield good results. Anyway, thanks for your great work in this multi-illu estimation field. I am just hoping this minor tips could help make it better! |
I appreciate your attention to detail. For color chart masking, I understand that some classical algorithms can take advantage from color charts and the comparison may not be fair. I will add the caveats about saturation clipping and color chart masking to the README. Thanks again! |
Hi again @shuwei666 , import rawpy, os, cv2
import numpy as np
raw = rawpy.imread('Place208_1.arw')
tiff_file = 'Place208_1.tiff'
white_level = raw.white_level
black_level = raw.black_level_per_channel[0]
wb_kernel = raw.camera_whitebalance
wb_kernel = (np.array(wb_kernel) / wb_kernel[1])[0:3]
raw_data = cv2.imread(tiff_file, cv2.IMREAD_UNCHANGED).astype(float)
black_subtracted = np.clip(raw_data - black_level, 0, white_level-black_level)
white_balanced = black_subtracted * wb_kernel[None, None, :]
white_balanced = np.clip(white_balanced, 0, white_level)
auto_bright = white_balanced / white_balanced.max()
gamma_corrected = np.power(auto_bright, 1/2.2)
print('tiff file min/max : ', raw_data.min(), raw_data.max()) # 109, 4157
print('arw file min/max : ', raw.raw_image.min(), raw.raw_image.max()) # 438, 16628
print('White level: ', white_level)
print('Black level: ', black_level)
print('White balance kernel: ', wb_kernel)
print("Raw data min/max: ", raw_data.min(), raw_data.max())
print("Black subtracted min/max: ", black_subtracted.min(), black_subtracted.max())
print("White balanced min/max: ", white_balanced.min(), white_balanced.max())
# resize to 1/4
gamma_corrected = cv2.resize(gamma_corrected, (0,0), fx=0.25, fy=0.25)
cv2.imwrite('Place208_1.png', (gamma_corrected*255).astype(np.uint8)) |
Hi again, This Sony sensor seems a bit odd. I noticed it is a 14-bit depth sensor, but if that's the case, its black level should be closer to 512. However, according to your analysis, 128 is what allows for correct image output, which suggests that you might have used a 12-bit mode for saving. In other words, the effective bit depth of this Sony sensor's RAW data is actually 12 bits, right? |
I don't know what is a 12-bit saving mode. Is it a mode of DCRAW? or Sony camera? |
You can check the mode If you have the Sony alpha 9 camera. It seems that the Sony Alpha 9 camera is operating in a 12-bit depth mode since the black level at 128 and saturation point at 4095 correspond to a 12-bit range. Another possibility is that the camera might not truly possess the 14-bit depth capability as advertised. A histogram analysis(255bins) of the camera's raw output reveals that pixel values are predominantly within the lower range, up to approximately 50 (50 * 64 = 3200~4095). Conversely, there are significantly fewer occurrences of higher values. This pattern suggests that the actual effective bit-depth achieved by the camera is closer to 12-bit, contrary to the claimed 14-bit. That's may the reason why you tried blacklevel as 512 but failed! Bingo! |
I found the black level of Sony from the .arw raw file, which is$512$ .$128$ .
However, it seems that your code (in 2_pre_process_data.py)is using another manual value, which is
Could you explain this discreprancy?
Thanks!
The text was updated successfully, but these errors were encountered: