creating an image

Tim Hutton T.Hutton at eastman.ucl.ac.uk
Thu Dec 16 12:55:50 EST 1999


Solved my problem of how to create an image. The trick is to leave
vtkImage* well alone and use vtkStructuredPoints:

	vtkStructuredPoints *im = vtkStructuredPoints::New();

	im->SetDimensions(X,Y,1);

	vtkScalars *scalars = vtkScalars::New();
	scalars->SetNumberOfScalars(X*Y);

	im->GetPointData()->SetScalars(scalars);

	int x,y;
	for(x=0;x<X;x++)
		for(y=0;y<Y;y++)
			scalars->SetScalar(y*X+x,image.get(x,y)*255.0F);

	return im;

Just thought someone else might find this useful.

Cheers,

Tim.

At 12:20 16/12/99 -0500, you wrote:
>Hi Tim,
>
>There is a vtkImageImport class, it didn't make it into VTK 2.4
>but it is in the nightlies.
>
>It allows the vtk imaging pipeline to use a block of C++ memory 
>'in place,' i.e. it simply uses a C++ pointer as the source of
>the imaging pipeline.
>
>http://vtk.scorec.rpi.edu/Nightly/Doc/manhtml/vtkImageImport.html
>
> - David
>
>P.S. Thanks for the support on the vtkGeneralTransform issue.
>     I've prodded the Kitware folks a couple times about this,
>     but have never received a reply.
>
>--
>  David Gobbi, MSc                    dgobbi at irus.rri.on.ca
>  Advanced Imaging Research Group
>  Robarts Research Institute, University of Western Ontario
>
>On Thu, 16 Dec 1999, Tim Hutton wrote:
>
>> Quick question, how do you create a new image now? I want something very
>> similar to the code on p450 of the book, but updated for vtk2.4
>> (vtkImageRegion no longer exists). Everything I'm trying makes my code
>> crash, presumably because things aren't being allocated properly.
>> 
>> Here's an example of what I've been trying:
>> 
>> 	vtkImageCache *im = (vtkImageCache*)vtkImageCache::New();
>> 
>> 	im->SetWholeExtent(0,100,0,100,0,0);
>> 	im->SetUpdateExtent(0,100,0,100,0,0);
>> 
>> 	int x,y;
>> 	for(x=0;x<100;x++)
>> 	{
>> 		for(y=0;y<100;y++)
>> 		{
>> 			*(float*)(im->GetData()->GetScalarPointer(x,y,0)) = 0.0F;
>> 		}
>> 	}
>> 
>> 	return im;
>> 
>> Crashes most reliably.
>> 
>> Cheers,
>> 
>> Tim.
>> ---------------------------------------------------------------------------
>> Tim Hutton, Research Assistant            Email: T.Hutton at eastman.ucl.ac.uk
>> MINORI Project                     http://www.eastman.ucl.ac.uk/~dmi/MINORI
>> Dental and Medical Informatics                   Tel: [+44] (0171) 915 2344
>> Eastman Dental Institute, UCL                    Fax: [+44] (0171) 915 2303
>> 256 Gray's Inn Road, London WC1X 8LD, UK
>> ---------------------------------------------------------------------------
>> This email represents the views of the sender alone and must not be
>> construed as representing the views of the Eastman Dental Institute. It may
>> contain confidential information and may be protected by law as a legally
>> privileged document and copyright work. Its content should not be disclosed
>> and it should not be given or copied to anyone other than the person(s)
>> named or referenced above. If you have received this email in error, please
>> contact the sender.
>> 
>> 
>> 
>>
-----------------------------------------------------------------------------
>> This is the private VTK discussion list.  Please keep messages on-topic.
>> Check the FAQ at: <http://www.automatrix.com/cgi-bin/vtkfaq>
>> To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
>> <majordomo at gsao.med.ge.com>.  For help, send message body containing
>> "info vtkusers" to the same address.     Live long and prosper.
>>
-----------------------------------------------------------------------------
>> 
>
>
>


-----------------------------------------------------------------------------
This is the private VTK discussion list.  Please keep messages on-topic.
Check the FAQ at: <http://www.automatrix.com/cgi-bin/vtkfaq>
To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
<majordomo at gsao.med.ge.com>.  For help, send message body containing
"info vtkusers" to the same address.     Live long and prosper.
-----------------------------------------------------------------------------




More information about the vtkusers mailing list