vtkDistanceWidget and Dicom Images

classic Classic list List threaded Threaded
18 messages Options
Reply | Threaded
Open this post in threaded view
|

vtkDistanceWidget and Dicom Images

Leonardo M. Ramé
Hi, I use this code to add a vtkDistanceWidget to a scene showing a
Dicom image:

distanceWidget = vtkDistanceWidget::New();
distanceWidget->SetInteractor(this->GetInteractor());
static_cast<vtkDistanceRepresentation*>(distanceWidget->GetRepresentation())->SetLabelFormat("%-#6.2f mm");
distanceWidget->On();

The problem here is the measures I'm getting from the distance widget
are not related to the real image. For example, when I measure one image
with another Dicom viewer, it shows that I has 360mm width, and the
vtkDistanceWidget says it has 1748,30mm.

How can I define the relation between the size of the real image and the
representation I'm showing on screen?

--
Leonardo M. Ramé
http://leonardorame.blogspot.com
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: vtkDistanceWidget and Dicom Images

John Drescher-2
On Tue, Oct 19, 2010 at 9:46 AM, Leonardo M. Ramé <[hidden email]> wrote:

> Hi, I use this code to add a vtkDistanceWidget to a scene showing a
> Dicom image:
>
> distanceWidget = vtkDistanceWidget::New();
> distanceWidget->SetInteractor(this->GetInteractor());
> static_cast<vtkDistanceRepresentation*>(distanceWidget->GetRepresentation())->SetLabelFormat("%-#6.2f mm");
> distanceWidget->On();
>
> The problem here is the measures I'm getting from the distance widget
> are not related to the real image. For example, when I measure one image
> with another Dicom viewer, it shows that I has 360mm width, and the
> vtkDistanceWidget says it has 1748,30mm.
>
> How can I define the relation between the size of the real image and the
> representation I'm showing on screen?
>

Is the spacing correct in the vtkImageData?

John
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: vtkDistanceWidget and Dicom Images

Leonardo M. Ramé
On 2010-10-19 13:09:51 -0400, John Drescher wrote:

> On Tue, Oct 19, 2010 at 9:46 AM, Leonardo M. Ramé <[hidden email]> wrote:
> > Hi, I use this code to add a vtkDistanceWidget to a scene showing a
> > Dicom image:
> >
> > distanceWidget = vtkDistanceWidget::New();
> > distanceWidget->SetInteractor(this->GetInteractor());
> > static_cast<vtkDistanceRepresentation*>(distanceWidget->GetRepresentation())->SetLabelFormat("%-#6.2f mm");
> > distanceWidget->On();
> >
> > The problem here is the measures I'm getting from the distance widget
> > are not related to the real image. For example, when I measure one image
> > with another Dicom viewer, it shows that I has 360mm width, and the
> > vtkDistanceWidget says it has 1748,30mm.
> >
> > How can I define the relation between the size of the real image and the
> > representation I'm showing on screen?
> >
>
> Is the spacing correct in the vtkImageData?
>
> John

Thanks, if I apply a spacing of 0.20, got it from dicom tag (0028,0030),
it measures exactly as the other Dicom Viewer.

...but, now my image is rendered too small, I have to zoom it with the
mouse. Is there a way to render it to fill the QVTKWidget regardless of
its size?

--
Leonardo M. Ramé
http://leonardorame.blogspot.com
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: vtkDistanceWidget and Dicom Images

Jothy
Try ResetCameraClippingRange() on renderer.

Jothy

