<div dir="ltr"><div>I see, ArrayFromImage really wants an itk.Image (unlike ITK filters for which inheritance seems to work). Then you can just do the same trick as when converting from CPU to GPU image:</div><div><span style="font-family:monospace">feldkamp.Update()</span></div><div><span style="font-family:monospace">fdk = CPUImageType.New()<br>fdk.SetPixelContainer(feldkamp.GetOutput().GetPixelContainer())<br>fdk.CopyInformation(feldkamp.GetOutput())<br>fdk.SetBufferedRegion(feldkamp.GetOutput().GetBufferedRegion())<br>fdk.SetRequestedRegion(feldkamp.GetOutput().GetRequestedRegion())<br>itk.array_from_image(fdk)</span></div><div><br></div><div>PS: I won't answer next time if you don't use the mailing list....<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Nov 27, 2023 at 8:18 AM Fuquan Deng <<a href="mailto:dfq_2022@163.com">dfq_2022@163.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="line-height:1.7;color:rgb(0,0,0);font-size:14px;font-family:Arial"><div style="margin:0px"><div style="background-color:rgb(43,43,43);color:rgb(169,183,198);font-family:"JetBrains Mono",monospace;font-size:9.8pt;white-space:pre-wrap"><span style="color:rgb(128,128,128)"># </span><span style="color:rgb(128,128,128);font-family:"\005b8b\004f53",monospace">重建<br></span>feldkamp = rtk.CudaFDKConeBeamReconstructionFilter.New()<br>feldkamp.SetInput(<span style="color:rgb(104,151,187)">0</span><span style="color:rgb(204,120,50)">, </span>constantImageSource.GetOutput())<br>feldkamp.SetInput(<span style="color:rgb(104,151,187)">1</span><span style="color:rgb(204,120,50)">, </span>projections)<br>feldkamp.SetGeometry(geometry)<br><span style="color:rgb(128,128,128)"># feldkamp.GetRampFilter().SetTruncationCorrection(0.0)<br></span><span style="color:rgb(128,128,128)"># feldkamp.GetRampFilter().SetHannCutFrequency(0.0)<br></span>feldkamp.Update()<br><br><span style="color:rgb(128,128,128)"># Writer<br></span><span style="color:rgb(128,128,128)"># print("Writing output image...")<br></span><span style="color:rgb(128,128,128)"># WriterType = rtk.ImageFileWriter[CPUImageType]<br></span><span style="color:rgb(128,128,128)"># writer = WriterType.New()<br></span><span style="color:rgb(128,128,128)"># writer.SetFileName(filename)<br></span><span style="color:rgb(128,128,128)"># writer.SetInput(feldkamp.GetOutput())<br></span><span style="color:rgb(128,128,128)"># writer.Update()<br></span>image = itk.GetArrayFromImage(feldkamp.GetOutput())<br><span style="color:rgb(204,120,50)">return </span>image</div></div><div style="margin:0px"><br></div><div style="margin:0px">Traceback (most recent call last):</div><p style="margin:0px">  File "/home/ctwork/workstation/ctwork/completeRAC/reconstruct.py", line 108, in <module></p><p style="margin:0px">    reconstruction(image, geoFile, spacing=spacing, spacingOut=0.14, sizeOutput=1024,filename="temp1.mhd")</p><p style="margin:0px">  File "/home/ctwork/workstation/ctwork/completeRAC/reconstruct.py", line 71, in reconstruction</p><p style="margin:0px">    image = itk.GetArrayFromImage(feldkamp.GetOutput())</p><p style="margin:0px">  File "/home/ctwork/software/anaconda3/lib/python3.9/site-packages/itk/support/extras.py", line 335, in GetArrayFromImage</p><p style="margin:0px">    return _GetArrayFromImage(</p><p style="margin:0px">  File "/home/ctwork/software/anaconda3/lib/python3.9/site-packages/itk/support/extras.py", line 314, in _GetArrayFromImage</p><p style="margin:0px">    raise RuntimeError("No suitable template parameter can be found.")</p><p style="margin:0px">RuntimeError: No suitable template parameter can be found.</p><div><br></div><p style="margin:0px"><br></p><p style="margin:0px"><br></p><p style="margin:0px"><br></p><p style="margin:0px"><br></p><div></div><div id="m_6942276993200787034divNeteaseMailCard"></div><p style="margin:0px"><br></p><p>在 2023-11-27 14:55:16,"Simon Rit" <<a href="mailto:simon.rit@creatis.insa-lyon.fr" target="_blank">simon.rit@creatis.insa-lyon.fr</a>> 写道:</p><blockquote id="m_6942276993200787034isReplyContent" style="padding-left:1ex;margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204)"><div dir="ltr"><div>Please stick to the mailing list.</div><div>It should, what is the error message?<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Nov 27, 2023 at 7:53 AM Fuquan Deng <<a href="mailto:dfq_2022@163.com" target="_blank">dfq_2022@163.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="line-height:1.7;color:rgb(0,0,0);font-size:14px;font-family:Arial"><p style="margin:0px">Thanks for your answer. i convert itk.CudaImage to numpy.array after reconstruction by fdk. But it showed error when i use itk.GetArrayFromImage. Does itk not support to convert itk.CudaImage to numpy.array?</p><p style="margin:0px"><br></p><p style="margin:0px"><br></p><div></div><div id="m_6942276993200787034m_-452995294325862562divNeteaseMailCard"></div><p style="margin:0px"><br></p><p>At 2023-11-27 14:00:23, "Simon Rit" <<a href="mailto:simon.rit@creatis.insa-lyon.fr" target="_blank">simon.rit@creatis.insa-lyon.fr</a>> wrote:</p><blockquote id="m_6942276993200787034m_-452995294325862562isReplyContent" style="padding-left:1ex;margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204)"><div dir="ltr"><div>Hi,</div><div>You can find <a href="https://github.com/RTKConsortium/RTK/blob/master/examples/FirstReconstruction/FirstCudaReconstruction.py#L70-L76" target="_blank">here</a> how to convert an itk.Image to an itk.CudaImage. An itk.CudaImage is an itk.Image (by inheritance) so you should not need to convert it, just use it as if it were an itk.Image, as illustrated in the same example <a href="https://github.com/RTKConsortium/RTK/blob/master/examples/FirstReconstruction/FirstCudaReconstruction.py#L91" target="_blank">here</a>. Or have I missed something?</div><div>Simon<br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Nov 26, 2023 at 4:06 PM Fuquan Deng <<a href="mailto:dfq_2022@163.com" target="_blank">dfq_2022@163.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="line-height:1.7;color:rgb(0,0,0);font-size:14px;font-family:Arial"><div>Dear simon,</div><div><br></div><div>althought do not the theory of  transforming numpy.array to cuda image, I succeed.</div><div>but now i have other question.</div><div>how to transform cudaimage to itk.Image, and then use GetArrayFromImage to transform to numpy.array?  </div><div><br></div><div>i have read the itk and rtk documents and can not find the answer. Use GPT and get wrong answer. So i come to here and send email to ask you about this. Does rtk-python support this?</div><div>Thanks and look forward to your reply.</div><div><br></div><div>Fuquan Deng</div></div></blockquote></div>
</blockquote></div></blockquote></div>
</blockquote></div></blockquote></div>