# Does anyone know how to extract human skin?(about skin.py)

**URL:** <https://discourse.slicer.org/t/does-anyone-know-how-to-extract-human-skin-about-skin-py/22262>\
**Category:** Development\
**Tags:** build, segmentation, dicom, python, 3d-model\
**Created:** [March 2, 2022, 2:11pm UTC](https://discourse.slicer.org/t/does-anyone-know-how-to-extract-human-skin-about-skin-py/22262 "2022-03-02T14:11:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![zhuyingxinxs](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/zhuyingxinxs/32/13663_2.png) [@zhuyingxinxs](https://discourse.slicer.org/u/zhuyingxinxs)\
**Post date:** [March 2, 2022, 2:11pm UTC](https://discourse.slicer.org/t/does-anyone-know-how-to-extract-human-skin-about-skin-py/22262/1 "2022-03-02T14:11:01Z")

</div>

I found the code for extracting skin in the following url,But how do I import my own DICOM data instead of using the MRHEAD example?

> <https://gist.github.com/lassoan/1673b25d8e7913cbc245b4f09ed853f9>

---

<div class="post-metadata">

**Author:** ![Chuan](https://avatars.discourse-cdn.com/v4/letter/c/4da419/32.png) [@Chuan](https://discourse.slicer.org/u/Chuan)\
**Post date:** [October 9, 2023, 5:19pm UTC](https://discourse.slicer.org/t/does-anyone-know-how-to-extract-human-skin-about-skin-py/22262/2 "2023-10-09T17:19:05Z")

</div>

Hi Yingxin

Did you solve it? I need to extract skin from CT images, not sure whether we have the same problem.

Best regards,  
Chuan

---

<div class="post-metadata">

**Author:** ![slicer365](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/slicer365/32/67549_2.png) [@slicer365](https://discourse.slicer.org/u/slicer365)\
**Post date:** [October 9, 2023, 11:09pm UTC](https://discourse.slicer.org/t/does-anyone-know-how-to-extract-human-skin-about-skin-py/22262/3 "2023-10-09T23:09:58Z")

</div>

Open the python console  
change the following code to your data name,

and then paste it in the console to run.

```auto
masterVolumeNode = slicer.util.getNode('你自己的数据名称')

segmentationNode = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLSegmentationNode")
segmentationNode.CreateDefaultDisplayNodes() # 用于展示
segmentationNode.SetReferenceImageGeometryParameterFromVolumeNode(masterVolumeNode)
addedSegmentID = segmentationNode.GetSegmentation().AddEmptySegment("skin")

segmentEditorWidget = slicer.qMRMLSegmentEditorWidget()
segmentEditorWidget.setMRMLScene(slicer.mrmlScene)
segmentEditorNode = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLSegmentEditorNode")
segmentEditorWidget.setMRMLSegmentEditorNode(segmentEditorNode)
segmentEditorWidget.setSegmentationNode(segmentationNode)
segmentEditorWidget.setMasterVolumeNode(masterVolumeNode)

segmentEditorWidget.setActiveEffectByName("Threshold")
effect = segmentEditorWidget.activeEffect()
effect.setParameter("MinimumThreshold","35")
effect.setParameter("MaximumThreshold","695")
effect.self().onApply()

# 平滑
segmentEditorWidget.setActiveEffectByName("Smoothing")
effect = segmentEditorWidget.activeEffect()
effect.setParameter("SmoothingMethod", "MEDIAN")
effect.setParameter("KernelSizeMm", 11)
effect.self().onApply()

segmentEditorWidget = None
slicer.mrmlScene.RemoveNode(segmentEditorNode)

segmentationNode.CreateClosedSurfaceRepresentation()

```

[https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/1/4/14f2dae62cf293a3499c8b7772111a8f8820f497.mp4](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/1/4/14f2dae62cf293a3499c8b7772111a8f8820f497.mp4)