On Tue, Oct 19, 2010 at 6:18 PM, Leonardo M. Ramé <[hidden email]> wrote:
On 2010-10-19 13:09:51 -0400, John Drescher wrote:
> On Tue, Oct 19, 2010 at 9:46 AM, Leonardo M. Ramé <[hidden email]> wrote:
> > Hi, I use this code to add a vtkDistanceWidget to a scene showing a
> > Dicom image:
> >
> > distanceWidget = vtkDistanceWidget::New();
> > distanceWidget->SetInteractor(this->GetInteractor());
> > static_cast<vtkDistanceRepresentation*>(distanceWidget->GetRepresentation())->SetLabelFormat("%-#6.2f mm");
> > distanceWidget->On();
> >
> > The problem here is the measures I'm getting from the distance widget
> > are not related to the real image. For example, when I measure one image
> > with another Dicom viewer, it shows that I has 360mm width, and the
> > vtkDistanceWidget says it has 1748,30mm.
> >
> > How can I define the relation between the size of the real image and the
> > representation I'm showing on screen?
> >
>
> Is the spacing correct in the vtkImageData?
>
> John

Thanks, if I apply a spacing of 0.20, got it from dicom tag (0028,0030),
it measures exactly as the other Dicom Viewer.

...but, now my image is rendered too small, I have to zoom it with the
mouse. Is there a way to render it to fill the QVTKWidget regardless of
its size?

--
Leonardo M. Ramé
http://leonardorame.blogspot.com
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers


_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: vtkDistanceWidget and Dicom Images

Leonardo M. Ramé
On 2010-10-19 18:20:24 +0100, Jothy wrote:
> Try ResetCameraClippingRange() on renderer.
>
> Jothy
>

I tried that, but it does not work. Could you take a look at my code
below?, maybe the ResetCameraClippingRange is not on the correct line:

mImage = m_qdicomImage->getDicomImage();
mImage->flipImage(0,-1);
m_imageDataVTK->SetOrigin( 0, 0, 0 );

m_imageDataVTK->SetDimensions( mImage->getWidth(),
mImage->getHeight(), 1 );
m_imageDataVTK->SetScalarTypeToUnsignedShort(); // the data will be 16 bit
m_imageDataVTK->AllocateScalars();


// apply PixelSpacing
double lPixelSpacing;
m_qdicomImage->getDataSet()->findAndGetFloat64(DCM_PixelSpacing, lPixelSpacing, 0, false);
m_imageDataVTK->SetSpacing(lPixelSpacing, lPixelSpacing, lPixelSpacing);

// aplicamos Window Level
m_qdicomImage->getDicomImage()->setWindow(0);
mImage->getOutputData(
  m_imageDataVTK->GetScalarPointer(0,0,0),
  mImage->getOutputDataSize()
);

m_ImageViewer->SetInput(m_imageDataVTK);
m_ImageViewer->SetRenderWindow(this->GetRenderWindow());
m_ImageViewer->SetupInteractor(this->GetInteractor());

// ResetCameraClippingRange
m_ImageViewer->GetRenderer()->ResetCameraClippingRange();
--
Leonardo M. Ramé
http://leonardorame.blogspot.com
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: vtkDistanceWidget and Dicom Images

Jothy
First call Render() then try reset camera .

Jothy

On Tue, Oct 19, 2010 at 6:24 PM, Leonardo M. Ramé <[hidden email]> wrote:
On 2010-10-19 18:20:24 +0100, Jothy wrote:
> Try ResetCameraClippingRange() on renderer.
>
> Jothy
>

I tried that, but it does not work. Could you take a look at my code
below?, maybe the ResetCameraClippingRange is not on the correct line:

mImage = m_qdicomImage->getDicomImage();
mImage->flipImage(0,-1);
m_imageDataVTK->SetOrigin( 0, 0, 0 );

m_imageDataVTK->SetDimensions( mImage->getWidth(),
mImage->getHeight(), 1 );
m_imageDataVTK->SetScalarTypeToUnsignedShort(); // the data will be 16 bit
m_imageDataVTK->AllocateScalars();


// apply PixelSpacing
double lPixelSpacing;
m_qdicomImage->getDataSet()->findAndGetFloat64(DCM_PixelSpacing, lPixelSpacing, 0, false);
m_imageDataVTK->SetSpacing(lPixelSpacing, lPixelSpacing, lPixelSpacing);

