Now I have a vtkImageData (WxHxS) .I want to recontruct the cube to SxHxW
I think there is a mapping for the goal
NEW ORIGIN
(i,0,0) ⇒ (W-i,0,0)
(0,j,0) ⇒ (W,j,0)
(0,0,k) ⇒ (W,0,k)
so I try to setting the new diminsion and extent for the vtkImageData
m->SetDimensions(S, H, W);
m->SetSpacing(origin->GetSpacing()[2], origin->GetSpacing()[1], origin->GetSpacing()[0]);
for (int k = 0; k < W; k++)
for (int j = 0; j < H; j++)
for (int i = 0; i< S; i++)
{
ptr = (unsigned short *)m->GetScalarPointer(i, j, k);
ori = (unsigned short *)origin->GetScalarPointer(W - 1 - k, j, S -1- i);
*ptr = *ori;
}
//But it doesn't get the matter
//However, when I use the pixel method to copy origin data or upsidedow data, it is correct //like below
//copy the same structure
for (int k = 0; k < S; k++)
for (int j = 0; j < H; j++)
for (int i = 0; i< W; i++)
{
ori = (unsigned short*)origin->GetScalarPointer(i, j, k);
ptr = (unsigned short*)m->GetScalarPointer(i, j, k);
*ptr = *ori;
}
//upsiaedown
double val; int i = 0;
for (vtkIdType f = m->GetNumberOfPoints() - 1; f > -1; f--)
{
val =m->GetPointData()->GetScalars()->GetTuple1(f);
origin->GetPointData()->GetScalars()->SetTuple1(i, val);
i++;
}
correct cubic output
Aucun commentaire:
Enregistrer un commentaire