I get a strange behavior when displaying an image in vtk.
At random the image displays horizontal lines when being displayed.
Has anybody encountered this bug before.
The code (slightly stripped) looks like this:
// CWndVTK* m_pWndVTK; //Initialized elswhere
vtkSmartPointer table = vtkSmartPointer::New();
table->SetRange(0, 255); // image intensity range
table->SetValueRange(0.0, 1.0); // from black to white
table->SetSaturationRange(0.0, 0.0); // no color saturation
table->SetRampToLinear();
table->Build();
vtkSmartPointer m_imgActor_0 = vtkSmartPointer::New();
vtkSmartPointer imgImport_0 = vtkSmartPointer::New();
vtkSmartPointer color_0 = vtkSmartPointer::New();
Size imageSize = Size(m_image_width, m_image_height);
void* imageBuffer_0 = malloc(m_image_width * m_image_height * sizeof(unsigned short));
imgImport_0->SetDataScalarTypeToUnsignedShort();
image_data_size = m_image_width * m_image_height * sizeof(unsigned short);
imgImport_0->CopyImportVoidPointer( imageBuffer_0, image_data_size );
imgImport_0->SetWholeExtent(0, m_image_width - 1, 0, m_image_height - 1, 0, 0);
imgImport_0->SetDataExtentToWholeExtent();
imgImport_0->UpdateWholeExtent();
imgImport_0->Update();
color_0->SetLookupTable(table);
color_0->SetInputConnection (imgImport_0->GetOutputPort());
color_0->Update();
m_imgActor_0->GetMapper()->SetInputConnection(imgImport_0->GetOutputPort());
m_imgActor_0->GetMapper()->SetInputConnection(color_0->GetOutputPort());
// Get data to display transform
CoordinateSystem^ cs = m_pWndVTK->displayTransform->ConvertFrom(dsImgMap->CoordinateSystem);
double* p = &(ForwardAffineMatrix);
// Move plane one hundredth of a pixel back, such that 3d objects in the same plane are not clipped by the image
p[11] -= Math::Abs(p[0]) / 100;
// Apply transform
vtkSmartPointer imageGridToDisplayTransform = vtkSmartPointer::New();
imageGridToDisplayTransform->SetMatrix(p);
m_imgActor_0->SetUserTransform(imageGridToDisplayTransform);
m_imgActor_0->SetInterpolate(m_info->useInterpolation);
m_imgActor_0->Update();
m_imgActor_0->Render(m_pWndVTK->GetRenderWindow()->GetRenderers()->GetFirstRenderer());
vtkSmartPointer colorTransferFunction = vtkSmartPointer::New();
for (int i = 0; i < paletteColors->Length; i++)
{
rgba[0] = paletteColors[i].R / 255.0f;
rgba[1] = paletteColors[i].G / 255.0f;
rgba[2] = paletteColors[i].B / 255.0f;
colorTransferFunction->AddRGBPoint(lookupHandler->GetLookupTableValueValue(i), rgba[0], rgba[1], rgba[2]);
}
color_0->SetLookupTable(colorTransferFunction);
m_pWndVTK->GetRenderWindow()->Render();