// aplicamos Window Level
m_qdicomImage->getDicomImage()->setWindow(0);
mImage->getOutputData(
 m_imageDataVTK->GetScalarPointer(0,0,0),
 mImage->getOutputDataSize()
);

m_ImageViewer->SetInput(m_imageDataVTK);
m_ImageViewer->SetRenderWindow(this->GetRenderWindow());
m_ImageViewer->SetupInteractor(this->GetInteractor());

// ResetCameraClippingRange
m_ImageViewer->GetRenderer()->ResetCameraClippingRange();
--
Leonardo M. Ramé
http://leonardorame.blogspot.com
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers


_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: vtkDistanceWidget and Dicom Images

John Drescher-2
In reply to this post by Leonardo M. Ramé
On Tue, Oct 19, 2010 at 1:18 PM, Leonardo M. Ramé <[hidden email]> wrote:

> On 2010-10-19 13:09:51 -0400, John Drescher wrote:
>> On Tue, Oct 19, 2010 at 9:46 AM, Leonardo M. Ramé <[hidden email]> wrote:
>> > Hi, I use this code to add a vtkDistanceWidget to a scene showing a
>> > Dicom image:
>> >
>> > distanceWidget = vtkDistanceWidget::New();
>> > distanceWidget->SetInteractor(this->GetInteractor());
>> > static_cast<vtkDistanceRepresentation*>(distanceWidget->GetRepresentation())->SetLabelFormat("%-#6.2f mm");
>> > distanceWidget->On();
>> >
>> > The problem here is the measures I'm getting from the distance widget
>> > are not related to the real image. For example, when I measure one image
>> > with another Dicom viewer, it shows that I has 360mm width, and the
>> > vtkDistanceWidget says it has 1748,30mm.
>> >
>> > How can I define the relation between the size of the real image and the
>> > representation I'm showing on screen?
>> >
>>
>> Is the spacing correct in the vtkImageData?
>>
>> John
>
> Thanks, if I apply a spacing of 0.20, got it from dicom tag (0028,0030),
> it measures exactly as the other Dicom Viewer.
>
> ...but, now my image is rendered too small, I have to zoom it with the
> mouse. Is there a way to render it to fill the QVTKWidget regardless of
> its size?
>

I would use vtkChangeInformation filter right after the reader to
change the spacing.

John
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: vtkDistanceWidget and Dicom Images

John Drescher-2
On Tue, Oct 19, 2010 at 1:28 PM, John Drescher <[hidden email]> wrote:

> On Tue, Oct 19, 2010 at 1:18 PM, Leonardo M. Ramé <[hidden email]> wrote:
>> On 2010-10-19 13:09:51 -0400, John Drescher wrote:
>>> On Tue, Oct 19, 2010 at 9:46 AM, Leonardo M. Ramé <[hidden email]> wrote:
>>> > Hi, I use this code to add a vtkDistanceWidget to a scene showing a
>>> > Dicom image:
>>> >
>>> > distanceWidget = vtkDistanceWidget::New();
>>> > distanceWidget->SetInteractor(this->GetInteractor());
>>> > static_cast<vtkDistanceRepresentation*>(distanceWidget->GetRepresentation())->SetLabelFormat("%-#6.2f mm");
>>> > distanceWidget->On();
>>> >
>>> > The problem here is the measures I'm getting from the distance widget
>>> > are not related to the real image. For example, when I measure one image
>>> > with another Dicom viewer, it shows that I has 360mm width, and the
>>> > vtkDistanceWidget says it has 1748,30mm.
>>> >
>>> > How can I define the relation between the size of the real image and the
>>> > representation I'm showing on screen?
>>> >
>>>
>>> Is the spacing correct in the vtkImageData?
>>>
>>> John
>>
>> Thanks, if I apply a spacing of 0.20, got it from dicom tag (0028,0030),
>> it measures exactly as the other Dicom Viewer.
>>
>> ...but, now my image is rendered too small, I have to zoom it with the
>> mouse. Is there a way to render it to fill the QVTKWidget regardless of
>> its size?
>>
>
> I would use vtkChangeInformation filter right after the reader to
> change the spacing.
>

