[vtkusers] vtkImageGradient extent problem
Dean Inglis
dean.inglis at camris.ca
Fri Apr 16 15:08:55 EDT 2004
FYI: well, here is an awkward way to do it:
m_clip->SetOutputWholeExtent(m_imageActor()->GetDisplayExtent());
m_clip->UpdateWholeExtent();
vtkImagePermute* permute1 = vtkImagePermute::New();
switch(m_spline->GetProjectionNormal())
{
case 0: permute1->SetFilteredAxes(1,2,0); break;
case 1: permute1->SetFilteredAxes(2,0,1); break;
case 2: permute1->SetFilteredAxes(0,1,2); break;
}
permute1->SetInput(m_clip->GetOutput());
permute1->UpdateWholeExtent();
// we have to trick vtkImageGradient into thinking it has
// an x-y image by permuting axes
m_grad->SetInput(permute1->GetOutput());
m_grad->UpdateWholeExtent();
// then add zeros to make a 3 component gradient vector
vtkImageConstantPad* pad = vtkImageConstantPad::New();
pad->SetOutputNumberOfScalarComponents(3);
pad->SetOutputWholeExtent(m_grad->GetOutput()->GetWholeExtent());
pad->SetConstant(0.0);
pad->SetInput(m_grad->GetOutput());
pad->UpdateWholeExtent();
// do the reverse permutation, which doesn't permute the components
vtkImagePermute* permute2 = vtkImagePermute::New();
switch(m_spline->GetProjectionNormal())
{
case 0: permute2->SetFilteredAxes(2,0,1); break;
case 1: permute2->SetFilteredAxes(1,2,0); break;
case 2: permute2->SetFilteredAxes(0,1,2); break;
}
permute2->SetInput(pad->GetOutput());
permute2->UpdateWholeExtent();
// now extract and permute the gradient vector components
int cu,cv,cw;
switch(m_spline->GetProjectionNormal())
{
case 0: cu = 2; cv = 0; cw = 1; break;
case 1: cu = 1; cv = 2; cw = 0; break;
case 2: cu = 0; cv = 1; cw = 2; break;
}
vtkImageExtractComponents* extract1 = vtkImageExtractComponents::New();
extract1->SetComponents(cu);
extract1->SetInput(permute2->GetOutput());
extract1->UpdateWholeExtent();
vtkImageExtractComponents* extract2 = vtkImageExtractComponents::New();
extract2->SetComponents(cv);
extract2->SetInput(permute2->GetOutput());
extract2->UpdateWholeExtent();
vtkImageExtractComponents* extract3 = vtkImageExtractComponents::New();
extract3->SetComponents(cw);
extract3->SetInput(permute2->GetOutput());
extract3->UpdateWholeExtent();
vtkImageAppendComponents* append1 = vtkImageAppendComponents::New();
append1->AddInput(extract1->GetOutput());
append1->AddInput(extract2->GetOutput());
append1->UpdateWholeExtent();
vtkImageAppendComponents* append2 = vtkImageAppendComponents::New();
append2->AddInput(append1->GetOutput());
append2->AddInput(extract3->GetOutput());
append2->UpdateWholeExtent();
AAAAAAAAAAAAAAAAAAAAAARRRRRRRRRRRRRGGGGHH!
If anyone has some better ideas, please, let me know...
Dean
More information about the vtkusers
mailing list