[Insight-users] Co-registration in Osirix

Carlos Caldart hi_ten_mitsurugi at hotmail.com
Mon Oct 1 12:44:27 EDT 2012





Hello: I'm trying to make a co-registration plug-in for osirix, i have already test the wrapimagefloat3d to export 1 image, defining the viewer controller as 
ViewerController *new2DViewer;
 new2DViewer = [self duplicateCurrent2DViewerWindow];

but now I try to pass two images as if is was a fusion filter but it doesn't work... here is the part of the code i use to import the images between osirix and ITK
The code is build in Xcode without any error. I think my error is in the declaration of DCMview but i cant fixed.Any help would be greatThanks!!Carlos Caldart

- (ImageTypeFloat3D::Pointer)WrapImageFloat3D:(ViewerController*)Viewer

{
	ImageTypeFloat3D::Pointer image;
	ImportFilterTypeFloat3D::Pointer importFilter = ImportFilterTypeFloat3D::New();
	ImportFilterTypeFloat3D::SizeType size;
	ImportFilterTypeFloat3D::IndexType start;
	ImportFilterTypeFloat3D::RegionType region;


	DCMPix *firstPix = [[Viewer pixList] objectAtIndex:0];
	int slices = [[Viewer pixList] count];


//	Size Width * Height * NoOfSlices
	size[0] = [firstPix pwidth];
	size[1] = [firstPix pheight];
	size[2] = slices;


	long bufferSize = size[0] * size[1] * size[2];


	start.Fill(0);


	region.SetIndex(start);
	region.SetSize(size);


	double voxelSpacing[3];
	double originConverted[3];
	double vectorOriginal[9];
	double origin[3];


	origin[0] = [firstPix originX];
	origin[1] = [firstPix originY];
	origin[2] = [firstPix originZ];


	[firstPix orientationDouble: vectorOriginal];
	originConverted[ 0] = origin[ 0] * vectorOriginal[ 0] + origin[ 1] * vectorOriginal[ 1] + origin[ 2] * vectorOriginal[ 2];
	originConverted[ 1] = origin[ 0] * vectorOriginal[ 3] + origin[ 1] * vectorOriginal[ 4] + origin[ 2] * vectorOriginal[ 5];
	originConverted[ 2] = origin[ 0] * vectorOriginal[ 6] + origin[ 1] * vectorOriginal[ 7] + origin[ 2] * vectorOriginal[ 8];


	voxelSpacing[0] = [firstPix pixelSpacingX];
	voxelSpacing[1] = [firstPix pixelSpacingY];
	voxelSpacing[2] = [firstPix sliceInterval];


	importFilter->SetRegion(region);
	importFilter->SetOrigin(originConverted);
	importFilter->SetSpacing(voxelSpacing);
	importFilter->SetImportPointer(Viewer* , bufferSize, false); //do not overwrite original data


		image = importFilter->GetOutput();
	image->Update();


	return image;


}

- (void)UnwrapImageFloat3D:(ImageTypeFloat3D::Pointer)img Viewer:(ViewerController*)Viewer
{


	ImageTypeFloat3D::SizeType size = img->GetLargestPossibleRegion().GetSize();


	long bufferSize = size[0] * size[1] * size[2];
	long mem = bufferSize * sizeof(float);
	memcpy( [Viewer volumePtr], img->GetBufferPointer(), mem);


}

- (long) filterImage:(NSString*) menuName
{

	DCMView *viewB = [ViewerController imageView];
	// [[viewerController window] setTitle: @" :: Fixed Image"];

	DCMView *viewA = [[ViewerController blendedWindow] imageView];
	// [[[viewerController blendedWindow] window] setTitle: @" :: Moving Image"];

	typedef ITKNS::Image< PixelTypeFloat, 3 > FixedImageType;
	typedef ITKNS::Image< PixelTypeFloat, 3 > MovingImageType;


	const    unsigned int    ImageDimension = 3;
	

	//
	//   Read the Fixed and Moving images.
	//


	FixedImageType::Pointer fixedImage = [self WrapImageFloat3D:viewB];
	MovingImageType::Pointer movingImage = [self WrapImageFloat3D:viewA];


	registration->SetFixedImage(  fixedImage   );
	registration->SetMovingImage( movingImage  );
 
//Registration code no included

	[self UnwrapImageFloat3D:resample->GetOutput() Viewer:viewA];


 

 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20121001/13b253b5/attachment.htm>


More information about the Insight-users mailing list