I meant vtkImageChangeInformation

John
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: vtkDistanceWidget and Dicom Images

Leonardo M. Ramé
On 2010-10-19 13:39:49 -0400, John Drescher wrote:
> > I would use vtkChangeInformation filter right after the reader to
> > change the spacing.
> >
>
> I meant vtkImageChangeInformation
>
> John

I'm going crazy trying to find an example on the web, could you give me
one?

--
Leonardo M. Ramé
http://leonardorame.blogspot.com
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: vtkDistanceWidget and Dicom Images

David Doria-2-3
I'm going crazy trying to find an example on the web, could you give me
one?
 
This explains the filter:

And this demonstrates it:
http://www.vtk.org/Wiki/VTK/Examples/Cxx/Images/CenterAnImage

David

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: vtkDistanceWidget and Dicom Images

Jothy
In reply to this post by Leonardo M. Ramé
This python script works fine for me!

self.DistanceWidgetA=vtk.vtkDistanceWidget()         
            self.DistanceWidgetA.SetInteractor(self.frameA.GetRenderWindow().GetInteractor())          
            self.DistanceWidgetA.CreateDefaultRepresentation()           
            self.DistanceWidgetA.GetRepresentation().SetLabelFormat("%-#6.3gmm")          
            self.frameA.show()           
            self.DistanceWidgetA.On()
           

Here self.frameA is the QVTKWidget.


Jothy



On Tue, Oct 19, 2010 at 6:48 PM, Leonardo M. Ramé <[hidden email]> wrote:
On 2010-10-19 13:39:49 -0400, John Drescher wrote:
> > I would use vtkChangeInformation filter right after the reader to
> > change the spacing.
> >
>
> I meant vtkImageChangeInformation
>
> John

I'm going crazy trying to find an example on the web, could you give me
one?

--
Leonardo M. Ramé
http://leonardorame.blogspot.com
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers


_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: vtkDistanceWidget and Dicom Images

Leonardo M. Ramé
In reply to this post by David Doria-2-3
On 2010-10-19 13:53:19 -0400, David Doria wrote:

> >
> > I'm going crazy trying to find an example on the web, could you give me
> > one?
>
>
> This explains the filter:
> http://www.vtk.org/doc/nightly/html/classvtkImageChangeInformation.html
>
> And this demonstrates it:
> http://www.vtk.org/Wiki/VTK/Examples/Cxx/Images/CenterAnImage
>
> David

Thanks, after checking the examples I come up with this:

// get pixel spacing and apply to image
double lPixelSpacing;
m_qdicomImage->getDataSet()->findAndGetFloat64(DCM_PixelSpacing, lPixelSpacing, 0, false);
m_imageDataVTK->SetSpacing(lPixelSpacing, lPixelSpacing,lPixelSpacing);

// change image information
vtkImageChangeInformation * in = vtkImageChangeInformation::New();
in->SetInput(m_imageDataVTK);
in->SetOutputSpacing(1.0, 1.0, 1.0);
in->Update();
m_imageDataVTK = in->GetOutput();
...

Aparently in->SetOutputSpacing is reverting the changes that SetSpacing
did. The measurement is multiplied by 5 (1 / 0.20), and I'm getting the
same results like if I don't apply SetSpacing.

Any hint?

--
Leonardo M. Ramé
http://leonardorame.blogspot.com
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: vtkDistanceWidget and Dicom Images

John Drescher-2
On Tue, Oct 19, 2010 at 2:11 PM, John Drescher <[hidden email]> wrote:

