[Insight-users] masking part of an image
shoosh moosh
babygirl_25 at hotmail.com
Mon Apr 20 11:14:10 EDT 2009
Thanks!!! You're absolutely right. But it should be
outputImage->SetRegions(inputImage->GetBufferedRegion());
instead of
outputImage->SetRegions(inputMaskImage->GetBufferedRegion());
because inputImage is the one like the outputImage not inputMaskImage..
Thanks a lot.
Date: Mon, 20 Apr 2009 11:45:17 +1000
Subject: Re: [Insight-users] masking part of an image
From: nadan.zhu at gmail.com
To: babygirl_25 at hotmail.com
CC: insight-users at itk.org
Hi, from your code, it seems that you forgot to allocate memory for your output image.
try to add
outputImage->SetRegions(inputMaskImage->GetBufferedRegion());
outputImage->Allocate();
before the loop.
bill.lorensen at gmail.com,
2009/4/20 shoosh moosh <babygirl_25 at hotmail.com>
This is what I got when I printed them:
Image (0x857c040)
RTTI typeinfo: itk::Image<short, 3u>
Reference Count: 2
Modified Time: 205
Debug: Off
Observers:
none
Source: (0x8579948)
Source output index: 0
Release Data: Off
Data Released: False
Global Release Data: Off
PipelineMTime: 27
UpdateMTime: 206
LargestPossibleRegion:
Dimension: 3
Index: [0, 0, 0]
Size: [540, 520, 720]
BufferedRegion:
Dimension: 3
Index: [0, 0, 0]
Size: [540, 520, 720]
RequestedRegion:
Dimension: 3
Index: [0, 0, 0]
Size: [540, 520, 720]
Spacing: [1, 1, 1]
Origin: [0, 0, 0]
Direction
:
1 0 0
0 1 0
0 0 1
IndexToPointMatrix:
1 0 0
0 1 0
0 0 1
PointToIndexMatrix:
1 0 0
0 1 0
0 0 1
PixelContainer:
ImportImageContainer (0x857c1f8)
RTTI typeinfo: itk::ImportImageContainer<unsigned long, short>
Reference Count: 1
Modified Time: 203
Debug: Off
Observers:
none
Pointer: 0x9fb12008
Container manages memory: true
Size: 202176000
Capacity: 202176000
Image (0x857e938)
RTTI typeinfo: itk::Image<unsigned char, 3u>
Reference Count: 2
Modified Time: 3
57
Debug: Off
Observers:
none
Source: (0x857c240)
Source output index: 0
Release Data: Off
Data Released: False
Global Release Data: Off
PipelineMTime: 28
UpdateMTime: 358
LargestPossibleRegion:
Dimension: 3
Index: [0, 0, 0]
Size: [540, 520, 720]
BufferedRegion:
Dimension: 3
Index: [0, 0, 0]
Size: [540, 520, 720]
RequestedRegion:
Dimension: 3
Index: [0, 0, 0]
Size: [540, 520, 720]
Spacing: [1, 1, 1]
Origin: [0, 0, 0]
Direction:
1 0 0
0 1 0
0 0 1
IndexToPointMatrix:
1 0 0
0 1 0
0 0 1
PointToIndexMatrix:
1 0 0
0 1 0
0 0 1
Pi
xelContainer:
ImportImageContainer (0x857eaf0)
RTTI typeinfo: itk::ImportImageContainer<unsigned long, unsigned char>
Reference Count: 1
Modified Time: 355
Debug: Off
Observers:
none
Pointer: 0x93a42008
Container manages memory: true
Size: 202176000
Capacity: 202176000
I think they are the same size, right? However one is a an image of short's while the other is of unsigned char's.
> Date: Sun, 19 Apr 2009 15:35:53 -0400
> Subject: Re: [Insight-users] masking part of an image
> From: bill.lorensen at gmail.com
> To: babygirl_25 at hotmail.com
&g
t; CC: insight-users at itk.org
>
> Are the input and input mask the same size? Try printing them.
> inputImage->Print(std::cout);
> inputMaskImage->Print(std::cout);
>
> after the Update's
>
> 2009/4/19 shoosh moosh <babygirl_25 at hotmail.com>:
> > Ok, I added the reader->Update(), but now I'm getting a different error:
> > Segmentation fault
> >
> > The program apparently crashes in the for loop.
> >
> > I think something might be wrong with lines 64-65, but I'm not sure what.
> > inputImage=reader1->GetOutput();
> > inputMaskImage=reader2->GetOutput();
> >
> > I attached the code again.
> > Thanks
> >
> >
> >
> >> Date: Sun, 19 Apr 2009 14:57:47 -0400
> >> Subject: Re: [Insight-users] masking part of an image
> >> From: bill.lorensen at gmail.com
> >> To: babygirl_25 at hotmail.com
> >> CC: insight-users at itk.org
> >>
> >> Do a reader1->Update() and reader2->Update() before accessing the
> >> outputs of the reader.
> >>
> >> 2009/4/19 shoosh moosh <babygirl_25 at hotmail.com>:
> >> > Hi,
> >> > I wrote up a program that takes as input 2 images - a 3D image, and a 3D
> >> > binary mask image with 0's in the parts im not interested and 1's in the
> >> > parts I want to segment out. I want the program to simply multiply each
> >> > pixel in the original image with the corresponding pixel in the masking
> >> > image and produce a third image of the same size having only the region
> >> > specified by 1's in the mask. The code compiles, but when I run it, I
> >> > get
> >> > this error:
> >> &
gt;
> >> > terminate called after throwing an instance of 'itk::ExceptionObject'
> >> > what():
> >> > /home/shoosh/InsightToolkit-3.10.2/Code/IO/itkNrrdImageIO.cxx:951:
> >> > itk::ERROR: NrrdImageIO(0x8585a50): Write: Error wrapping nrrd for
> >> > output.nhdr:
> >> > [nrrd] nrrdWrap_nva:
> >> > [nrrd] _nrrdSizeCheck: axis 0 size is zero!
> >> >
> >> > Can some one tell me how to fix it. the code is attached.
> >> >
> >> >
> >> >
> >> > ________________________________
> >> > Get news, entertainment and everything you care about at Live.com. Check
> >> > it
> >> > out!
> >> > _____________________________________
> >> > 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 ITK FAQ at:
> >> > http://www.itk.org/Wiki/ITK_FAQ
> >> >
> >> > Follow this link to subscribe/unsubscribe:
> >> > http://www.itk.org/mailman/listinfo/insight-users
> >> >
> >> >
> >
> > ________________________________
> > See all the ways you can stay connected to friends and family
What can you do with the new Windows Live? Find out
_____________________________________
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 ITK FAQ at: http://www.itk.org/Wiki/ITK_FAQ
Follow this link to subscribe/unsubscribe:
http://www.itk.org/mailman/listinfo/insight-users
_________________________________________________________________
Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy!
http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20090420/6902d577/attachment.htm>
More information about the Insight-users
mailing list