mfbonfigli / gocesiumtiler

A Cesium.js point cloud 3D tiles generator from LAS files written in Golang
GNU Lesser General Public License v3.0
169 stars 36 forks source link

Colors not showing on .las files with 8-bit RGB values #17

Closed majos95 closed 2 years ago

majos95 commented 2 years ago

Whenever I use 8-bit RGB .las files the point cloud appears all black even though the RGB's byteOffset is present within each .pnts. This doesn't happen with 16-bit RGB files, is this a known prerequesite?

mfbonfigli commented 2 years ago

Good question. I need to deep dive into the las reader library to figure that out. Unfortunately I didn't write that module, so it will require time (which I don't have right now) to spot and fix the issue

majos95 commented 2 years ago

I found a solution, when using laszip to extract my .laz files I run it with a flag -scale_RGB_to_16bit which solved my problem

mfbonfigli commented 2 years ago

Did a bit of research there. Seems like that the LAS specs want colors (https://www.asprs.org/wp-content/uploads/2010/12/LAS_1_4_r13.pdf) to be stored using 16 bits, but evidently not all implementations follow this requirement.

Anyway I guess the fix should be quite simple, in tiler_las_reader.go we should get rid of the division by 256 in this block if colors are already 8 bit:

R = uint8(binary.LittleEndian.Uint16(b[offset:offset+2]) / 256)
offset += 2
G = uint8(binary.LittleEndian.Uint16(b[offset:offset+2]) / 256)
offset += 2
B = uint8(binary.LittleEndian.Uint16(b[offset:offset+2]) / 256)
offset += 2

Unsure if there is a way to understand the color depth automatically. Worst case would be to add a new flag to the CLI to specify a 8bit color depth which I believe is totally fine

omritz commented 2 years ago

Is there a solution to this? My points still appear in black...

mfbonfigli commented 2 years ago

The solution for now is to convert the last to 16 bit before, or to build the code removing the division by 256 in the three lines mentioned above.

I will try to create a new option to add support for the non standard 8bit las files but not sure when I'll have time to work on that.

Il mar 19 ott 2021, 15:45 omritz @.***> ha scritto:

Is there a solution to this? My points still appear in black...

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/mfbonfigli/gocesiumtiler/issues/17#issuecomment-946739954, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACFVRJYWAAUGYBPLQYYR6I3UHVY7PANCNFSM5ANS3TOA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

omritz commented 2 years ago

I appreciate your help, it solved my problem!

mfbonfigli commented 2 years ago

I added a new flag that can be used to force the system to interpret las colors as 8 bit colors instead of 16 bit. Closing the issue for now, in future it would be nice to have an autodetect system in place, if at all possible.