[Insight-users] how can i convert from Vtk To itk...

yasser salman yass71 at yahoo.com
Fri, 6 Feb 2004 11:56:50 -0800 (PST)


--0-468972986-1076097410=:61490
Content-Type: text/plain; charset=us-ascii
Content-Id: 
Content-Disposition: inline


Note: forwarded message attached.


__________________________________
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html
--0-468972986-1076097410=:61490
Content-Type: message/rfc822

X-Apparently-To: yass71 at yahoo.com via 216.109.117.224; Fri, 06 Feb 2004 04:59:33 -0800
Return-Path: <insight-users-admin at itk.org>
Received: from 24.97.130.19  (EHLO public.kitware.com) (24.97.130.19)
  by mta128.mail.scd.yahoo.com with SMTP; Fri, 06 Feb 2004 04:59:28 -0800
Received: from public.kitware.com (localhost [127.0.0.1])
	by public.kitware.com (Postfix) with ESMTP
	id 7D91A1B239; Fri,  6 Feb 2004 07:59:04 -0500 (EST)
Delivered-To: insight-users at itk.org
Received: from web60702.mail.yahoo.com (web60702.mail.yahoo.com [216.109.117.225])
	by public.kitware.com (Postfix) with SMTP id EB3B81AB41
	for <insight-users at itk.org>; Fri,  6 Feb 2004 07:58:50 -0500 (EST)
Received: from [62.135.20.114] by web60702.mail.yahoo.com via HTTP; Fri, 06 Feb 2004 04:58:48 PST
From: yasser salman <yass71 at yahoo.com>
Subject: Re: [Insight-users] From Vtk To itk...
To: Luis Ibanez <luis.ibanez at kitware.com>
Cc: insight-users at itk.org
In-Reply-To: <40104F7B.5060909 at kitware.com>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="0-418025320-1076072328=:97060"
Sender: insight-users-admin at itk.org
Errors-To: insight-users-admin at itk.org
X-BeenThere: insight-users at itk.org
X-Mailman-Version: 2.0.11
Precedence: bulk
List-Help: <mailto:insight-users-request at itk.org?subject=help>
List-Post: <mailto:insight-users at itk.org>
List-Subscribe: <http://www.itk.org/mailman/listinfo/insight-users>,
	<mailto:insight-users-request at itk.org?subject=subscribe>
List-Id: <insight-users.itk.org>
List-Unsubscribe: <http://www.itk.org/mailman/listinfo/insight-users>,
	<mailto:insight-users-request at itk.org?subject=unsubscribe>
List-Archive: <http://www.itk.org/pipermail/insight-users/>
Date: Fri, 6 Feb 2004 04:58:48 -0800 (PST)
Content-Length: 2634

--0-418025320-1076072328=:97060
Content-Type: text/plain; charset=us-ascii
Content-Id: 
Content-Disposition: inline

hi Luis ..,
About ur suggestion to use the same filter
"Itk::ImageToVTKImageFilter" to connect vtk->Itk->Vtk
agian.., i wrote this code at the attachment but  it
didn't work.., 
can u help me to show me how to connect these
pipeLines..,
thanx..,

--- Luis Ibanez <luis.ibanez at kitware.com> wrote:
> 
> Yasser,
> 
> If you need to convert a VTK image
> into an ITK one you use the filter
> itkVTKImageToImageFilter.
> 
> You will find the files in the directory:
> 
>    InsightApplications/Auxiliary/vtk
> 
>       itkVTKImageToImageFilter.h
>       itkVTKImageToImageFilter.txx
> 
> 
> With this filter you can do:
> 
> 
> VTKReader-->VTK2ITK---ITKSegmentation-->
> 
> --->ITK2VTK--->VTKContour..... visualization
> 
> 
> Please look at the tutorial session
> 
>
http://www.itk.org/CourseWare/Training/GettingStarted-II.pdf
> 
> 
> 
> 
> Regards,
> 
> 
>    Luis
> 
> 
> ----------------------------
> yasser salman wrote:
> > hi ALL..,
> > 
> > i run  sample code that Luis sent and it works
> well
> > (thanx luis..)..,
> > but at the begining i read the files or volumes
> using
> > Vtk , like that
> > 
> > 
> > Reader->SetFilePrefix(VolData_FName);
> > 	Reader->SetFilePattern("%s%.1d.dcm");
> >     Reader->SetDataByteOrderToLittleEndian();
> > 	   	Reader->SetDataScalarTypeToUnsignedShort();
> > 
> > 	Reader->SetDataExtent
> >
> (0,VolData_Width,0,VolData_Height,1,VolData_Images);
> > 	Reader->SetDataOrigin(0,0,0); 
> > 
> >
>
Reader->SetDataSpacing(VolData_Xsize,VolData_Ysize,VolData_Zsize);
> > 	Reader->Update();
> > 
> > so how can i send this volume to Itk (and then use
> > Luis code for segmentation and back again to
> > visualize)..
> > thanx All..,
> > yasser
> > 
> > 
> 
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users


__________________________________
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html
--0-418025320-1076072328=:97060
Content-Type: text/plain; name="SegmenterViewer2.cxx"
Content-Description: SegmenterViewer2.cxx
Content-Disposition: inline; filename="SegmenterViewer2.cxx"


#include "itkImageFileReader.h"
#include "itkImageToVTKImageFilter.h"
#include "itkImage.h"

#include "itkCastImageFilter.h"
#include "itkConfidenceConnectedImageFilter.h"
#include "itkCurvatureFlowImageFilter.h"

#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkContourFilter.h"
#include "vtkPolyDataMapper.h"
#include "vtkActor.h"
#include "vtkImageActor.h"
#include "vtkImageShiftScale.h"
#include "vtkitkImageToImageFilter.h"
#include "vtkMarchingCubes.h"

