[vtkusers] Re: [vtkusers]: Weird problem reading BMP image thenset transform
Thomas - Kuiran Chen
chent at cs.queensu.ca
Fri May 21 12:04:18 EDT 2004
Hi Qi Wei,
Yes, you are right. The matrix is something like that, to be specific, it is:
-0.33658448304182 -0.85428086875344 0 0.24762597798394
0.86780991318033 -0.06357157476514 0 -0.02272676782324
-0.36553696548425 0.50824159678083 0 -1.27555842452333
0 0 0 1.00000000000000
It is not directly applied to the indice (i.e.: i, j) of the image, as I set the image spacing first (which is 0.0001 meters/pixel), so that effectively scaled the image from the pixel units to meters. Then the above transform was applied.
This transform is used to transform a 2D image frame to a 3D frame. That is the reason the 3rd column is all zeros, because in a 2D image frame there is no 3rd components (i.e., z-axis), so this transform, plus the scaling factor, effectively projects a 2D image pixels to a 3D voxel.
Somehow, I don't understand why VTK gives error, as the image intensity should be first read and stored somewhere in the memory, and the transform is then applied to the pixel coordinates, so there shouldn't be reading error in the case, is that right?
Thanks,
Thomas
---------------------- Original Message ------------------------
From: Qi Wei <qwei at cs.ubc.ca>
To: Thomas - Kuiran Chen <chent at cs.queensu.ca>
Sent: 2004-05-21 11:47:23
Subject: Re: [vtkusers] [vtkusers]: Weird problem reading BMP image thenset transform
Hi Kuiran,
Does your transformation matrix look like this:
* * 0 *
* * 0 *
* * 0 *
0 0 0 1
or its transpose? Does the transformation operate on the indices of the
pixels in the image? What's the transformation for? I am wondering if
after that operation, the indices are not valid.
-Qi
On Fri, 21 May 2004, Thomas - Kuiran Chen wrote:
> Hi There,
>
> I am having the following errors when reading image using vtkBMPReader. I also set the data spacing and transform in the reader. These errors only come out when the transform is set.
>
> ERROR: In \THOMAS_K_CHEN\data_Research\Projects\ThirdParty\vtk-4.2\IO\vtkImageReader.cxx, line 175
> vtkBMPReader (0037AAC0): File operation failed: 4294837422, ext: -232, 148, -380, -17, 136, 159
>
> ERROR: In \THOMAS_K_CHEN\data_Research\Projects\ThirdParty\vtk-4.2\IO\vtkImageReader.cxx, line 179
> vtkBMPReader (0037AAC0): Header size: 1078, file ext: 0, 342, 0, 380, 0, 0
>
> Generic Warning: In \THOMAS_K_CHEN\data_Research\Projects\ThirdParty\vtk-4.2\IO\vtkBMPReader.cxx, line 476
> File operation failed. row = -380, Read = 381, Skip0 = -37, Skip1 = 5848, FilePos = -1, FileName = ../Test_Registration/Data/MatchedUSImageNO775_ROI-8.bmp
>
> The simple code to read in the image is:
>
> // 2D image transform
> // All the units are set in meters
> SliceTransformMatrix->SetElement(0, 0, -0.33658448304182);
> SliceTransformMatrix->SetElement(0, 1, -0.85428086875344);
> SliceTransformMatrix->SetElement(0, 2, 0);
> SliceTransformMatrix->SetElement(0, 3, 0.24762597798394);
>
> SliceTransformMatrix->SetElement(1, 0, 0.86780991318033);
> SliceTransformMatrix->SetElement(1, 1, -0.06357157476514);
> SliceTransformMatrix->SetElement(1, 2, 0);
> SliceTransformMatrix->SetElement(1, 3, -0.02272676782324);
>
> SliceTransformMatrix->SetElement(2, 0, -0.36553696548425);
> SliceTransformMatrix->SetElement(2, 1, 0.50824159678083);
> SliceTransformMatrix->SetElement(2, 2, 0);
> SliceTransformMatrix->SetElement(2, 3, -1.27555842452333);
>
> SliceTransformMatrix->SetElement(3, 0, 0);
> SliceTransformMatrix->SetElement(3, 1, 0);
> SliceTransformMatrix->SetElement(3, 2, 0);
> SliceTransformMatrix->SetElement(3, 3, 1);
>
> sliceTransform->SetMatrix( SliceTransformMatrix );
>
> // Live US Image Reader
> vtkBMPReader *LiveUSImage = vtkBMPReader::New();
> LiveUSImage->SetFileName("../Test_Registration/Data/MatchedUSImageNO775_ROI-8.bmp");
> LiveUSImage->Allow8BitBMPOn();
> LiveUSImage->SetDataSpacing(0.0001, 0.0001, 0.0001);
> LiveUSImage->SetTransform(sliceTransform);
> LiveUSImage->Update();
>
> Does anybody have a clue what's going on wrongly here?
>
> BTW, by default, the image that is read in by BMP reader has its left-lower corner as origin, is that right? The transform is set to w.r.t. that definition in mind.
>
> Thanks a lot,
> Thomas
>
>
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
--------------------------------------------------------------------
More information about the vtkusers
mailing list