I need to generate a histogram of intensities!

Operating system:Windows
Slicer version:4.11.20210226
Expected behavior: Copy pasting the code is not working
Actual behavior: Errors are showing up