[vtkusers] Difference in images displayed in vtkImageViewer2 and vtkResliceImageViewer

K O ranjith kor1581 at gmail.com
Thu Sep 21 04:55:30 EDT 2017


Hi,
This is the code i used for image viewer with vtkResliceImageViewer, is
this ok?
as per vtk class reference doc, the vtkResliceImageViewer will behave like
vtkImageViewer2
<https://www.vtk.org/doc/nightly/html/classvtkImageViewer2.html>,  if the
Reslice mode is set to RESLICE_AXIS_ALIGNED,
but the setting not affecting in image display.

viewwidget::viewwidget(QWidget *parent) : QWidget(parent)
{

     QPointer<QVTKWidget> m_vtkWgt      = new QVTKWidget(this);

    vtkSmartPointer<vtkResliceImageViewer> m_vtkImViewer   =
vtkSmartPointer<vtkResliceImageViewer>::New();

     QPointer<QHBoxLayout> m_loSinWin      = new QHBoxLayout(this);

    vtkSmartPointer<vtkDICOMReader> m_vtkDcmRdr m_vtkDcmRdr     =
vtkSmartPointer<vtkDICOMReader>::New();

    m_MetaData      = vtkSmartPointer<vtkDICOMMetaData>::New();

    m_loSinWin->addWidget(m_vtkWgt);
    this->setLayout(m_loSinWin);

    vtkSmartPointer <vtkDICOMDirectory> vtkDcmDir =
vtkSmartPointer<vtkDICOMDirectory>::New();

    vtkSmartPointer <vtkStringArray>  aVtkStrFNames;

    QString imgFolder =
QDir::currentPath()+"/sampledicom/MRIX_LUMBAR/Lumbar/3-PlaneLoc1";
    vtkDcmDir->SetDirectoryName(imgFolder.toStdString().c_str());
    vtkDcmDir->RequirePixelDataOn();
    vtkDcmDir->Update();
     // Iterate through all of the studies that are present.
    int iNoStudies = vtkDcmDir ->GetNumberOfStudies();
    for(int i = 0; i < iNoStudies; i++)
    {
        // Get information related to the patient study
        //vtkDICOMItem   patient = dicomdir ->GetPatientRecordForStudy(i);
        //vtkDICOMItem   study = dicomdir ->GetStudyRecord(i);
        // Iterate through all of the series in this study.
        int j1 = vtkDcmDir ->GetFirstSeriesForStudy(i);
        int j2 = vtkDcmDir ->GetLastSeriesForStudy(i);
        for (int j = j1; j <= j2; j++)
        {
            aVtkStrFNames = vtkDcmDir->GetFileNamesForSeries(j);
            // do something with the files
            m_vtkDcmRdr ->SetFileNames(aVtkStrFNames);
            m_vtkDcmRdr->UpdateInformation();
            m_vtkDcmRdr ->Update();
        }
    }
    //m_vtkDcmRdr->SetMemoryRowOrderToFileNative();
    m_vtkImViewer->SetSliceOrientationToXY();
    m_vtkImViewer->SetResliceModeToAxisAligned();
    m_vtkDcmRdr->Update();
    m_MetaData = m_vtkDcmRdr->GetMetaData();
    //m_vtkImViewer->SetInputConnection(m_vtkDcmRdr->GetOutputPort());

    m_vtkImViewer->SetInputData(m_vtkDcmRdr->GetOutput());


    m_vtkImViewer->SetRenderWindow(m_vtkWgt->GetRenderWindow());


    double dDefaultWinWidth   = m_MetaData->GetAttributeValue (0 , DC ::
WindowWidth ). AsDouble () ;

    double dDefaultWinLevel   = m_MetaData-> GetAttributeValue(0 , DC ::
WindowCenter ). AsDouble () ;

    m_vtkImViewer->SetColorLevel(dDefaultWinWidth);
    m_vtkImViewer->SetColorWindow(dDefaultWinLevel);


    m_vtkImViewer->SetupInteractor(m_vtkWgt->GetInteractor());

    m_vtkImViewer->GetRenderer()->ResetCamera();
    m_vtkImViewer->Render();
    m_vtkWgt->GetInteractor()->Initialize();
    m_vtkWgt->show();
}


On Wed, Sep 20, 2017 at 9:14 PM, K O ranjith <kor1581 at gmail.com> wrote:

> Hello,
>
> Thanks for the support.
>
> As I mentioned in my question I have tried to set the window level and
> width from the dicom metadata to both the viewer’s using the api s
>
>     m_vtkImViewer->SetColorLevel(dDefaultWinWidth);
>
>     m_vtkImViewer->SetColorWindow(dDefaultWinLevel);
>
> but the result from vtkResliceImageViewer is different than other viewers,
> ie vtkImageViewer2 and other dicom viewer applications.
>
>
>
> While connecting the vtkResliceImageViewer with vtkDICOMReader with api
> “SetInputData””, have .
>
>
>
> So I tried with the method vtkResliceImageViewer->
> SetInputConnection(vtkDICOMReader ->GetOutputPort());,  then vtk showing
> error message "Use SetInputData instead.", but the images are displaying
> image almost same as (but not exact )other viewers. But then also, while
> setting the window level and width from to the default value in the dicom
> metadata, the image display again getting distorted. But the
> vtkImageViewer2 have same proper result all the time.
>
> I used 2d dicom images for testing.
>
> Why this happening? What are the basic difference in both vtk viewers in
> displaying images and setting window level and width?
>
>
>
>
> On Wed, Sep 20, 2017 at 6:23 PM, Sankhesh Jhaveri <
> sankhesh.jhaveri at kitware.com> wrote:
>
>> The difference in the two images seems to be window width and level.
>> Ensure that the values are same in the vtkImageResliceViewer.
>>>>
>> On Wed, Sep 20, 2017 at 7:37 AM K O ranjith <kor1581 at gmail.com> wrote:
>>
>>> Hello,
>>> While displaying same dicom images in vtkResliceImageViewer and
>>> vtkImageViewer2, it showing images with a different window level and window
>>> width.
>>> I also tried to get the window level and window width values from dicom
>>> metadata and set in both the viewers. Then the vtkImageViewer2 giving same
>>> result as like other dicom viewer applications(like RadiAnt), but
>>> vtkResliceImageViewer showing a differnt result from others.
>>> I need to use vtkResliceImageViewer in my application.
>>> why images displaying in different manner in vtkResliceImageViewer and
>>> vtkImageViewer2?
>>> Can get the same result with vtkResliceImageViewer as like
>>> vtkImageViewer2?
>>> Do need to perform any configuration in vtkResliceImageViewer?
>>>
>>> (Attached the screenshot of screens displayed same dicom image with
>>> vtkResliceImageViewer and vtkImageViewer2)
>>>
>>> _______________________________________________
>>> 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
>>>
>>> Search the list archives at: http://markmail.org/search/?q=vtkusers
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://public.kitware.com/mailman/listinfo/vtkusers
>>>
>> --
>> Sankhesh Jhaveri *Sr. Research & Development Engineer* | Kitware
>> <http://www.kitware.com/> | (518) 881-4417
>>>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20170921/ae49513a/attachment.html>


More information about the vtkusers mailing list