# vtkMarchingCubes & vtkImageThreshold generate noticeable staircase-like textures

**URL:** https://discourse.vtk.org/t/vtkmarchingcubes-vtkimagethreshold-generate-noticeable-staircase-like-textures/15525
**Category:** Support
**Tags:** code
**Created:** [April 21, 2025, 8:30am UTC](https://discourse.vtk.org/t/vtkmarchingcubes-vtkimagethreshold-generate-noticeable-staircase-like-textures/15525 "2025-04-21T08:30:28Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![yangyang117](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/y/da6949/32.png) [@yangyang117](https://discourse.vtk.org/u/yangyang117)
#### Post date: [April 21, 2025, 8:30am UTC](https://discourse.vtk.org/t/vtkmarchingcubes-vtkimagethreshold-generate-noticeable-staircase-like-textures/15525/1 "2025-04-21T08:30:28Z")

</div>

After reading the CT data, if I use `vtkImageThreshold` for threshold segmentation and then use `vtkMarchingCubes` to generate the `polydata`, the resulting `polydata` has very noticeable staircase-like textures. However, when I directly use `vtkMarchingCubes`, the generated `polydata` is relatively smooth. I want to ask how this can be improved.

I checked the output data from `imgreader` and `vtkImageThreshold`, and the data size and format are exactly the same. If smoothing is required, the processing time is relatively long. Is there a better solution?

1. 

vtkNew marchingCubes;  
marchingCubes-\>SetInputConnection(imgReader-\>GetOutputPort());  
marchingCubes-\>SetValue(0, 500); // 设置等值面的阈值  
marchingCubes-\>Update();

 ![图片](https://discourse.vtk.org/uploads/default/original/2X/6/68ed44a775872a55f82d4650deb2e12feea1208a.jpeg)

1. 

vtkNew thresholdFilter;  
thresholdFilter-\>SetInputData(imgReader-\>GetOutput());  
thresholdFilter-\>ThresholdBetween(500.0, 9000.0); // 设置阈值范围  
thresholdFilter-\>SetInValue(100.0); // 阈值内的值设为 1.0  
thresholdFilter-\>SetOutValue(0.0); // 阈值外的值设为 0.0  
thresholdFilter-\>Update();  
vtkNew marchingCubes;  
marchingCubes-\>SetInputConnection(thresholdFilter-\>GetOutputPort());  
marchingCubes-\>SetValue(0, 50); // 设置等值面的阈值  
marchingCubes-\>Update();

 ![图片](https://discourse.vtk.org/uploads/default/original/2X/3/3e8e5e387592dded497c66dc7e729af89f6300d1.jpeg)

During the two generation processes, both used 500 as the threshold for distinction. In the first case, `marching cubes` was directly applied to the original `imagedata` for isosurface reconstruction at 500. In the second case, `vtkImageThreshold` was used to set values within the range of 500-9000 to 100, followed by applying `marching cubes` for isosurface reconstruction at 50. The results were significantly different.
