1. 程式人生 > >LASLib不能利用LASreader對原始檔進行修改

LASLib不能利用LASreader對原始檔進行修改

       嘗試對原始las檔案的點進行修改的需求包括點雲著色、點雲分類等,參考官網的例程發現,點雲著色和點雲簡單分類都是需要新建一個las檔案,對原始檔案的點進行修改後寫入到新檔案中:

例如,官網中點雲簡單分類示例程式碼中的點雲遍歷部分:(lasexample_simple_classification.cpp

// loop over the points

    while (lasreader->read_point())
    {
      xpos = I32_FLOOR((lasreader->point.get_x() - lasreader->header.min_x)/step);
      ypos = I32_FLOOR((lasreader->point.get_y() - lasreader->header.min_y)/step);

      pos = ypos*xdim + xpos;

      if (grid_minz[pos] < R)
      {
        lasreader->point.set_classification(8);
        count++;
      }

      laswriter->write_point(&lasreader->point);
      laswriter->update_inventory(&lasreader->point);
    }

例如,官網中點雲著色示例程式碼中的點雲遍歷部分:(lasexample_add_rgb.cpp

// loop over points and modify them

  // where there is a point to read
  while (lasreader->read_point())
  {
    // copy the point
    point = lasreader->point;
    // change RGB
    point.rgb[0] = point.rgb[1] = point.rgb[2] = U16_QUANTIZE(((point.get_z() - header.min_z)*65535.0)/(header.max_z - header.min_z));
    if (lasreader->point.get_classification() == 12) lasreader->point.set_classification(1);
    // write the modified point
    laswriter->write_point(&point);
  } 

感覺LASLib用不夠爽快,不是全部開源,PDAL貌似一直在更新,下一步嘗試一下PDAL,希望能像GDAL一樣開源。