> On Tue, Oct 19, 2010 at 2:06 PM, Leonardo M. Ramé <[hidden email]> wrote:
>> On 2010-10-19 13:53:19 -0400, David Doria wrote:
>>> >
>>> > I'm going crazy trying to find an example on the web, could you give me
>>> > one?
>>>
>>>
>>> This explains the filter:
>>> http://www.vtk.org/doc/nightly/html/classvtkImageChangeInformation.html
>>>
>>> And this demonstrates it:
>>> http://www.vtk.org/Wiki/VTK/Examples/Cxx/Images/CenterAnImage
>>>
>>> David
>>
>> Thanks, after checking the examples I come up with this:
>>
>> // get pixel spacing and apply to image
>> double lPixelSpacing;
>> m_qdicomImage->getDataSet()->findAndGetFloat64(DCM_PixelSpacing, lPixelSpacing, 0, false);
>> m_imageDataVTK->SetSpacing(lPixelSpacing, lPixelSpacing,lPixelSpacing);
>>
>> // change image information
>> vtkImageChangeInformation * in = vtkImageChangeInformation::New();
>> in->SetInput(m_imageDataVTK);
>> in->SetOutputSpacing(1.0, 1.0, 1.0);
>> in->Update();
>> m_imageDataVTK = in->GetOutput();
>> ...
>>
>> Aparently in->SetOutputSpacing is reverting the changes that SetSpacing
>> did. The measurement is multiplied by 5 (1 / 0.20), and I'm getting the
>> same results like if I don't apply SetSpacing.
>>
>> Any hint?
>>
>
> Don't create a loop. Put the vtkImageChangeInformation right after the
> reader and before it gets to m_imageDataVTK.
>

Wait a minute. I am doing that myself with this code. That works..

if (fZAxisSpacing > 0.0) {
        double spacing[3];
        m_pImage->GetSpacing(spacing);
        pChangeInfo->SetInput(m_pImage);
        spacing[2] = fZAxisSpacing;
        pChangeInfo->SetOutputSpacing(spacing);
        pChangeInfo->Update();
        m_pImage = pChangeInfo->GetOutput();
}

This changes the z axes spacing because the vtkGDCMImageReader that I
use does not get the spacing correct in that direction for all image
types that I need to read.

John
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: vtkDistanceWidget and Dicom Images

John Drescher-2
On Tue, Oct 19, 2010 at 2:26 PM, John Drescher <[hidden email]> wrote:

> On Tue, Oct 19, 2010 at 2:11 PM, John Drescher <[hidden email]> wrote:
>> On Tue, Oct 19, 2010 at 2:06 PM, Leonardo M. Ramé <[hidden email]> wrote:
>>> On 2010-10-19 13:53:19 -0400, David Doria wrote:
>>>> >
>>>> > I'm going crazy trying to find an example on the web, could you give me
>>>> > one?
>>>>
>>>>
>>>> This explains the filter:
>>>> http://www.vtk.org/doc/nightly/html/classvtkImageChangeInformation.html
>>>>
>>>> And this demonstrates it:
>>>> http://www.vtk.org/Wiki/VTK/Examples/Cxx/Images/CenterAnImage
>>>>
>>>> David
>>>
>>> Thanks, after checking the examples I come up with this:
>>>
>>> // get pixel spacing and apply to image
>>> double lPixelSpacing;
>>> m_qdicomImage->getDataSet()->findAndGetFloat64(DCM_PixelSpacing, lPixelSpacing, 0, false);
>>> m_imageDataVTK->SetSpacing(lPixelSpacing, lPixelSpacing,lPixelSpacing);
>>>
>>> // change image information
>>> vtkImageChangeInformation * in = vtkImageChangeInformation::New();
>>> in->SetInput(m_imageDataVTK);
>>> in->SetOutputSpacing(1.0, 1.0, 1.0);
>>> in->Update();
>>> m_imageDataVTK = in->GetOutput();
>>> ...
>>>
>>> Aparently in->SetOutputSpacing is reverting the changes that SetSpacing
>>> did. The measurement is multiplied by 5 (1 / 0.20), and I'm getting the
>>> same results like if I don't apply SetSpacing.
>>>
>>> Any hint?
>>>
>>
>> Don't create a loop. Put the vtkImageChangeInformation right after the
>> reader and before it gets to m_imageDataVTK.
>>
>
> Wait a minute. I am doing that myself with this code. That works..
>
> if (fZAxisSpacing > 0.0) {
>        double spacing[3];
>        m_pImage->GetSpacing(spacing);
>        pChangeInfo->SetInput(m_pImage);
>        spacing[2] = fZAxisSpacing;
>        pChangeInfo->SetOutputSpacing(spacing);
>        pChangeInfo->Update();
>        m_pImage = pChangeInfo->GetOutput();
> }
>
> This changes the z axes spacing because the vtkGDCMImageReader that I
> use does not get the spacing correct in that direction for all image
> types that I need to read.
>

