{
 "id": "cloth-simulation-filter",
 "title": "Cloth Simulation Filter (CSF) for LiDAR Ground Filtering",
 "aliases": [
  "CSF"
 ],
 "domain": "capture",
 "subdomain": "LiDAR processing",
 "stage": "capture",
 "realtime": "offline",
 "platforms": [
  "cpu",
  "python"
 ],
 "year_introduced": 2016,
 "inputs": [
  "point-cloud"
 ],
 "outputs": [
  "point-cloud",
  "heightfield"
 ],
 "style": "photoreal",
 "dynamic": "static",
 "summary": "Separates ground from non-ground points in an airborne LiDAR cloud by inverting the cloud and draping a simulated cloth over it; points near the cloth are ground.",
 "how_it_works": "The point cloud is flipped upside down, and a regular grid of cloth particles, connected by springs, is dropped onto it. Each particle moves under gravity until it would touch a LiDAR point beneath it, at which point it stops. Neighbouring particles are pulled toward each other by internal forces that depend on the cloth rigidness, which stops the cloth from falling into small gaps or following buildings and trees. After a fixed number of iterations the cloth approximates the terrain surface. Original points are classified as ground when their distance to the cloth is below a threshold. Only a few parameters are needed: grid resolution, rigidness, time step and the distance threshold.",
 "when_to_use": "Choose it when you need a ground/non-ground split of airborne or terrestrial LiDAR or photogrammetric point clouds, for DTM extraction or object removal. Prefer progressive morphological or TIN-densification filters for dense, steep, urban terrain with hand-tuned parameters, and learned segmenters when labels exist.",
 "cost": {
  "class": "offline",
  "notes": "Roughly linear in number of points and grid cells; runs on CPU in seconds to minutes for tiles."
 },
 "failure_modes": [
  "Steep slopes and terraces get classified as non-ground if rigidness is too high",
  "Low vegetation and cars are retained as ground when the distance threshold is too loose",
  "Large flat roofs may be partly absorbed as ground with a soft cloth",
  "Grid resolution too coarse smooths away small terrain features like ditches"
 ],
 "sources": [
  {
   "role": "primary",
   "key": "doi:10.3390/rs8060501",
   "type": "paper",
   "title": "An Easy-to-Use Airborne LiDAR Data Filtering Method Based on Cloth Simulation",
   "authors": [
    "Wuming Zhang",
    "Jianbo Qi",
    "Peng Wan",
    "Hongtao Wang",
    "Donghui Xie",
    "Xiaoyan Wang",
    "Guangjian Yan"
   ],
   "year": 2016,
   "venue": "Remote Sensing",
   "url": "https://doi.org/10.3390/rs8060501",
   "ids": {
    "doi": "10.3390/rs8060501"
   },
   "license": null,
   "extra": {
    "csl_type": "journal-article"
   },
   "provenance": {
    "title": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.3390/rs8060501",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.3390/rs8060501",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.3390/rs8060501",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.3390/rs8060501",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.3390/rs8060501",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": 1,
   "__bib": "zhang2016easy"
  },
  {
   "role": "implementation",
   "key": "gh:jianboqi/csf",
   "type": "code",
   "title": "jianboqi/CSF",
   "description": "LiDAR point cloud ground filtering / segmentation (bare earth extraction) method based on cloth simulation",
   "authors": [
    "jianboqi"
   ],
   "year": 2016,
   "venue": "GitHub",
   "url": "https://github.com/jianboqi/CSF",
   "ids": {
    "repo": "jianboqi/CSF"
   },
   "license": "Apache-2.0",
   "extra": {
    "stars": 658,
    "stars_checked": "2026-11-29",
    "archived": false,
    "fork": false,
    "pushed_at": "2026-09-11T23:06:04Z",
    "language": "C++",
    "homepage": "http://ramm.bnu.edu.cn/projects/CSF/",
    "license_name": "Apache License 2.0"
   },
   "provenance": {
    "title": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/jianboqi/CSF",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/jianboqi/CSF",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/jianboqi/CSF",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/jianboqi/CSF",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/jianboqi/CSF",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "license": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/jianboqi/CSF",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": null,
   "__bib": "jianboqi2016jianboqi"
  }
 ],
 "presets": [
  {
   "id": "csf-default-parameters",
   "title": "CSF default parameters",
   "runtime": "json-params",
   "params": {
    "cloth_resolution": 0.5,
    "rigidness": 3,
    "time_step": 0.65,
    "class_threshold": 0.5,
    "iterations": 500,
    "slope_smooth": true
   },
   "basis": "original",
   "license_note": "Parameter names follow jianboqi/CSF (Apache-2.0); values are the library's commonly used defaults, written for this index.",
   "execution_fidelity": "parameter-only",
   "proof": {
    "kind": "parameter",
    "label": "parameter preset",
    "ok": true,
    "proof": null
   }
  },
  {
   "id": "cloth-simulation-filter-live",
   "title": "Cloth Simulation Filter (CSF) — inverted LiDAR cloth drape (left) vs classified ground & objects (right)",
   "runtime": "glsl-fragment",
   "params": {
    "P_RIGIDNESS": 0.72,
    "P_CLASS_THRESH": 0.07,
    "P_SWEEP": 0.45,
    "P_SPLIT": 0.48
   },
   "basis": "original",
   "license_note": "MIT — written for this index.",
   "code": "const float P_RIGIDNESS = 0.72; // P Cloth Rigidness [0.1, 1.0, 0.02]\nconst float P_CLASS_THRESH = 0.07; // P Ground Threshold [0.02, 0.16, 0.005]\nconst float P_SWEEP = 0.45; // P Scan Pan [0.0, 2.0, 0.05]\nconst float P_SPLIT = 0.48; // P Inverted CSF / Class [0.0, 1.0, 0.02]\n\nfloat hash11(float x) {\n  x = fract(x * 0.1031);\n  x *= x + 33.33;\n  x *= x + x;\n  return fract(x);\n}\n\n// True rolling ground elevation y_ground(x)\nfloat groundY(float x) {\n  return -0.18 + 0.09 * sin(x * 3.2) + 0.045 * cos(x * 6.5 + 0.7);\n}\n\n// Airborne LiDAR surface height including buildings & tree crowns above the ground\nfloat lidarTopY(float x) {\n  float g = groundY(x);\n  // Building 1\n  if (abs(x + 0.42) < 0.13) return g + 0.28;\n  // Building 2 (stepped roof)\n  if (abs(x - 0.36) < 0.15) return g + 0.24 + 0.06 * step(0.32, x);\n  // Tree canopy 1\n  float t1 = abs(x + 0.08);\n  if (t1 < 0.11) return g + 0.22 * sqrt(max(1.0 - (t1 / 0.11) * (t1 / 0.11), 0.0)) + 0.05 * sin(x * 80.0);\n  // Tree canopy 2\n  float t2 = abs(x - 0.66);\n  if (t2 < 0.09) return g + 0.19 * sqrt(max(1.0 - (t2 / 0.09) * (t2 / 0.09), 0.0));\n  return g;\n}\n\n// Simulated draped cloth height over inverted LiDAR (stiff cloth bridges over inverted buildings/trees!)\nfloat clothY(float x, float rigid) {\n  float g = groundY(x);\n  // Low rigidness lets cloth sag slightly into building/tree pits; high rigidness stays tightly bridged on ground\n  float sag = (1.0 - rigid) * 0.12;\n  float b1 = smoothstep(0.14, 0.0, abs(x + 0.42)) * sag;\n  float b2 = smoothstep(0.16, 0.0, abs(x - 0.36)) * sag;\n  float tr = smoothstep(0.12, 0.0, abs(x + 0.08)) * sag * 0.8;\n  return g + (b1 + b2 + tr);\n}\n\nvec3 aces(vec3 x) {\n  x = max(x, 0.0);\n  return (x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14);\n}\n\nvoid mainImage(out vec4 fragColor, in vec2 fragCoord) {\n  vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;\n  float screenX = fragCoord.x / max(iResolution.x, 1.0);\n  float split = clamp(P_SPLIT, 0.0, 1.0);\n  bool isInverted = screenX < split;\n  float rigid = clamp(P_RIGIDNESS, 0.05, 1.0);\n  float thresh = clamp(P_CLASS_THRESH, 0.015, 0.20);\n  float pan = sin(iTime * 0.45 * max(P_SWEEP, 0.0)) * 0.16;\n\n  // Blueprint engineering grid backdrop\n  vec3 col = mix(vec3(0.024, 0.034, 0.056), vec3(0.054, 0.072, 0.112), smoothstep(-0.5, 0.5, uv.y));\n  vec2 g1 = abs(fract(uv * 10.0 - 0.5) - 0.5);\n  col += vec3(0.018, 0.028, 0.044) * smoothstep(0.035, 0.008, min(g1.x, g1.y));\n\n  // Left half shows the INVERTED LiDAR cloud (y -> -y) with gravity cloth draping down from above!\n  // Right half shows the UPRIGHT classified point cloud (cyan = ground, amber/green = non-ground)\n  float xWorld = uv.x + pan;\n  float yEval = isInverted ? -uv.y : uv.y;\n\n  float cY = clothY(xWorld, rigid);\n  float dCloth = abs(yEval - cY);\n\n  // Draw threshold tolerance band around the simulated cloth surface\n  float inBand = smoothstep(thresh + 0.004, thresh - 0.004, abs(yEval - cY));\n  col = mix(col, vec3(0.12, 0.52, 0.68), inBand * 0.22);\n\n  // Draw the cloth curve + cloth particle nodes\n  float clothLine = smoothstep(0.008, 0.002, dCloth);\n  float nodeX = fract(xWorld * 18.0 + 0.5) - 0.5;\n  float dNode = length(vec2(nodeX / 18.0, yEval - cY));\n  float clothNode = smoothstep(0.012, 0.005, dNode);\n  vec3 clothCol = isInverted ? vec3(0.98, 0.78, 0.24) : vec3(0.24, 0.88, 0.96);\n  col = mix(col, clothCol, max(clothLine * 0.9, clothNode));\n\n  // Render discrete airborne LiDAR return points sampled along x\n  float stepX = 0.022;\n  float ix = floor(xWorld / stepX);\n  for (int k = -1; k <= 1; k++) {\n    float cx = (ix + float(k) + 0.5) * stepX;\n    float topY = lidarTopY(cx);\n    float gY = groundY(cx);\n    float clY = clothY(cx, rigid);\n\n    // Primary LiDAR top return point\n    float jit = (hash11(ix + float(k) * 1.7) - 0.5) * 0.012;\n    float py = topY + jit;\n    float distPt = length(vec2(xWorld - cx, yEval - py));\n    float ptMask = smoothstep(0.012, 0.004, distPt);\n    bool isGroundPt = abs(py - clY) < thresh;\n    vec3 ptCol = isGroundPt\n      ? vec3(0.18, 0.90, 0.86) // Ground point\n      : (py - gY > 0.23 ? vec3(0.98, 0.44, 0.22) : vec3(0.42, 0.92, 0.34)); // Building vs tree\n    col = mix(col, ptCol * 1.15, ptMask);\n\n    // Vertical wall / trunk returns for buildings & canopies\n    if (topY - gY > 0.08) {\n      for (int r = 1; r <= 3; r++) {\n        float ry = mix(gY + 0.03, topY - 0.02, float(r) / 4.0) + (hash11(cx * 31.0 + float(r)) - 0.5) * 0.015;\n        float dR = length(vec2(xWorld - cx, yEval - ry));\n        float mR = smoothstep(0.009, 0.003, dR);\n        bool rGrd = abs(ry - clY) < thresh;\n        vec3 rCol = rGrd ? vec3(0.18, 0.90, 0.86) : vec3(0.95, 0.58, 0.22);\n        col = mix(col, rCol, mR * 0.85);\n      }\n    }\n  }\n\n  // Gravity arrow indicator on left inverted side\n  if (isInverted) {\n    vec2 aP = uv - vec2(-0.34, 0.30);\n    float shaft = smoothstep(0.005, 0.001, abs(aP.x)) * smoothstep(0.07, 0.06, abs(aP.y));\n    float head = smoothstep(0.006, 0.001, abs(abs(aP.x) - (aP.y + 0.075) * 0.65)) * step(aP.y, -0.02) * step(-0.08, aP.y);\n    col += vec3(0.98, 0.78, 0.24) * max(shaft, head) * 0.85;\n  }\n\n  float sep = smoothstep(0.0035, 0.0008, abs(screenX - split));\n  col = mix(col, vec3(0.95, 0.97, 1.0), sep);\n\n  fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);\n}",
   "execution_fidelity": "conceptual-diagram",
   "proof": {
    "kind": "rendered",
    "label": "rendered 2026-11-30",
    "ok": true,
    "proof": {
     "ok": true,
     "technique": "cloth-simulation-filter",
     "runtime": "glsl-fragment",
     "checked_at": "2026-11-30T20:35:46.000Z",
     "renderer": "Headless EGL Tesla T4/PCIe/SSE2, OpenGL 3.30 Core, 512×512, iTime=1.5",
     "stats": {
      "mean": 0.3041,
      "std": 0.1354,
      "min": 0.1808,
      "max": 0.929
     },
     "image": "/specimens/cloth-simulation-filter-live.webp",
     "reason": null
    }
   }
  }
 ],
 "related": [
  "multi-view-stereo-patchmatch",
  "structure-from-motion-colmap"
 ],
 "extends": [],
 "supersedes": [],
 "combines_with": [
  {
   "id": "multi-view-stereo-patchmatch",
   "why": "Dense photogrammetric point clouds are filtered by CSF to extract a terrain model."
  }
 ],
 "provenance": {
  "prose": "original text written for this index (research draft, editorially reviewed)",
  "sources_verified_at": "2026-11-29T15:51:27.588Z",
  "draft": "data/drafts/capture/cloth-simulation-filter.json"
 },
 "solves": [
  "separate ground points from trees and buildings in lidar",
  "need a terrain model from an airborne point cloud",
  "remove objects to get bare earth from scan data",
  "classify ground versus non-ground in photogrammetry points",
  "ground extraction with few parameters to tune"
 ],
 "authority": "Zhang et al., 2016",
 "url": "https://texelatlas.vercel.app/t/cloth-simulation-filter/",
 "execution_fidelity": "conceptual-diagram",
 "fidelity_label": "Visual Diagram",
 "benchmark_eligible": false,
 "gpu_weight": {
  "weight_x": 10.16,
  "tier": "moderate",
  "p50_ms": 0.3344,
  "p95_ms": 0.3355,
  "baseline_p50_ms": 0.0329,
  "gpu": "Tesla T4/PCIe/SSE2",
  "resolution": "1920x1080",
  "method": "opengl-timer-query",
  "frames": 32,
  "preset_id": "cloth-simulation-filter-live",
  "execution_fidelity": "conceptual-diagram",
  "fidelity_label": "Visual Diagram",
  "benchmark_eligible": false,
  "generated_at": "2026-11-30T21:07:47Z",
  "l4": {
   "weight_x": 8.32,
   "tier": "moderate",
   "p50_ms": 0.1323,
   "p95_ms": 0.1333,
   "speedup_x": 2.53,
   "gpu": "NVIDIA L4/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0159
  },
  "a100": {
   "weight_x": 7.57,
   "tier": "moderate",
   "p50_ms": 0.2179,
   "p95_ms": 0.2184,
   "speedup_x": 1.53,
   "gpu": "NVIDIA A100-SXM4-40GB/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0288
  }
 }
}