# How to use code to implement the function of colormap image and overlay two images like itksnap

**URL:** <https://discourse.itk.org/t/how-to-use-code-to-implement-the-function-of-colormap-image-and-overlay-two-images-like-itksnap/5840>\
**Category:** Uncategorized\
**Created:** [March 31, 2023, 8:17am UTC](https://discourse.itk.org/t/how-to-use-code-to-implement-the-function-of-colormap-image-and-overlay-two-images-like-itksnap/5840 "2023-03-31T08:17:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ljjiayou](https://discourse.itk.org/user_avatar/discourse.itk.org/ljjiayou/32/3211_2.png) [@ljjiayou](https://discourse.itk.org/u/ljjiayou)\
**Post date:** [March 31, 2023, 8:17am UTC](https://discourse.itk.org/t/how-to-use-code-to-implement-the-function-of-colormap-image-and-overlay-two-images-like-itksnap/5840/1 "2023-03-31T08:17:33Z")

</div>

this my code, why it goes wrong?What code should I write  
colormap = sitk.Colormap(4) # jet

mapped\_image = sitk.ScalarToRGBColormap(im1, colormap)

image\_viewer.Execute(mapped\_image)

---

<div class="post-metadata">

**Author:** ![zivy](https://discourse.itk.org/user_avatar/discourse.itk.org/zivy/32/1726_2.png) [@zivy](https://discourse.itk.org/u/zivy)\
**Post date:** [March 31, 2023, 12:40pm UTC](https://discourse.itk.org/t/how-to-use-code-to-implement-the-function-of-colormap-image-and-overlay-two-images-like-itksnap/5840/2 "2023-03-31T12:40:51Z")

</div>

Hello @ljjiayou,

Please see the SimpleITK jupyter notebooks repository, specifically [this notebook](https://github.com/InsightSoftwareConsortium/SimpleITK-Notebooks/blob/master/Python/05_Results_Visualization.ipynb), section titled **Overlay scalar image onto another via color map**.

---

<div class="post-metadata">

**Author:** ![ljjiayou](https://discourse.itk.org/user_avatar/discourse.itk.org/ljjiayou/32/3211_2.png) [@ljjiayou](https://discourse.itk.org/u/ljjiayou)\
**Post date:** [April 4, 2023, 3:28am UTC](https://discourse.itk.org/t/how-to-use-code-to-implement-the-function-of-colormap-image-and-overlay-two-images-like-itksnap/5840/3 "2023-04-04T03:28:30Z")

</div>

thank you very much