#include "vtkProperty.h"
#include "vtkPolyDataNormals.h"
#include "vtkContourFilter.h"
#include "vtkImageViewer.h"
#include "vtkImageReader2.h"
#include "vtkVolumeRayCastFunction.h"
#include "vtkVolumeRayCastCompositeFunction.h"
#include "vtkVolumeRayCastMapper.h"
#include "vtkPiecewiseFunction.h"
#include "vtkVolumeProperty.h" 
#include "vtkColorTransferFunction.h"
#include "vtkImageViewer2.h"
#include "vtkPolyData.h"
#include "vtkImageActor.h"
#include "vtkImageActor.h"
#include "vtkImageData.h"
#include "vtkDICOMImageReader.h"
#include "vtkImageFlip.h"
#include "vtkContourFilter.h"
#include "vtkPolyDataMapper.h"
int main( int argc, char ** argv )
{


  typedef unsigned char    InputPixelType;
  typedef unsigned char     InternalPixelType;
  typedef unsigned char   SegmentedPixelType;

  typedef itk::Image< InputPixelType, 3 >          InputImageType;
  typedef itk::Image< InternalPixelType, 3>       InternalImageType;
  typedef itk::Image< SegmentedPixelType, 3 >      SegmentedImageType;

  typedef itk::ImageFileReader< InputImageType >   ReaderType;

  typedef   itk::CastImageFilter< 
                 InputImageType, 
                 InternalImageType >     CastImageFilterType;

  typedef   itk::CurvatureFlowImageFilter< 
                 InternalImageType, 
                 InternalImageType >     CurvatureFlowImageFilterType;

  typedef   itk::ConfidenceConnectedImageFilter< 
                         InternalImageType, 
                         SegmentedImageType >     ConfidenceConnectedImageFilterType;

  typedef itk::ImageToVTKImageFilter< SegmentedImageType >  ConnectorFilterType;
    vtkDICOMImageReader *Reader=vtkDICOMImageReader::New(); 
	vtkImageViewer2 *viewer = vtkImageViewer2::New();     
	Reader->SetDirectoryName("D:/imagedata/Dicom/1Nesma");              
    Reader->Update();										  
		vtkImageFlip *flipY = vtkImageFlip::New();
flipY->SetInput (Reader->GetOutput());
flipY->SetFilteredAxis (1);

	viewer->SetInput(flipY->GetOutput());				  
int VolData_Images = viewer->GetWholeZMax ();			  


for (int i=1;i<VolData_Images;i++)
{
	
	viewer->SetZSlice(i);		  
    viewer->SetSize(512,512);
	viewer->SetPosition(500,0);
	viewer->SetColorWindow(512);
	viewer->SetColorLevel(256);
	viewer->Render();

// TODO: Add your command handler code here
}		

  //----------------------------------
  //           ITK Pipeline
  //----------------------------------

  ReaderType::Pointer  reader = ReaderType::New();

  CastImageFilterType::Pointer cast = CastImageFilterType::New();

  CurvatureFlowImageFilterType::Pointer smoothing = CurvatureFlowImageFilterType::New();

  ConfidenceConnectedImageFilterType::Pointer confidence = ConfidenceConnectedImageFilterType::New();

  ConnectorFilterType::Pointer connector = ConnectorFilterType::New();


  connector->SetInput((itk::Image<unsigned char,3> *) Reader ->GetOutput());

  cast->SetInput( (itk::Image<unsigned char,3> *)connector->GetOutput() );
  smoothing->SetInput(  cast->GetOutput() );
  confidence->SetInput( smoothing->GetOutput() );

  smoothing->SetTimeStep( 0.125 );
  smoothing->SetNumberOfIterations( 2 );
    
  confidence->SetMultiplier( 5.0 );
  confidence->SetNumberOfIterations( 2 );
  confidence->SetReplaceValue( 250 );

  typedef ConfidenceConnectedImageFilterType::IndexType IndexType;
  IndexType seed;
  seed[0] = 50;
  seed[1] = 50;
  seed[2] = 5;

  std::cout << "Using seed = " << seed << std::endl;
  confidence->SetSeed( seed );

  confidence->SetInitialNeighborhoodRadius( 3);

  connector->SetInput(confidence ->GetOutput());
  connector->GetImporter()->SetDataScalarTypeToUnsignedChar();
  //----------------------------------
  //           VTK Pipeline
  //----------------------------------

  vtkRenderer               * renderer               = vtkRenderer::New();
  vtkRenderWindow           * renderWindow           = vtkRenderWindow::New();
  vtkRenderWindowInteractor * renderWindowInteractor = vtkRenderWindowInteractor::New();
vtkImageActor* imageactor = vtkImageActor::New();
  renderWindow->AddRenderer( renderer );
  renderWindow->SetInteractor( renderWindowInteractor );
 vtkMarchingCubes *mc = vtkMarchingCubes::New();

	mc->SetInput((vtkImageData * )connector->GetOutput());  
	mc->SetValue(0,127);

	vtkPolyDataMapper* mcmap=vtkPolyDataMapper::New();
	mcmap->SetInput(mc->GetOutput());
	mcmap->ScalarVisibilityOff();
	vtkActor* mcactor=vtkActor::New();
	mcactor->SetMapper(mcmap); 
	renderer->AddActor(mcactor);
  renderer->SetBackground( 0.1, 0.2, 0.4 );

  renderWindow->Render();
 renderWindowInteractor->Start();
  
  return 0;

}




--0-418025320-1076072328=:97060--
_______________________________________________
Insight-users mailing list
Insight-users at itk.org
http://www.itk.org/mailman/listinfo/insight-users
--0-468972986-1076097410=:61490--