[vtkusers] Fwd: non-square image "cropped" after rotate 90º

David Gobbi david.gobbi at gmail.com
Thu Sep 17 13:06:48 EDT 2015


Hi Marcos,

You'll have to describe your pipeline in more detail before I can help.

 - David


On Thu, Sep 17, 2015 at 10:52 AM, Marcos <fotosentido at gmail.com> wrote:

> Thank you so much, it worked.
>
> Just one thing: after your change, in a multiframe image, when I rotated
> it, it was still cropped on one side. I noticed that, switching to the
> next/previous, it was corrected (I could the entire image rotated), so my
> solution for now is moving to the next frame and inmediatly going back
> again.
>
>
>
> 2015-09-17 0:36 GMT+02:00 David Gobbi <david.gobbi at gmail.com>:
>
>> Hi Marcos,
>>
>> Changing to SetResliceAxes is simple.  Just do this:
>>
>>     reslicer->SetResliceAxes(transform->GetMatrix());
>>
>> Then remove the call to SetOutputExtent().
>>
>> The output extent should not be the same as the input extent when
>> you rotate a rectangular image.
>>
>> Also, do not set the Extent with the Bounds.  The Bounds and the Extent
>> are not the same thing (here the Bounds is measured in millimetres, but
>> the Extent is measured in voxels).  It might have worked for you if your
>> voxel size was 1mm x 1mm x 1mm, but in general this is not the case.
>>
>>  - David
>>
>>
>>
>> On Wed, Sep 16, 2015 at 4:24 PM, Marcos <fotosentido at gmail.com> wrote:
>>
>>>
>>> Hi,
>>>
>>> I tried before woth SetResliceAxes, but I didn't get how to use a
>>> vtkMatrix4x4 as I said in another post.
>>>
>>> It was working with SetResliceTransform, until I saw that.
>>>
>>>
>>> I tried to do this:
>>>
>>> void ViewerWidget::rotateCalculate(int angle, double axis[])
>>>
>>> {
>>>
>>>     double bounds[6];
>>>
>>>     con->GetOutput()->GetBounds(bounds);
>>>
>>>     double center[3];
>>>
>>>     center[0] = (bounds[1] + bounds[0]) / 2.0;
>>>
>>>     center[1] = (bounds[3] + bounds[2]) / 2.0;
>>>
>>>     center[2] = (bounds[5] + bounds[4]) / 2.0;
>>>
>>>     transform->Translate(center[0], center[1], center[2]);
>>>
>>>     transform->RotateWXYZ(angle, axis);
>>>
>>>     transform->Translate(-center[0], -center[1], -center[2]);
>>>
>>>     reslicer->SetResliceTransform(transform);
>>>
>>>
>>>     // added this line,
>>>
>>>     reslicer->SetOutputExtent(bounds[2], bounds[3], bounds[0], bounds[1],
>>>
>>>             bounds[4], bounds[5]);
>>>
>>>
>>>     reslicer->Update();
>>>
>>> }
>>>
>>>
>>> I got an exception : read access violation on
>>> vtkImageMapToWindowLevelColors::ThreadedRequestData
>>> even with square images.
>>>
>>> The bound values for a non square-image (multiframe):
>>> 299.5, 898.5, 214.5, 643.5, 4.5, 13.5
>>>
>>> The bound values for the square image (multiframe):
>>> 127.5, 382.5, 127.5, 382.5, 521.024, 1563.0749
>>>
>>>
>>> 2015-09-16 22:49 GMT+02:00 David Gobbi <david.gobbi at gmail.com>:
>>>
>>>> On Wed, Sep 16, 2015 at 1:46 PM, Siavash Khallaghi <siavashk at ece.ubc.ca
>>>> > wrote:
>>>>
>>>>> Hi Marcos,
>>>>>
>>>>> Can you compare the extent of the output of vtkImageReslice against its
>>>>> input? My gut feeling is that they are not equal.
>>>>>
>>>>
>>>> I suggest to use SetResliceAxes() (using transform->GetMatrix())
>>>> instead of
>>>> SetResliceTransform.  Here is why:
>>>>
>>>> When you use SetResliceAxes(), vtkImageReslice will transform the input
>>>> sampling (i.e. the extent and spacing) so that the output extent is
>>>> rotated as
>>>> compared to the input extent.
>>>>
>>>> Another option is to manually set the output extent, with
>>>> reslice->SetOutputExtent().
>>>>
>>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20150917/22f4bac0/attachment.html>


More information about the vtkusers mailing list