<br>Would this example help? Constructing a .vtk volume manually.<br><br><a href="http://www.cmake.org/Wiki/VTK/Examples/IterateImageData">http://www.cmake.org/Wiki/VTK/Examples/IterateImageData</a><br><br>Michael<br><br><div class="gmail_quote">
On Wed, Jan 27, 2010 at 10:33 AM, Malsoaz James <span dir="ltr"><<a href="mailto:jmalsoaz@yahoo.fr">jmalsoaz@yahoo.fr</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td style="font-family: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-size: inherit; line-height: inherit; font-size-adjust: inherit; font-stretch: inherit;" valign="top">
I need the ITK images data to do some processes. Thus, I use ITK to read the Dicom series. Then, I need to build "manually" the vtkVolume in order to display it.<br><br>--- En date de : <b>Mer 27.1.10, michiel mentink <i><<a href="mailto:michael.mentink@st-hughs.ox.ac.uk" target="_blank">michael.mentink@st-hughs.ox.ac.uk</a>></i></b> a écrit :<br>
<blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>De: michiel mentink <<a href="mailto:michael.mentink@st-hughs.ox.ac.uk" target="_blank">michael.mentink@st-hughs.ox.ac.uk</a>><div class="im">
<br>Objet: Re: [vtkusers] vtkDataArray: Memory allocation problem<br>À: "Malsoaz James" <<a href="mailto:jmalsoaz@yahoo.fr" target="_blank">jmalsoaz@yahoo.fr</a>><br></div>Cc: "Bill Lorensen" <<a href="mailto:bill.lorensen@gmail.com" target="_blank">bill.lorensen@gmail.com</a>>, <a href="mailto:vtkusers@vtk.org" target="_blank">vtkusers@vtk.org</a><br>
Date: Mercredi 27 Janvier 2010, 9h34<div><div></div><div class="h5"><br><br><div><br>I'm curious, why don't you use the dicomseriesreader? Shown below here is an example to create a metaImage volume,<br>but writing a VTK volume should be
nearly identical:<br><br>int main(int argc, char *argv[])<br>
{<br> if(argc != 3)<br> {<br> vtkstd::cout << "Required arguments: Folder containing .dcm files and also name of OutputFile" << vtkstd::endl;<br> }<br> vtkstd::string folder = argv[1];<br>
vtkstd::string outputFile = argv[2];<br> <br> // Read all the DICOM files in the specified directory.<br> vtkSmartPointer<vtkDICOMImageReader> reader = vtkSmartPointer<vtkDICOMImageReader>::New();<br> reader->SetDirectoryName(folder.c_str());<br>
reader->Update();<br> <br> vtkImageData* imagedata = reader->GetOutput();<br> vtkSmartPointer<vtkMetaImageWriter> metaImageWriter = vtkSmartPointer<vtkMetaImageWriter>::New();<br> metaImageWriter->SetInput(imagedata);<br>
metaImageWriter->SetFileName(outputFile.c_str());<br> metaImageWriter->Update();<br> <br> return 0;<br>}<h2 style="color: rgb(159, 197, 232);"><a rel="nofollow" name="1266f57b7f636294_TOC-CMakeLists.txt"></a> <span></span></h2>
Michael<br><br>
<div class="gmail_quote">
On Wed, Jan 27, 2010 at 8:21 AM, Malsoaz James <span dir="ltr"><<a rel="nofollow" href="http://mc/compose?to=jmalsoaz@yahoo.fr" target="_blank">jmalsoaz@yahoo.fr</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td style="font-family: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-size: inherit; line-height: inherit; font-size-adjust: inherit; font-stretch: inherit;" valign="top">
Thanks for the answer. I guess I need to add some explanation to my application.<br>
<br>
I'm reading a Dicom series using ITK to build a 3D vtk volume. This
part is working well whatever the number of slices. I have no problem
for the allocation with vtkIntArray.<br>
Here is the code for this part:<br>
<br>
<div style="margin-left: 40px;">scalars=vtkIntArray::New();<br>
scalars->SetNumberOfValues(nbPixelX*nbPixelY*nbPixelZ);<br>
<br>
std::vector <ImageType::Pointer>::iterator iterator;<br>
iterator = SlicesList.begin();<br>
<br>
for (unsigned int lz=0;lz<numberOfSlice;lz++)<br>
{<br>
itk::ImageRegionConstIterator<ImageType> inputIt(*iterator, (*iterator)->GetLargestPossibleRegion());<br>
inputIt.GoToBegin();<br>
int currentvalue;<br>
while( !inputIt.IsAtEnd() )<br>
{<br>
lurrentvalue = inputIt.Get();<br>
m_scalars->SetValue(offset,currentvalue);<br>
offset++;<br>
++inputIt;<br>
iterator++;<br>
}<br>
<br>
</div>
As I said, this is working and I have been able to allocate X*Y*Z elements in my vtkIntArray.<br>
<br>
Then, I'm working with ITK to do some process with ITK (threshold,
opening, closing, labeling, ...). At the end, I have the boundaries of
some objects in my slices.<br>
In order to display these boundaries on the vtkVolume, I'm building a
new 3D volume with only the boundaries. Further to this, I'm displaying
the boundaries on the raw volume using Texture. The error of allocation
appears here and only when the number of slices in my volume is
important (more than 300 slices). Here is the code I'm using:<br>
<br>
<div style="margin-left: 40px;">vtkIntArray* scalars = vtkIntArray::New();<br>
scalars->SetNumberOfValues(nbPixelX*nbPixelY*nbPixelZ);<br>
for (points in my boundaries)<br>
{<br>
</div>
<div style="margin-left: 80px;">scalars->SetValue(offset,1);<br>
</div>
<div style="margin-left: 40px;">}<br>
</div>
Note that the error appears at the first "SetValue". I have been trying
to fill the new volume with 0 using "InsertTuple1(offset, 0)". Thus,
I'm able to see where the allocation is crashing. It seems to be around
the 33 555 448th elements. I can't explain why.<br>
<br>
I hope this has clarify my problem.<br>
Best<br>
James<br><br>--- En date de : <b>Mar 26.1.10, Bill Lorensen <i><<a rel="nofollow" href="http://mc/compose?to=bill.lorensen@gmail.com" target="_blank">bill.lorensen@gmail.com</a>></i></b> a écrit :<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;">
<br>De: Bill Lorensen <<a rel="nofollow" href="http://mc/compose?to=bill.lorensen@gmail.com" target="_blank">bill.lorensen@gmail.com</a>><br>Objet: Re: [vtkusers] vtkDataArray: Memory allocation problem<br>À: "Malsoaz James" <<a rel="nofollow" href="http://mc/compose?to=jmalsoaz@yahoo.fr" target="_blank">jmalsoaz@yahoo.fr</a>><br>
Cc: <a rel="nofollow" href="http://mc/compose?to=vtkusers@vtk.org" target="_blank">vtkusers@vtk.org</a><br>Date: Mardi 26 Janvier 2010, 16h10<div><div></div><div><br><br><div>Are there other filters involved in the processing? What does your vtk pipeline look like?<br>
<br><div class="gmail_quote">On Tue, Jan 26, 2010 at 10:59 AM, Malsoaz James <span dir="ltr"><<a rel="nofollow" href="http://mc/compose?to=jmalsoaz@yahoo.fr" target="_blank">jmalsoaz@yahoo.fr</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td style="font-family: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-size: inherit; line-height: inherit; font-size-adjust: inherit; font-stretch: inherit;" valign="top">
Hello,<br><br>First of all, I would like to expose the context of my problem. I'm working on an application which is in charge of loading/building a 3D volume from Dicom files. The building of the 3D volume is working perfectly using a vtkIntArray and setScalars(). <br>
<br><br>Unfortunately, later in the software, I need to rebuild a new 3D volume using one more time vtkIntArray with the same size but I got an error like: vtkIntArray: Unable to allocate X elements of size 4. Although I have enough memory (I have 3Go of RAM), I'm doing exactly the same thing as the first build and the charge on Windows for the application is always under 1Go. My application is working with small volume (ie 150 slices) and I got this allocation error with big volume (ie more than 300 slices).<br>
For information, the images have a size of 512*512.<br><br>Do you know what is the
origin of the problem? How can I solve this ?<br><br><br>Best<br>James<br></td></tr></tbody></table><br>
<br>_______________________________________________<br>
Powered by <a rel="nofollow" href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a rel="nofollow" href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a rel="nofollow" href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a rel="nofollow" href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><br>
</div></div></div></blockquote></td></tr></tbody></table><br>
<br>_______________________________________________<br>
Powered by <a rel="nofollow" href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a rel="nofollow" href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a rel="nofollow" href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a rel="nofollow" href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><br>
</div></div></div></blockquote></td></tr></tbody></table><br>
</blockquote></div><br>