Comments (4)
Hi,
For .png
and .jpg
, the write_bitmap
function will apply a sRGB gamma ramp to the pixel color values. Therefore when loading one of those images as a numpy array
, this sRGB gamma ramp will be baked in the image. Using it as a reference, the optimization process will converge to a set of parameters that tries to mimic the effect of this gamma ramp.
A solution would be to output an EXR reference image, which is not gamma corrected:
write_bitmap('out_ref.exr', image_ref, crop_size)
# which we can load back from disk:
my_bmp_ref = Bitmap('out_ref.exr')
# and/or convert it to a numpy array
my_np_ref = np.array(my_bmp_ref)
When working with external data (e.g. photo, reference image generated by a different program), it is important to ensure that the format of the reference data matches the output of the differential rendering process (e.g. same color space).
We could maybe expose another parameter to the write_bitmap
function to specify whether to apply the sRGB gamma ramp or not (for png
and jpg
as well).
from mitsuba2.
Hi @Speierers,
thank you for your answer. Unfortunately, I'm not too familiar with color spaces and gamma ramps. But if I understand this correctly and I work with external data (i.e. a photo in .png
format) I can use something like histogram matching to get the same color space as from the rendering process? However, I guess that the initial guess as output of the diff. rendering process (at the beginning of the optimization) must be at least similar in terms of light conditions?
Is there a possibility to undo the gamma correction in a .png
/ .jpg
image (if the reference image is not available in .exr
format)?
from mitsuba2.
It would be great to know in what color space your reference image lives in and apply the right conversion. Not sure whether histogram matching will be good enough. This will definitely affect the set of parameters (e.g. color values) resulting from the optimization process.
In Mitsuba 2, it is possible to undo the gamma correction in the following way:
import numpy as np
import mitsuba
mitsuba.set_variant("scalar_rgb")
from mitsuba.core import Bitmap, Struct
# Load a PNG from disk (gamma-corrected)
img_srgb = Bitmap("my_image.png")
# Undo the gamma correction
img_linear = img_srgb .convert(Bitmap.PixelFormat.RGB, Struct.Type.UInt8, srgb_gamma=False)
# Similarly you can convert from Int8 to Float values
img_float = img_srgb .convert(Bitmap.PixelFormat.RGB, Struct.Type.Float32, srgb_gamma=False)
# Get the corresponding Numpy array
img_np = np.array(img_float)
from mitsuba2.
Thank you for your answer. This is what I was looking for.
from mitsuba2.
Related Issues (20)
- [🔨 compilation issue] 'cmake -GNinja' step HOT 3
- [❔ other question] How to convert/extract enoki.autodiff_cuda.Float32 type array from Bitmap class? HOT 4
- [❔ other question]runtime API error = 0719 HOT 1
- [🐛 bug report] importing Pytorch after mitsuba => Segmentation fault (core dumped) HOT 1
- [❔ other question] Performance on Windows much lower than Linux? HOT 5
- [🐛 bug report] hdrfilm.cpp: duplicate channel detection HOT 3
- [❔ other question] how to uninstall mitsuba2 in linux? HOT 4
- The examples of Differentiable rendering applications HOT 2
- [🐛 bug report] OptiX "arithmetic involving uninitialized variable!" with Certain Scenes HOT 1
- [✨ feature request] Tutorial on differential rendering material acquisition HOT 1
- Something about code HOT 1
- Caught a critical exception: main [properties.cpp:401] └1∩Æ∞☺
- [✨ feature request] Does the mitsuba2 support bsdf for cloth model? HOT 1
- 用java或C++用物件導向的概念設計程式解下面的問題:讀取一組時間,計算出時針與分針的夾角,時間的格式是0:00到12:00,小時數可能為1或2位數,分鐘數總是2位數,00到59之間。輸出腳讀為0到180之間的值,角度的精確度到千分之一。例如9:00是90.000度,不是-90,也不是270,2:00則是60 HOT 1
- Rendered polarized images' intensity doesn't change according to the change of polarization angle- [❔ other question] HOT 1
- [❔ other question] setting the variant("llvm_spectral_polarized"), the code didn't work HOT 2
- [❔ other question]How can we output UV map in python? HOT 1
- - [❔ other question] I want to optimize the values in the transform component of my sensor plugin HOT 1
- Unable to compile: Windows 10: Visual Studio Community 2022 HOT 1
- White noise in spectral rendering - [❔ other question] HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mitsuba2.