[Insight-users] itkRegionOfInterestImageFilter question

freiman at cs.huji.ac.il freiman at cs.huji.ac.il
Wed Aug 10 10:43:34 EDT 2005


Hello!
I have the follwoing problem.
i read A 3D image, then extract a region of interest and save it.
when i try to read the extracted region again, i got a garbage image.
below is my code:

//reading part
        VoxIo::Pointer imageio = VoxIo::New();
	imageio->SetFileDimensionality (3);
	imageio->SetDimensions (0,dim_x);
	imageio->SetDimensions (1,dim_y);
	imageio->SetDimensions (2,dim_z);
	imageio->SetByteOrderToLittleEndian();
	imageio->SetSpacing (0, spacing_x);
	imageio->SetSpacing (1, spacing_y);
	imageio->SetSpacing (2, spacing_z);
	imageio->SetOrigin (0,origin_x);
	imageio->SetOrigin (1,origin_y);
	imageio->SetOrigin (2,origin_z);
	imageio->SetHeaderSize (512);
	imageio->SetFileTypeToBinary();
	
	ReaderType::Pointer reader = ReaderType::New();
	reader->SetFileName(volumeName.c_str());
	reader->SetImageIO (imageio);
	reader->Update();

//extract roi part
	ImageType::Pointer image = reader->GetOutput();
        ImageType::IndexType start;
	start[0] = min_x;
	start[1] = min_y;
        start[2] = min_z;
    	
	ImageType::SizeType size;
	size[0] = max_x - min_x;
	size[1] = max_y - min_y;
	size[2] = max_z - min_z;

	ImageType::RegionType desiredRegion;
	desiredRegion.SetSize( size );
	desiredRegion.SetIndex( start );
	
	ROIFilterType::Pointer _filter = ROIFilterType::New();

	
	_filter->SetInput (reader->GetOutput());
        _filter->Update();
        

//writing partwhere extent hold new image extent and spacing hold image
spacing

        VoxIo::Pointer imageio = VoxIo::New();
	imageio->SetFileDimensionality (3);
	imageio->SetDimensions (0,extent[1]-extent[0]);
	imageio->SetDimensions (1,extent[3]-extent[2]);
	imageio->SetDimensions (2,extent[5]-extent[4]);
	imageio->SetByteOrderToLittleEndian();
	imageio->SetSpacing (0, spacing[0]);
	imageio->SetSpacing (1, spacing[1]);
	imageio->SetSpacing (2, spacing[2]);
	imageio->SetOrigin (0,extent[0]);
	imageio->SetOrigin (1,extent[2]);
	imageio->SetOrigin (2,extent[4]);
	imageio->SetHeaderSize (512);
	imageio->SetFileTypeToBinary();
	
		
	

	WriterType::Pointer writer = WriterType::New();

	writer->SetInput (_filter->GetOutput());
	writer->SetImageIO (imageio);
	writer->SetFileName (filename.c_str());
        writer->Update();
//////////////////////end/////////////////////////////////////
then when i try to read the region i saved before i got a garbage image,
thanks.
moti
__
Moti Freiman, Graduate Student.
Medical Image Processing and Computer-Assisted Surgery Laboratory.
School of Computer Science and Engineering.
The Hebrew University of Jerusalem Givat Ram, Jerusalem 91904, Israel
Phone: +(972)-2-658-5371 (laboratory)
E-mail: freiman at cs.huji.ac.il
WWW site: http://www.cs.huji.ac.il/~freiman



--------------------------------------------------------------------
mail2web - Check your email from the web at
http://mail2web.com/ .




More information about the Insight-users mailing list