[vtkusers] image scalar range problem[solved]

liulewes lewes_infor at hotmail.com
Fri Dec 14 12:24:40 EST 2012


Just figured out that 
            temp->SetExtent(0,511,0,511,0,1); should be             temp->SetExtent(0,511,0,511,0,0);
in order to have just one slice.

From: lewes_infor at hotmail.com
To: vtkusers at vtk.org
Date: Fri, 14 Dec 2012 11:48:04 -0500
Subject: [vtkusers] image scalar range problem




I'm tring to create an image and assign scalars manually. I think I should get a scalar range of [1,1] for the following code,  but I get [1,52680] instead. Is it the problem of the assignment part or the GetScalarRange function or anything else?

    vtkImageData* temp = vtkImageData::New();
            temp->SetScalarTypeToUnsignedShort();
            temp->SetSpacing(1,1,0);
            temp->SetOrigin(0,0,0);
            temp->SetExtent(0,511,0,511,0,1);
            temp->SetNumberOfScalarComponents(1);
            temp->AllocateScalars();

            for (int i = 0 ; i < 512 ; ++i)
            {
                for (int j = 0 ; j < 512 ; ++j)
                {
                    *(static_cast<unsigned short*>(temp->GetScalarPointer(i,j,0))) = 1;
                }
            }

            temp->Modified();
            temp->GetPointData()->GetScalars()->Modified();
            double dtrangetemp[2];
            temp->GetScalarRange(dtrangetemp);
 		 	   		  

_______________________________________________
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 VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20121214/fc26b634/attachment.htm>


More information about the vtkusers mailing list