Package: cloth-simulation-filter
CSFAirborne LiDAR filtering method based on Cloth Simulation.
This is the code for the article:W. Zhang, J. Qi*, P. Wan, H. Wang, D. Xie, X. Wang, and G. Yan, “An Easy-to-Use Airborne LiDAR Data Filtering Method Based on Cloth Simulation,” Remote Sens., vol. 8, no. 6, p. 501, 2016.
(http://www.mdpi.com/2072-4292/8/6/501/htm)New feature has been implemented:Now, We has wrapped a Python interface for CSF with swig. It is simpler to use now. This new feature can make CSF easier to be embeded into a large project. For example, it can work with Laspy (https://github.com/laspy/laspy). What you do is just read a point cloud into a python 2D list, and pass it to CSF.
The following example shows how to use it with laspy.# coding: utf-8importlaspyimportCSFimportnumpyasnpinFile=laspy.read(r"in.las")# read a las filepoints=inFile.pointsxyz=np.vstack((inFile.x,inFile.y,inFile.z)).transpose()# extract x, y, z and put into a listcsf=CSF.CSF()# prameter settingscsf.params.bSloopSmooth=Falsecsf.params.cloth_resolution=0.5# more details about parameter: http://ramm.bnu.edu.cn/projects/CSF/download/csf.setPointCloud(xyz)ground=CSF.VecInt()# a list to indicate the index of ground points after calculationnon_ground=CSF.VecInt()# a list to indicate the index of non-ground points after calculationcsf.do_filtering(ground,non_ground)# do actual filtering.outFile=laspy.LasData(inFile.header)outFile.points=points[np.array(ground)]# extract ground points, and save it to a las file.out_file.write(r"out.las")Reading data from txt file:If the lidar data is stored in txt file (x y z for each line), it can also be imported directly.importCSFcsf=CSF.CSF()csf.readPointsFromFile('samp52.txt')csf.params.bSloopSmooth=Falsecsf.params.cloth_resolution=0.5ground=CSF.VecInt()# a list to indicate the index of ground points after calculationnon_ground=CSF.VecInt()# a list to indicate the index of non-ground points after calculationcsf.do_filtering(ground,non_ground)# do actual filtering.csf.savePoints(ground,"ground.txt")How to use CSF in PythonDownload the source code. under python folder:pythonsetup.pybuildpythonsetup.pyinstallHow to use CSF in Matlabsee more details from filedemo_mex.munder matlab folder.How to use CSF in RThanks to the nice work of @Jean-Romain, through the collaboration, the CSF has been made as a R package, the details can be found in theRCSF repository. This package can be used easily with thelidR package:library(lidR)las<-readLAS("file.las")las<-lasground(las,csf())How to use CSF in C++Now, CSF is built by CMake, it produces a static library, which can be used by other c++ programs.linuxTo build the library, run:mkdirbuild#or other namecdbuild
cmake..
make
sudomakeinstallor if you want to build the library and the demo executablecsfdemomkdirbuild#or other namecdbuild
cmake-DBUILD_DEMO=ON..
make
sudomakeinstallWindowsYou can use CMake GUI to generate visual studio solution file.Binary VersionFor binary release version, it can be downloaded at:http://ramm.bnu.edu.cn/projects/CSF/download/Note: This code has been changed a lot since the publication of the corresponding paper. A lot of optimizations have been made. We are still working on it, and wish it could be better.Cloudcompare PulginAt last, if you are interested in Cloudcompare, there is a good news. our method has been implemented as a Cloudcompare plugin, you can refer to :https://github.com/cloudcompare/trunkRelated projectA tool namedCSFToolshas been recently released, it is based on CSF, and provides dem/chm generation, normalization. Please refer to:https://github.com/jianboqi/CSFToolsLicenseCSF is maintained and developed by Jianbo QI. It is now released under Apache 2.0.