pChangeInfo was defined before the conditional as:

vtkSmartPointer<vtkImageChangeInformation> pChangeInfo =
                        vtkSmartPointer<vtkImageChangeInformation>::New();

John
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: vtkDistanceWidget and Dicom Images

John Drescher-2
In reply to this post by Leonardo M. Ramé
On Tue, Oct 19, 2010 at 2:06 PM, Leonardo M. Ramé <[hidden email]> wrote:

> On 2010-10-19 13:53:19 -0400, David Doria wrote:
>> >
>> > I'm going crazy trying to find an example on the web, could you give me
>> > one?
>>
>>
>> This explains the filter:
>> http://www.vtk.org/doc/nightly/html/classvtkImageChangeInformation.html
>>
>> And this demonstrates it:
>> http://www.vtk.org/Wiki/VTK/Examples/Cxx/Images/CenterAnImage
>>
>> David
>
> Thanks, after checking the examples I come up with this:
>
> // get pixel spacing and apply to image
> double lPixelSpacing;
> m_qdicomImage->getDataSet()->findAndGetFloat64(DCM_PixelSpacing, lPixelSpacing, 0, false);
> m_imageDataVTK->SetSpacing(lPixelSpacing, lPixelSpacing,lPixelSpacing);
>
> // change image information
> vtkImageChangeInformation * in = vtkImageChangeInformation::New();
> in->SetInput(m_imageDataVTK);
> in->SetOutputSpacing(1.0, 1.0, 1.0);
> in->Update();
> m_imageDataVTK = in->GetOutput();
> ...
>
> Aparently in->SetOutputSpacing is reverting the changes that SetSpacing
> did. The measurement is multiplied by 5 (1 / 0.20), and I'm getting the
> same results like if I don't apply SetSpacing.
>
> Any hint?

Wait a minute. I meant that you need to set your spacing with
vtkImageChangeInformation only. So in this case you need to specify
0.20 not 1.0. You should not use SetSpacing on images directly because
the pipeline will reset the change the next update.

John
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: vtkDistanceWidget and Dicom Images

Leonardo M. Ramé
In reply to this post by John Drescher-2
On 2010-10-19 14:27:19 -0400, John Drescher wrote:

> >
> > Wait a minute. I am doing that myself with this code. That works..
> >
> > if (fZAxisSpacing > 0.0) {
> >        double spacing[3];
> >        m_pImage->GetSpacing(spacing);
> >        pChangeInfo->SetInput(m_pImage);
> >        spacing[2] = fZAxisSpacing;
> >        pChangeInfo->SetOutputSpacing(spacing);
> >        pChangeInfo->Update();
> >        m_pImage = pChangeInfo->GetOutput();
> > }
> >
> > This changes the z axes spacing because the vtkGDCMImageReader that I
> > use does not get the spacing correct in that direction for all image
> > types that I need to read.
> >
>
> pChangeInfo was defined before the conditional as:
>
> vtkSmartPointer<vtkImageChangeInformation> pChangeInfo =
> vtkSmartPointer<vtkImageChangeInformation>::New();
>
> John

Look, this is my code, setting the spacing with m_imageDataVTK does the
same as vtkImageChangeInformation::SetOutputSpacing, the spacing is
right, the measure is correct, but the image is small on screen. I think
what I need is some way to Zoom in the image.

