[Insight-users] Questions on inserting zeros pixels around an
imageand on PasteImageFilter
Miller, James V (Research)
millerjv at crd.ge.com
Mon Jul 19 11:16:01 EDT 2004
PadImageFilter has been around for several years. There are several
subclasses: ConstantPadImageFilter, WrapPadImageFilter, MirrorPadImageFilter
Jim
-----Original Message-----
From: Jonathan Lok-Chuen Lo [mailto:jlo at robots.ox.ac.uk]
Sent: Monday, July 19, 2004 11:12 AM
To: 'Ivan Macia'; 'ITK User Mailing List'
Subject: RE: [Insight-users] Questions on inserting zeros pixels around
an imageand on PasteImageFilter
Hi Ivan,
Thank you very much for you email, but I couldn't really find the filter you
have mentioned? I am using ITK version 1.6.0, is the filter added in after
that release?
Thanks!
Jonathan
-----Original Message-----
From: Ivan Macia [mailto:imacia at vicomtech.es]
Sent: 19 July 2004 15:55
To: 'Jonathan Lok-Chuen Lo'; 'ITK User Mailing List'
Subject: RE: [Insight-users] Questions on inserting zeros pixels around an
imageand on PasteImageFilter
Hi Jonathan,
I cannot tell you much about the PasteImageFilter, but to insert zero pixels
you can use the PadImageFilter which resizes the image accordingly.
http://www.itk.org/Doxygen16/html/classitk_1_1PadImageFilter.html
Hope that helps
Ivan
-----Mensaje original-----
De: Jonathan Lok-Chuen Lo [mailto:jlo at robots.ox.ac.uk]
Enviado el: lunes, 19 de julio de 2004 11:48
Para: ITK User Mailing List
Asunto: [Insight-users] Questions on inserting zeros pixels around an
imageand on PasteImageFilter
Hi all,
I am currently trying to use the morphological operations
(itkBinaryErodeImageFilter and itkBinaryDilateImageFilter) on some images.
In order to preserve the edge pixels, I want to insert some zero pixels
around the edges of the image. After searching the mailing list, I have
found the filter itkPasteImageFilter.
I have successfully paste the original read image into a larger itkImage
object. However, I have problem on the other direction, i.e. to paste the
larger image back into the original image. A run time exception message
"Description: Requested region is (at least partially) outside the largest
possible region." is generated. I gathered that it is because the
LargestPossibleRegion of the original image is smaller than that of the
larger image. The code is at the end of this message.
Here are my questions:
1) Is it the correct behaviour of the itkPasteImageFilter? Even though the
LargestPossibleRegion of the destination is smaller than the source, but the
region to be copied from the source is going to fit into the destination?
2) Are there a better way to perform the operations I need, i.e. to insert
zero pixels around the edges of a image?
Thank you very much for your time!
With regards,
Jonathan Lo
*************************************
Jonathan Lok-Chuen Lo
Medical Vision Labortory
Department of Engineering Science
Oxford University
Parks Road
Oxford OX1 3PJ
Phone: (44) 1865 280940
Fax: (44) 1865 280922
*************************************
CODE:
Image::Pointer mask = some image read in...
Image::Pointer maskLarge = Image::New();
Image::RegionType maskRegion;
Image::RegionType maskLargeRegion;
maskRegion = mask->GetLargestPossibleRegion();
// Generate a larger data object to store the mask
for (int ii=0; ii<mask->GetImageDimension(); ii++) {
maskLargeRegion.SetIndex(ii, 0);
maskLargeRegion.SetSize(ii, maskRegion.GetSize(ii) + 4);
}
maskLarge->SetRegions(maskLargeRegion);
maskLarge->Allocate();
maskLarge->FillBuffer(0);
// Perform the pasting from the original to the larger mask, at an offset
index MaskType::IndexType maskLargeIndex; maskLargeIndex.Fill(2);
pasteFilter->SetSourceImage(mask); // pasteFilter has been
created somewhere...
pasteFilter->SetSourceRegion(maskRegion);
pasteFilter->SetDestinationImage(maskLarge);
pasteFilter->SetDestinationIndex(maskLargeIndex);
pasteFilter->Update();
maskLarge = pasteFilter->GetOutput();
... Perform morphological operations on maskLarge
MaskType::IndexType maskIndex;
maskIndex.Fill(0);
for (int ii=0; ii<mask->GetImageDimension(); ii++) {
maskLargeRegion.SetIndex(ii, 2);
maskLargeRegion.SetSize(ii, maskRegion.GetSize(ii));
}
pasteFilter->SetSourceImage(maskLarge);
pasteFilter->SetSourceRegion(maskLargeRegion);
pasteFilter->SetDestinationImage(mask);
pasteFilter->SetDestinationIndex(maskIndex);
pasteFilter->Update(); // FAILED HERE!!!
mask = pasteFilter->GetOutput();
_______________________________________________
Insight-users mailing list
Insight-users at itk.org
http://www.itk.org/mailman/listinfo/insight-users
More information about the Insight-users
mailing list