[Insight-users] Output Problem with PasteImageFilter!

doege at zedat.fu-berlin.de doege at zedat.fu-berlin.de
Thu Jun 18 03:42:06 EDT 2009


Hello Hector,

I had the same problem, you are putting all slices to the same position.
You have to remeber the index of the extracted slice is (0,0,0) and the
index of yor 3D image is (0,0,i).
My code looks like this:
startSlice[2] = sliceNumber; //iterator i
regionSlice.SetIndex(start); //start (0,0,0)

//slices into a 3d image
pasteImageFilter-> SetDestinationIndex(startSlice);// (0,0,i) the index
where you wanna put the slice
pasteImageFilter-> SetSourceRegion(regionSlice);  //index (0,0,0), the
index of the extracted slice, and your slice size (x,y,1)
pasteImageFilter-> SetDestinationImage(Image);
pasteImageFilter-> SetSourceImage(castImage2Dto3DFilter->GetOutput());

Hope that helps,
best regards
Juliane

>
> Hello to everyone!
>
> I think my last post was lost somewhere, or just didn't get enough
> attention...
>
> I already solved some of my issues, looking through older posts, so now I
> came with an specific problem.
>
> The thing is that I'm using a PasteImageFilter, to make a 3D volume coming
> from 2D slices, but at the end I use a ImageFileWriter to write the 3D
> volume as an .img volume (.img .hdr), but when I read it, the new volume
> just has as the first image, the last slice read and pasted in my process,
> and the rest of the volume is just empty.
>
> This is what I'm doing:
>
> ImportFilter (2D slices from OsiriX) -> castFilter (to change from 2D
> slices
> to 3D with one slice) -> pasteFilter (first allocate the imageVolume with
> the size of the volume I want in this case 256x256x54) -> smoothFilter
> (passing the entire volume 3D) ->writeFilter(to write the image as .im
> .hdr
> volume).
>
> I tried many ways and recommendations from older posts, and also saw many
> times the same problem as mine but non of them has an answer, so I hope
> someone may help me this time.
>
> this is part of my code: (I hope the problem is just something I miss)
>
> The destination volume for the 2D slices is first allocated like:
>
> //////////////Setup and Allocating imageVolume
> ImageType3D::Pointer	imageVolume=ImageType3D::New();
> ImageType3D::IndexType	destVolIndex;
> ImageType3D::SizeType	sizeVolImage;
> ImageType3D::RegionType regionVolImage;
>
> //////////////////// 3D imageVolume index
> 	destVolIndex[0] = 0;
> 	destVolIndex[1] = 0;
> 	destVolIndex[2] = 0;
>
> 	sizeVolImage[0] = imageWidth; ///took this data from the same data
> ImportFilter will
> 	sizeVolImage[1] = imageHeight;
> 	sizeVolImage[2] = [pixList count];
>
> 	regionVolImage.SetSize(sizeVolImage);
> 	regionVolImage.SetIndex(destVolIndex);
>
> 	imageVolume->SetRegions(regionVolImage);
> 	imageVolume->Allocate();
>
> /////I have 54 2D slices of 256x256 to make a 3D volume of 256x256x54
>
> /////I take on sliceImage2D the output of importFilter inside a for loop
>
> for(i=0; i < [pixList count]; i++)
> {
> 	curPix= [pixList	objectAtIndex: i]; //for loop to read the slices
>
> 	..... setup of importFilter....
>
> 	sliceImage2D = importFilter->GetOutput();
>
> 	/////Cast the slice from 2D to 3D with one slice
> 	caster->SetInput(sliceImage2D);
>
> 	caster->UpdateLargestPossibleRegion();
> 	caster->Update();
> 	sliceImage3D = caster -> GetOutput();
>
> 	//////////PasteImageFilter setup
> 	destVolIndex[0] = 0;
> 	destVolIndex[1] = 0;
> 	destVolIndex[2] = i;//Takes the number of read slice from for loop
>
> 	paster -> ResetPipeline();
> 	paster -> SetDestinationImage(imageVolume);
> 	paster -> SetDestinationIndex(destVolIndex);
>
> 	paster -> SetSourceImage(sliceImage3D);
> 	paster -> SetSourceRegion(sliceImage3D->GetLargestPossibleRegion());
>
>
> 	try
> 	{
> 		paster->UpdateLargestPossibleRegion();
> 		paster->Update();
> 		imageVolume = paster->GetOutput();
>
> 	}
> 	catch(itk::ExceptionObject & excp)
> 	{
> 		std::cerr <<"Exception thrown while pasting the Images" << std::endl;
> 		std::cerr <<excp<<std::endl;
> 	}
>
> }/////END of for loop
>
> 	/////Now I send the imageVolume to be smoothed as a 3D volume
> 	imageVolume->Update();
>
> 	///////////3D smoothing DiscreteGaussianImageFilter and
> RescalerIntensityImageFilter
>
> 	smooth->SetInput(imageVolume);
> 	//smooth->SetInput(paster->GetOutput()); ///I tried both!!
>
> 	try
> 	{
> 		smooth->Update();
> 	}
> 	catch(itk::ExceptionObject & excp)
> 	{
> 		std::cerr <<"Exception thrown while smoothing the 3D volume" <<
> std::endl;
> 		std::cerr <<excp<<std::endl;
> 	}
>
>
> 	//////////RescaleIntensityImageFilter
> 	rescaler->SetInput(smooth->GetOutput());
>
> 	//////////ImageFileWriter
> 	writer->SetInput(rescaler->GetOutput());
> 	writer->Update();
>
>
> The most of my trials I get just one slice on the 3D volume, having the 54
> slices the first is the last slice read and the other 53 are just black
> space.
>
> Any help?? Ideas??? someone please HELP!
>
> Hector
>
> --
> View this message in context:
> http://n2.nabble.com/Output-Problem-with-PasteImageFilter%21-tp3095177p3095177.html
> Sent from the ITK Insight Users mailing list archive at Nabble.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 ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>




More information about the Insight-users mailing list