This is the method I use to get the image from dcmtk and show in a
vtkImageViewer2.

mImage = m_qdicomImage->getDicomImage();
mImage->flipImage(0,-1);
m_imageDataVTK->SetOrigin( 0, 0, 0 );

m_imageDataVTK->SetDimensions( mImage->getWidth(), mImage->getHeight(), 1 );
m_imageDataVTK->SetScalarTypeToUnsignedShort(); // the data will be 16 bit
m_imageDataVTK->AllocateScalars();

double lPixelSpacing;
m_qdicomImage->getDataSet()->findAndGetFloat64(DCM_PixelSpacing, lPixelSpacing, 0, false);
//m_imageDataVTK->SetSpacing(lPixelSpacing, lPixelSpacing, lPixelSpacing);

// aplicamos Window Level
m_qdicomImage->getDicomImage()->setWindow(0);

mImage->getOutputData(
  m_imageDataVTK->GetScalarPointer(0,0,0),
  mImage->getOutputDataSize()
);

vtkImageChangeInformation * in = vtkImageChangeInformation::New();
in->SetInput(m_imageDataVTK);
in->SetOutputSpacing(lPixelSpacing, lPixelSpacing, lPixelSpacing);
in->Update();

m_ImageViewer->SetInput(in->GetOutput());
m_ImageViewer->SetRenderWindow(this->GetRenderWindow());
m_ImageViewer->SetupInteractor(this->GetInteractor());

vtkSmartPointer<DCMInteractorStyle> style = vtkSmartPointer<DCMInteractorStyle>::New();
this->GetInteractor()->SetInteractorStyle(style);


--
Leonardo M. Ramé
http://leonardorame.blogspot.com
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: vtkDistanceWidget and Dicom Images

Leonardo M. Ramé
On 2010-10-19 14:45:22 -0400, John Drescher wrote:

> On Tue, Oct 19, 2010 at 2:40 PM, Leonardo M. Ramé <[hidden email]> wrote:
> > On 2010-10-19 14:27:19 -0400, John Drescher wrote:
> >> >
> >> > Wait a minute. I am doing that myself with this code. That works..
> >> >
> >> > if (fZAxisSpacing > 0.0) {
> >> >        double spacing[3];
> >> >        m_pImage->GetSpacing(spacing);
> >> >        pChangeInfo->SetInput(m_pImage);
> >> >        spacing[2] = fZAxisSpacing;
> >> >        pChangeInfo->SetOutputSpacing(spacing);
> >> >        pChangeInfo->Update();
> >> >        m_pImage = pChangeInfo->GetOutput();
> >> > }
> >> >
> >> > This changes the z axes spacing because the vtkGDCMImageReader that I
> >> > use does not get the spacing correct in that direction for all image
> >> > types that I need to read.
> >> >
> >>
> >> pChangeInfo was defined before the conditional as:
> >>
> >> vtkSmartPointer<vtkImageChangeInformation> pChangeInfo =
> >>                       vtkSmartPointer<vtkImageChangeInformation>::New();
> >>
> >> John
> >
> > Look, this is my code, setting the spacing with m_imageDataVTK does the
> > same as vtkImageChangeInformation::SetOutputSpacing, the spacing is
> > right, the measure is correct, but the image is small on screen. I think
> > what I need is some way to Zoom in the image.
> >
>
> I do not use vtkImageViewer2 but in my code (derived from vtkINRIA3d
> google for that if you like) moves the camera to zoom in.
>
> John

Could it be that vtkImageViewer2 is ignoring the "z" scaling?

--
Leonardo M. Ramé
http://leonardorame.blogspot.com
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

2d Annotations Dynamically

kumar
This post was updated on .
In reply to this post by Leonardo M. Ramé
Hi,

Am using vtkImageViewer2 for Rendering Dicom Images.

For 2d Annotation, can any one tell me how to Draw Dynamically on Mouse Events.

I Tried using CallBack Functions, but it's not changing the Rectangle Drawn.

Any one if done, pls send me the Attachment.