[Insight-users] Using ImportFilter and PasteImageFilter
Quent
quentin.bezsilko at gmail.com
Thu May 6 08:57:26 EDT 2010
Hi Todd,
Thanks for your answer.
You're right, I increment the pointer in order to fill it but just after the
"for" loop, I decrement it in order to be back at the beginning of the
pointer. Do you think it is still wrong ?
Thanks,
Quentin
Todd Jensen wrote:
>
>
>
>
>
>
> ________________________________
> From: "insight-users-request at itk.org" <insight-users-request at itk.org>
> To: insight-users at itk.org
> Sent: Thu, May 6, 2010 4:50:57 AM
> Subject: Insight-users Digest, Vol 73, Issue 19
>
> Send Insight-users mailing list submissions to
> insight-users at itk.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
> http://www.itk.org/mailman/listinfo/insight-users
> or, via email, send a message with subject or body 'help' to
> insight-users-request at itk.org
>
> You can reach the person managing the list at
> insight-users-owner at itk.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Insight-users digest..."
>
>
> Today's Topics:
>
> 1. Re: Using ImportFilter and PasteImageFilter (Quent)
> 2. Re: Wrapping ITK in OSX 10.6 (Lassi Paavolainen)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Thu, 6 May 2010 00:30:13 -0700 (PDT)
> From: Quent <quentin.bezsilko at gmail.com>
> Subject: Re: [Insight-users] Using ImportFilter and PasteImageFilter
> To: insight-users at itk.org
> Message-ID: <28470202.post at talk.nabble.com>
> Content-Type: text/plain; charset=UTF-8
>
> In the following lines:
> -------------------------
> unsigned long i, x;
> float * fImage;
> pixList =
> [new2DViewer pixList];
> for(i=0;i<[pixList count]; i++){
> curPix = [pixList objectAtIndex:i];
> x = height * width;
> fImage = [curPix fImage];
> while(x>0){
>
> *localBuffer = *fImage;
> localBuffer++;
>
> cptLocalBuffer++;
> fImage++;
> x--;
>
> }
> }
> -----------------------
>
> you are incrementing the pointer to your allocated buffer (localBuffer++).
> So, when you use it later in:
>
> -----------------------
> importFilter->SetImportPointer(localBuffer, numberOfPixels, true);
> -----------------------
>
> It is no longer pointing to the memory space you allocated but just beyond
> that leading to your unexpected crash. You should rewrite you pixel copy
> code to something like:
>
> -------------------------
> unsigned long i, x;
> x = height * width;
> float * fImage;
> float* tmpLocalBufferPtr;
> tmpLocalBufferPtr = localBuffer;
> pixList =
> [new2DViewer pixList];
> for(i=0;i<[pixList count]; i++){
> memcpy( tmpLocalBufferPtr, [curPix fImage], x);
> tmpLocalBufferPtr += x;
> }
> -----------------------
>
> Todd Jensen
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>
>
--
View this message in context: http://old.nabble.com/Using-ITK-with-XCode-tp6529684p28473235.html
Sent from the ITK - Users mailing list archive at Nabble.com.
More information about the Insight-users
mailing list