# Unable to render image

**URL:** https://discourse.vtk.org/t/unable-to-render-image/2598
**Category:** Support
**Created:** [February 12, 2020, 9:47pm UTC](https://discourse.vtk.org/t/unable-to-render-image/2598 "2020-02-12T21:47:20Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Tracy\_Nk](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/t/90ced4/32.png) [@Tracy\_Nk](https://discourse.vtk.org/u/Tracy_Nk)
#### Post date: [February 12, 2020, 9:47pm UTC](https://discourse.vtk.org/t/unable-to-render-image/2598/1 "2020-02-12T21:47:20Z")

</div>

Here is an example code i’m using:

#include vtkSmartPointer.h  
#include vtkDataArray.h  
#include vtkImageData.h  
#include vtkImageViewer2.h  
#include vtkDICOMImageReader.h  
#include vtkPointData.h  
#include vtkRenderWindow.h  
#include vtkRenderWindowInteractor.h  
#include vtkRenderer.h

int main(int argc, char argv[])  
{  
Verify input arguments  
if ( argc != 2 )  
{  
stdcout Usage argv[0]  
Filename(.img) stdendl;  
return EXIT\_FAILURE;  
}

stdstring inputFilename = argv[1];

Read all the DICOM files in the specified directory.  
auto reader = vtkSmartPointervtkDICOMImageReaderNew();  
reader-SetFileName(inputFilename.c\_str());  
reader-Update();

auto image = reader-GetOutput();  
double range = image-GetPointData()-GetScalars()-GetRange();

Visualize  
auto imageViewer = vtkSmartPointervtkImageViewer2New();  
imageViewer-SetInputConnection(reader-GetOutputPort());  
auto renderWindowInteractor =  
vtkSmartPointervtkRenderWindowInteractorNew();  
imageViewer-SetColorLevel(0.5 (range[0] + range[1]));  
imageViewer-SetColorWindow(range[1] - range[0]);  
imageViewer-SetupInteractor(renderWindowInteractor);  
imageViewer-GetRenderer()-ResetCamera();  
imageViewer-Render();

renderWindowInter  
actor-Start();

return EXIT\_SUCCESS;  
}

This configures, generates, and built fine. However when i attempt to open the file from the command prompt as shown:

 ![image](https://discourse.vtk.org/uploads/default/original/2X/0/043c983a4c9676b980ebcf6cc1df88ef7a5625f4.png)

It produces this output:

 ![image](https://discourse.vtk.org/uploads/default/original/2X/b/b789fb35ccf537c64cec061e0a735af7b1b5ac22.png)

In the anonymized folder there are about 200+ dicom files. Please help me to understand why i’m getting this error.

---

<div class="post-metadata">

### Author: ![kaaonline](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/k/8c91f0/32.png) [@kaaonline](https://discourse.vtk.org/u/kaaonline)
#### Post date: [February 14, 2020, 9:21am UTC](https://discourse.vtk.org/t/unable-to-render-image/2598/2 "2020-02-14T09:21:58Z")

</div>

Yeah I’m having the same problem!

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [February 17, 2020, 11:10am UTC](https://discourse.vtk.org/t/unable-to-render-image/2598/3 "2020-02-17T11:10:14Z")

</div>

Hello, firend,

First, please, edit your post so we can get your code right. Re-post it between two sets of ````` to get something like this:

```auto
void helloVTK(int param0, bool param1){
    //hello there! 
   std::cout << "Code is a lot easier to read when you use markdown! ;-)" << std::endl;
   exit(0);
}

```

all the best,

Paulo
