graphdeco-inria / gaussian-splatting

Original reference implementation of "3D Gaussian Splatting for Real-Time Radiance Field Rendering"
https://repo-sam.inria.fr/fungraph/3d-gaussian-splatting/
Other
12.98k stars 1.63k forks source link

How to convert color in " .ply" file?? #485

Open lms7127 opened 8 months ago

lms7127 commented 8 months ago

I want to convert vertex color using the result " .ply" file.

In " .ply" file, I checked "property float f_dc_0~1", "property float f_rest_0~44". But this values are -1.~ to 1.~. I want to convert this value to nomal rgb or hs value like 0~255.

  1. How can I represent this f_dc, f_rest property to rgb or sh value(ex, 0~255 number)??
  2. Is there any good way to convert color in 3DGS??
jaco001 commented 8 months ago

value=(value+1)*128

lms7127 commented 8 months ago

Thank you for your reply : ) But under -1 (like, "-1.23") value can be minus. How can i control that value??

antonzub99 commented 8 months ago

Parameters f_dc_0, f_dc_1, f_dc_2 contain your R, G and B colors, You need to convert them into regular format with something like R = 0.5 + C0 * f_dc_0 where C0 is the zeroth-order spherical harmonic coefficient. After that, you will obtain colors in the [0, 1] range and it is straightforward to map them to [0, 255] integers.

The rest of the spherical harmonics don't really make much sense without viewing directions (the rasterizer handles that for you OR you have to do raycasting and compute the view-dependent color by yourself), so I would go just with the base RGB color.

lms7127 commented 8 months ago

Thank you for your response!! I applied this method just now(0.5 + C0 * f_dc_0, I think C0 is 0.28209479177387814). Some of the values are under 0, but most values are pretty good:)

pknmax commented 8 months ago

@lms7127 @antonzub99 can you please tell how we can compute the final view-dependent color and not just base RGB?

lms7127 commented 7 months ago

f_dc_0(is red), f_dc_1(is green), f_dc_2(is blue) convert f_dc_0, 1, 2 to 0~255 using (0.5 + C0 * f_dc_0, I think C0 is 0.28209479177387814) maybe this is final view color

TristanMorelle commented 7 months ago

How is this? i'm reading negative values of the splats like f_dc_0 = -2.2223 from polycam

applying the formula: 0.5 + 0.28209479177387814 * -2.2223 = -0.126899255759089390522

this makes no sense to me.

sugerkiller commented 5 months ago

I notice that there are some parameters in the .ply file called 'f_rest_nums', do you know what these parameters do?

PlyProperty('f_rest_1', 'float'), PlyProperty('f_rest_2', 'float'), PlyProperty('f_rest_3', 'float')
JayNyce commented 4 months ago

Is this formula applied on the ply output after training