how to copy RGB as "extra bytes" to another laz with identical point index?

81 views
Skip to first unread message

Andrew Ritchie

unread,
Oct 24, 2024, 2:03:14 AM10/24/24
to LAStools - efficient tools for LiDAR processing
I have two laz files, each with 3 spectral bands in RGB (from sfm with 6-band imagery). Each file has identical points and I would like to copy the RGB bands from one file (band456.laz) to user bytes (attribute 4 5 6 which don't exist in the source file)

What I wish I could do:

lascopy64 -i band456.laz -i band123.laz -o band123456.laz ^
-unmatched ^
-copy_R_into_register 0 ^
-copy_G_into_register 1 ^
-copy_B_into_register 2 ^
-copy_register_into_attribute 0 4 ^
-copy_register_into_attribute 1 5 ^
-copy_register_into_attribute 2 6

but that doesn't do anything unfortunately.

I *think* I can see a convoluted way of doing this with las2las and lascopy mapping one band into intensity on each pass of las2las, then copying intensity to the destination file with lascopy, then mapping intensity to an attribute with las2las, and maybe with some intermediate steps involving registers and scaling and adding attributes (iadd_attribute?) and specifying data types (documentation anywhere?) but I would really love it if there's something simpler that I don't know about. Do I really need to start with something like this and experiment?

las2las -i band456.laz -o source.laz -copy_R_into_intensity
lascopy -i source.laz -i band123.laz -o target.laz -unmatched -copy_intensity
las2las -i target.laz -o band1234.laz -copy_intensity_into_attribute 4
las2las -i band456.laz -o source.laz -copy_G_into_intensity
lascopy -i source.laz -i band1234.laz -o target.laz -unmatched -copy_intensity
las2las -i target.laz -o band12345.laz -copy_intensity_into_attribute 5
las2las -i band456.laz -o source.laz -copy_B_into_intensity
lascopy -i source.laz -i band12345.laz -o target.laz -unmatched -copy_intensity
las2las -i target.laz -o band123456.laz -copy_intensity_into_attribute 6


Jochen Rapidlasso

unread,
Oct 25, 2024, 7:45:10 AM10/25/24
to LAStools - efficient tools for LiDAR processing
Hi Andrew,
this is a task we have not often heard of, anyway, it would be good to have a option to copy color values to attributes/extra bytes more easy.
We will implement this soon.

Cheers,

Jochen @rapidlasso

Jochen Rapidlasso

unread,
Nov 5, 2024, 4:11:30 PM11/5/24
to LAStools - efficient tools for LiDAR processing
Hi Andrew,
with latest release (241031) lascopy64 got 2 new arguments:

-copy_rgb          : copy rgb to target (64bit only)  
-copy_user_data    : copy user data to target (64bit only)     

This helps to simplify your task.
Please see this example:

This are our testfiles. We want to copy the RGB of "file A" into Extrabytes (Attributes) of "file B".

file A            file B
x y z R  G  B     x y z R  G  B  
1 1 1 55 66 77    1 1 1 88 99 00  
2 3 4 66 77 88    2 3 4 11 22 33  

:: first we create your testfiles out of the textfiles
txt2las64 -i fileA.txt -o fileA.laz -set_scale 1 1 1

LAStools txt2las (by in...@rapidlasso.de) version 241031
Column description detected. Parse string is xyzRGB
opening reader took 0 sec.
reading from 'fileA.txt' and writing to 'fileA.laz'
main pass took 0.001 sec.
done with 'fileA.laz'. total time 0.001 sec.

txt2las64 -i fileB.txt -o fileB.laz -set_scale 1 1 1

:: then we extend one file with the attribs we want to have
las2las64 -i fileA.laz -o fileAa.laz -add_attribute 1 R Red  -add_attribute 1 G Green  -add_attribute 1 B Blue
lasinfo64 -i fileAa.laz
            ...
    Extra Byte Descriptions
      data type: 1 (unsigned char), name "R", description: "Red", scale: 1 (not set), offset: 0 (not set)
      data type: 1 (unsigned char), name "G", description: "Green", scale: 1 (not set), offset: 0 (not set)
      data type: 1 (unsigned char), name "B", description: "Blue", scale: 1 (not set), offset: 0 (not set)
           ...

:: now we copy the RGB values of our file into the attributes
las2las64 -i fileAa.laz -o fileAb.laz ^
  -copy_R_into_register 0 -copy_G_into_register 1 -copy_B_into_register 2 ^
  -copy_register_into_attribute 0 0  -copy_register_into_attribute 1 1  -copy_register_into_attribute 2 2
lasinfo64 -i fileAb.laz

  Color R 55 66
        G 66 77
        B 77 88
  attribute0         55         66  ('R')
  attribute1         66         77  ('G')
  attribute2         77         88  ('B')

:: finally we do the lascopy task to copy the RGB values of "file B" into our new file
:: we do this unmatched - just by order, of course this should work with -match_.... arguments as well
lascopy64 -i fileB.laz -i fileAb.laz -o fileC.laz -unmatched -copy_rgb
lasinfo64 -i fileC.laz

  Color R 11 88
          G 22 99
          B 0 33
  attribute0         55         66  ('R')
  attribute1         66         77  ('G')
  attribute2         77         88  ('B')

:: final test: export the values to text to view the results
las2txt64 -i fileC.laz -o fileC.txt -parse xyzRGB012 -coldesc

x y z  R  G  B  0  1  2
1 1 1 88 99  0 55 66 77
2 3 4 11 22 33 66 77 88


Hope this helps,
Cheers,

Jochen @rapidlasso
Reply all
Reply to author
Forward
0 new messages