I will give you more details about how I did.<br>It is a function with (int argc, IDL_VPTR argv[]) as arguments<br>First argument is an array passed thanks to IDL<br>At the moment, I&#39;m working on 16 bits DICOM (short type) with size : 512*512 and using them works fine
<br>All the problem I have is to return the array modified back to IDL, here is my code :<br><br><br>typedef&nbsp; short InputPixelType;&nbsp; <br>typedef&nbsp; short OutputPixelType;<br>const unsigned int Dimension = 2;<br>typedef itk::Image&lt; InputPixelType,&nbsp; Dimension &gt;&nbsp;&nbsp; InputImageType;
<br>typedef itk::Image&lt; OutputPixelType, Dimension &gt;&nbsp;&nbsp; OutputImageType;<br><br>IDL_VPTR src,dest;&nbsp;&nbsp; // variables to import / export the picture from / to IDL<br>InputPixelType *src_d,*dest_d;<br>src = argv[0];&nbsp;&nbsp; // array 512*512
<br>src_d = (InputPixelType *)src-&gt;value.s.arr-&gt;data; // way to get the data from the IDL variable<br><br><br>// So now I&#39;m using the ImportImageFilter using this array as Input and it works perfectly fine<br><br>
typedef itk::ImportImageFilter&lt; InputPixelType, Dimension &gt;&nbsp;&nbsp; ImportFilterType;<br>ImportFilterType::Pointer importFilter = ImportFilterType::New();&nbsp; <br>ImportFilterType::SizeType&nbsp; size;<br>size[0]&nbsp; = 512;&nbsp; // size along X
<br>size[1]&nbsp; = 512;&nbsp; // size along Y<br>ImportFilterType::IndexType start;<br>start.Fill( 0 );<br>ImportFilterType::RegionType region;<br>region.SetIndex( start );<br>region.SetSize(&nbsp; size&nbsp; );<br>importFilter-&gt;SetRegion( region );
<br>double origin[ Dimension ];<br>origin[0] = 0.0;&nbsp;&nbsp;&nbsp; // X coordinate <br>origin[1] = 0.0;&nbsp;&nbsp;&nbsp; // Y coordinate<br>importFilter-&gt;SetOrigin( origin );<br>double spacing[ Dimension ];<br>spacing[0] = 0.21484;&nbsp;&nbsp;&nbsp; // along X direction 
<br>spacing[1] = 0.21484;&nbsp;&nbsp;&nbsp; // along Y direction<br>importFilter-&gt;SetSpacing( spacing );<br>const unsigned int numberOfPixels =&nbsp; size[0] * size[1];<br>const bool importImageFilterWillOwnTheBuffer = false;<br>importFilter-&gt;SetImportPointer( (InputPixelType *)src_d, numberOfPixels,importImageFilterWillOwnTheBuffer );
<br><br>// Just for test I was using a binarythresholdfilter and it is working with it<br><br>typedef itk::BinaryThresholdImageFilter&lt; InputImageType, OutputImageType &gt;&nbsp; FilterType;<br>FilterType::Pointer filter = FilterType::New();
<br>const OutputPixelType outsideValue = 0;<br>const OutputPixelType insideValue&nbsp; = 255;<br>filter-&gt;SetOutsideValue( outsideValue );<br>filter-&gt;SetInsideValue( insideValue );<br>const InputPixelType lowerThreshold = 0;
<br>const InputPixelType upperThreshold = 500;&nbsp;&nbsp;&nbsp; <br>filter-&gt;SetLowerThreshold( lowerThreshold );<br>filter-&gt;SetUpperThreshold( upperThreshold );<br>filter-&gt;SetInput( importFilter-&gt;GetOutput() );<br><br>// Okay so until now, everything is fine. I can say it works because I used a FileWriter and checked the picture after passing in the filter with :
<br><br>typedef itk::ImageFileWriter&lt; OutputImageType &gt;&nbsp; WriterType;<br>WriterType::Pointer writer = WriterType::New();<br>writer-&gt;SetInput( filter-&gt;GetOutput() );<br>writer-&gt;SetFileName( &quot;e:\\test.dcm&quot; );
<br><br>try<br>{<br>&nbsp;&nbsp;&nbsp; writer-&gt;Update();<br>}<br>catch (itk::ExceptionObject &amp; e)<br>{<br>&nbsp;&nbsp;&nbsp; sprintf(statusbuffer, &quot;Error&quot;);<br>&nbsp;&nbsp;&nbsp; IDL_Message(IDL_M_NAMED_GENERIC,IDL_MSG_INFO, statusbuffer);<br>&nbsp;&nbsp;&nbsp; return src;
<br>&nbsp;}<br><br>// Now is the part where I try to export it back to IDL<br><br>I tried both with ImportImageContainer without succeeding :<br><br>typedef itk::ImportImageContainer&lt;InputPixelType, InputPixelType &gt;&nbsp; ImportContainerType;
<br>ImportContainerType::Pointer importFilter2 = ImportContainerType::New();&nbsp; <br>importFilter2-&gt;SetImportPointer( (InputPixelType *)filter-&gt;GetOutput(), numberOfPixels,false);<br><br>dest_d = (InputPixelType *)
IDL_MakeTempArray(IDL_TYP_INT,dest-&gt;value.arr-&gt;n_dim,dest-&gt;value.arr-&gt;dim,IDL_ARR_INI_INDEX,&amp;paf);&nbsp; // this allows to create an array with the same dimensions. each element of the array is set to the value of its index.&nbsp; (it works I get an array with the right dimensions and with the values back)
<br><br>dest_d = (InputPixelType *)importFilter2-&gt;GetBufferPointer();&nbsp; // I try to get the array from the binary filter<br><br>return dest;&nbsp; // return the IDL_VPTR variable to IDL containing the array.&nbsp; The result in IDL is the array with each element is set to the value of its index as if the GetBufferPointer didn&#39;t have any effect on the variable. I tried also with the GetImportPointer but the result is the same.
<br><br>I tried in a similar way with the ImportImageFilter but the result was still the same.<br><br>I hope that you understand better my problem like this and would really be glad to be helped because I have tried for a long time studying the problem without succeeding.
<br><br>Regards,<br><br>Frédéric<br><br><br><br><div><span class="gmail_quote">On 5/21/07, <b class="gmail_sendername">Frédéric Stevens</b> &lt;<a href="mailto:frederic.stevens@gmail.com">frederic.stevens@gmail.com</a>&gt; wrote:
</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi,<br><br>I have successfully imported an array using ImportImageFilter, used some filters on it and I can write it on the hard disk using ImageFileWriter. Instead of creating a new file, I would like to return this array in the same way as I imported it. (I am using an image imported from IDL and I would like to export it back with the filters applied).
<br>Is there a function that allows to do this operation&nbsp; ?&nbsp; <br><br>Many thanks,<br><span class="sg"><br>Frédéric<br>
</span></blockquote></div><br>