Skip to main content

CSF: Ground Filtering based on Cloth Simulation

Project description

csf1 csf2

CSF

Airborne 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)

This is a modified version of the original Code for 3DFin purposes

For now this is only intended to be used inside 3DFin/dendromatics. But this repository also serve as a playground to bootstrap a planned full rewrite of CSF.

List of changes:

  • Better handling of numpy arrays in the python bindings (avoid expensive copies)
  • Bug fixes and improvement (mostly backport from CloudCompare version of CSF and original ones)
  • Better (but yet to be improved) documentation and code structure.

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-8
import laspy
import CSF
import numpy as np

inFile = laspy.read(r"in.las") # read a las file
points = inFile.points
xyz = np.vstack((inFile.x, inFile.y, inFile.z)).transpose() # extract x, y, z and put into a list

csf = CSF.CSF()

# prameter settings
csf.params.bSloopSmooth = False
csf.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 calculation
non_ground = CSF.VecInt() # a list to indicate the index of non-ground points after calculation
csf.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.

import CSF

csf = CSF.CSF()
csf.readPointsFromFile('samp52.txt')

csf.params.bSloopSmooth = False
csf.params.cloth_resolution = 0.5

ground = CSF.VecInt()  # a list to indicate the index of ground points after calculation
non_ground = CSF.VecInt() # a list to indicate the index of non-ground points after calculation
csf.do_filtering(ground, non_ground) # do actual filtering.
csf.savePoints(ground,"ground.txt")

How to use CSF in Python

Thanks to @rjanvier's contribution. Now we can install CSF from pip as:

pip install cloth-simulation-filter

How to use CSF in Matlab

see more details from file demo_mex.m under matlab folder.

How to use CSF in R

Thanks 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 the RCSF repository. This package can be used easily with the lidR 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.

linux

To build the library, run:

mkdir build #or other name
cd build
cmake ..
make
sudo make install

or if you want to build the library and the demo executable csfdemo

mkdir build #or other name
cd build
cmake -DBUILD_DEMO=ON ..
make
sudo make install

Windows

You can use CMake GUI to generate visual studio solution file.

Binary Version

For 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 Pulgin

At 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/trunk

Related project

A tool named CSFTools has been recently released, it is based on CSF, and provides dem/chm generation, normalization. Please refer to: https://github.com/jianboqi/CSFTools

License

CSF is maintained and developed by Jianbo QI. It is now released under Apache 2.0.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

CSF_3DFin-1.3.0.tar.gz (938.1 kB view hashes)

Uploaded Source

Built Distributions

CSF_3DFin-1.3.0-cp312-cp312-win_amd64.whl (128.7 kB view hashes)

Uploaded CPython 3.12 Windows x86-64

CSF_3DFin-1.3.0-cp312-cp312-win32.whl (103.4 kB view hashes)

Uploaded CPython 3.12 Windows x86

CSF_3DFin-1.3.0-cp312-cp312-musllinux_1_1_x86_64.whl (2.0 MB view hashes)

Uploaded CPython 3.12 musllinux: musl 1.1+ x86-64

CSF_3DFin-1.3.0-cp312-cp312-musllinux_1_1_i686.whl (2.0 MB view hashes)

Uploaded CPython 3.12 musllinux: musl 1.1+ i686

CSF_3DFin-1.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.5 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

CSF_3DFin-1.3.0-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl (1.5 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ i686

CSF_3DFin-1.3.0-cp312-cp312-macosx_10_9_x86_64.whl (163.1 kB view hashes)

Uploaded CPython 3.12 macOS 10.9+ x86-64

CSF_3DFin-1.3.0-cp311-cp311-win_amd64.whl (129.3 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

CSF_3DFin-1.3.0-cp311-cp311-win32.whl (102.9 kB view hashes)

Uploaded CPython 3.11 Windows x86

CSF_3DFin-1.3.0-cp311-cp311-musllinux_1_1_x86_64.whl (2.0 MB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.1+ x86-64

CSF_3DFin-1.3.0-cp311-cp311-musllinux_1_1_i686.whl (2.0 MB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.1+ i686

CSF_3DFin-1.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.5 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

CSF_3DFin-1.3.0-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl (1.5 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ i686

CSF_3DFin-1.3.0-cp311-cp311-macosx_10_9_x86_64.whl (162.0 kB view hashes)

Uploaded CPython 3.11 macOS 10.9+ x86-64

CSF_3DFin-1.3.0-cp310-cp310-win_amd64.whl (129.3 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

CSF_3DFin-1.3.0-cp310-cp310-win32.whl (102.8 kB view hashes)

Uploaded CPython 3.10 Windows x86

CSF_3DFin-1.3.0-cp310-cp310-musllinux_1_1_x86_64.whl (2.0 MB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.1+ x86-64

CSF_3DFin-1.3.0-cp310-cp310-musllinux_1_1_i686.whl (2.0 MB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.1+ i686

CSF_3DFin-1.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.5 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

CSF_3DFin-1.3.0-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl (1.5 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ i686

CSF_3DFin-1.3.0-cp310-cp310-macosx_10_9_x86_64.whl (162.0 kB view hashes)

Uploaded CPython 3.10 macOS 10.9+ x86-64

CSF_3DFin-1.3.0-cp39-cp39-win_amd64.whl (129.3 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

CSF_3DFin-1.3.0-cp39-cp39-win32.whl (102.7 kB view hashes)

Uploaded CPython 3.9 Windows x86

CSF_3DFin-1.3.0-cp39-cp39-musllinux_1_1_x86_64.whl (2.0 MB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.1+ x86-64

CSF_3DFin-1.3.0-cp39-cp39-musllinux_1_1_i686.whl (2.0 MB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.1+ i686

CSF_3DFin-1.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.5 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

CSF_3DFin-1.3.0-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl (1.5 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ i686

CSF_3DFin-1.3.0-cp39-cp39-macosx_10_9_x86_64.whl (162.0 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page