# vtkImageData rendering issue

**URL:** https://discourse.vtk.org/t/vtkimagedata-rendering-issue/5966
**Category:** Support
**Created:** [June 8, 2021, 10:32pm UTC](https://discourse.vtk.org/t/vtkimagedata-rendering-issue/5966 "2021-06-08T22:32:17Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Hyunwoo\_Kim](https://discourse.vtk.org/user_avatar/discourse.vtk.org/hyunwoo_kim/32/3465_2.png) [@Hyunwoo\_Kim](https://discourse.vtk.org/u/Hyunwoo_Kim)
#### Post date: [June 8, 2021, 10:32pm UTC](https://discourse.vtk.org/t/vtkimagedata-rendering-issue/5966/1 "2021-06-08T22:32:17Z")

</div>

* * *

# Issue

* * *

Hi,

I want to display a 2D image on my 3d view.  
So, I’m trying to use vtkImageData.  
However, when I apply scalar data and render the image data, there is no display.  
How could I fix this?

thanks.

* * *

# Source

* * *

```
// Set Data Set //
vtkImageData* dataCoronal = vtkImageData::New();
dataCoronal->SetDimensions(cxCoronalImage, 1, cyCoronalImage);
dataCoronal->SetOrigin(sx, fPosY, sz);
dataCoronal->SetSpacing(dx, 1, dx);
dataCoronal->AllocateScalars(VTK_SHORT, 1);

// Associate Data with Data Set //
vtkShortArray* scalarsCoronal = vtkShortArray::New();
scalarsCoronal->Allocate(cxCoronalImage*cyCoronalImage);
short* pBufferCoronal = scalarsCoronal->WritePointer(0,cxCoronalImage*cyCoronalImage);
short* pTempCoronal = pBufferCoronal;

int i,j;
float zPat;
for(j = cyCoronalImage-1; j >= 0; j--)
{
	zPat = (sz-ez)*j/(float)(cyCoronalImage-1) + ez;
	
	ASSERT(zPat>=sz && zPat<=ez);

	for(i = 0; i < cxCoronalImage; i++)
	{
		*pTempCoronal = m_pFullVolume->GetZOnlyLinearInterpolValue_XYIndex(i,nPos,zPat);
		pTempCoronal++;
	}
}
dataCoronal->GetPointData()->SetScalars(scalarsCoronal);

// Apply LUT //
vtkImageMapToColors* colorsCoronal = vtkImageMapToColors::New();
colorsCoronal->SetInputData(dataCoronal);
colorsCoronal->SetLookupTable(m_lut);

// Set Actor Parameters //
m_actorPlaneCoronal->SetInputData(colorsCoronal->GetOutput());
    // m_actorPlaneCoronal->SetInputData(dataCoronal);
m_actorPlaneCoronal->SetDisplayExtent(0,cxCoronalImage-1, 0,0, 0,cyCoronalImage-1);

```

* * *

# And some error like this occurred with my test code,

* * *

ERROR: In D:\Libraries\VTK\VTK 9.0.1\VTK-9.0.1\Common\ExecutionModel\vtkStreamingDemandDrivenPipeline.cxx, line 878  
vtkStreamingDemandDrivenPipeline (19681EA0): The update extent specified in the information for output port 0 on algorithm vtkTrivialProducer(169041C0) is 0 9 0 9 0 0, which is outside the whole extent 0 -1 0 -1 0 -1.

ERROR: In D:\Libraries\VTK\VTK 9.0.1\VTK-9.0.1\Common\ExecutionModel\vtkTrivialProducer.cxx, line 241  
vtkTrivialProducer (169041C0): This data object does not contain the requested extent.

* * *

# Test Code

* * *

```
vtkImageData* testImage = vtkImageData::New();
testImage->SetExtent(0, 9, 0, 9, 0, 9);
testImage->SetOrigin(0, 0, 0);
testImage->SetSpacing(1, 1, 1);
testImage->AllocateScalars(VTK_SHORT, 1);

vtkDataArray* newScalars = testImage->GetPointData()->GetScalars();

double numPts = 10 * 10 * 10;
for (int i = 0; i < numPts; i++)
{
	newScalars->SetComponent(i, 0, 1);
}

//unsigned short* VolPtr = (unsigned short*)testImage->GetScalarPointer();
//for (int i = 0; i < 100 * 100 * 100; i++)
//{
//	*VolPtr = 1;
//	*VolPtr++;
//}

vtkNew<vtkImageActor> testActor;
testActor->SetInputData(testImage);
testActor->SetDisplayExtent(0,9,0,9,0,9);
m_ren->AddActor(testActor);

```

---

<div class="post-metadata">

### Author: ![Hyunwoo\_Kim](https://discourse.vtk.org/user_avatar/discourse.vtk.org/hyunwoo_kim/32/3465_2.png) [@Hyunwoo\_Kim](https://discourse.vtk.org/u/Hyunwoo_Kim)
#### Post date: [June 9, 2021, 5:15am UTC](https://discourse.vtk.org/t/vtkimagedata-rendering-issue/5966/3 "2021-06-09T05:15:40Z")

</div>

In my Test Project, It works fine.

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

 ![image](https://discourse.vtk.org/uploads/default/original/2X/3/373c80451c7577d0127a4045aa13e3bbf80fab02.png)

However, in my original project, there is no rendered object!

And got this error  
“vtkTrivialProducer (00F15A08) : This data object does not contain the requested extent.”
