<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:΢ÈíÑźÚ
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>Just figured out that <br> temp->SetExtent(0,511,0,511,0,1); should be temp->SetExtent(0,511,0,511,0,0);<br>in order to have just one slice.<br><br><div><div id="SkyDrivePlaceholder"></div><hr id="stopSpelling">From: lewes_infor@hotmail.com<br>To: vtkusers@vtk.org<br>Date: Fri, 14 Dec 2012 11:48:04 -0500<br>Subject: [vtkusers] image scalar range problem<br><br>
<style><!--
.ExternalClass .ecxhmmessage P
{padding:0px;}
.ExternalClass body.ecxhmmessage
{font-size:12pt;font-family:\005fae\008f6f\0096c5\009ed1;}
--></style>
<div dir="ltr">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?<br><br> vtkImageData* temp = vtkImageData::New();<br> temp->SetScalarTypeToUnsignedShort();<br> temp->SetSpacing(1,1,0);<br> temp->SetOrigin(0,0,0);<br> temp->SetExtent(0,511,0,511,0,1);<br> temp->SetNumberOfScalarComponents(1);<br> temp->AllocateScalars();<br><br> for (int i = 0 ; i < 512 ; ++i)<br> {<br> for (int j = 0 ; j < 512 ; ++j)<br> {<br> *(static_cast<unsigned short*>(temp->GetScalarPointer(i,j,0))) = 1;<br> }<br> }<br><br> temp->Modified();<br> temp->GetPointData()->GetScalars()->Modified();<br> double dtrangetemp[2];<br> temp->GetScalarRange(dtrangetemp);<br>                                            </div>
<br>_______________________________________________
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</div>                                            </div></body>
</html>