[Insight-users] erode using a buffer
cspl
affable at hd2 . dot . net . in
Sat, 27 Jul 2002 19:49:39 +0530
This is a multi-part message in MIME format.
------=_NextPart_000_0034_01C235A6.BE3FCA10
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Dear Mr.Bjorn & Friends,
I got the o/p using files.Now I am giving i/p from buffer and put o/p in =
buffer.I am getting o/p using itkGrayScaleDialteImageFilter.
when using itkgrayscaleErodeImageFilter o/p is not getting.It is giving =
some black screen.
Volume* IntensityScaleVolume(Volume *vol)
{=20
if (vol =3D=3D NULL) return ;
unsigned short *Buffer =3D new unsigned short[vol->width * vol->height =
* vol->depth];
typedef unsigned short PixelType;
Buffer =3D (unsigned short *) vol->Mem;
typedef itk::Image<unsigned short,3> ImageType;
itk::RawImageIO<unsigned short, 3>::Pointer output_io
=3D itk::RawImageIO<unsigned short, 3>::New();
=20
output_io->SetByteOrderToLittleEndian();
output_io->SetFileTypeToBinary();
output_io->SetFileDimensionality(3);
// Initialize the initial and target volumes.
ImageType::Pointer vol_init =3D ImageType::New();
ImageType::Pointer vol_init1 =3D ImageType::New();
=20
ImageType::SizeType sz;
sz[0] =3D vol->width;
sz[1] =3D vol->height;
sz[2]=3Dvol->depth;=20
=20
=20
ImageType::IndexType idx;
idx[0] =3D 0;
idx[1] =3D 0;
idx[2] =3D 0;
unsigned short pval;
=20
ImageType::RegionType reg; =20
reg.SetSize(sz);
reg.SetIndex(idx);
=20
vol_init->SetRegions(reg);
vol_init->Allocate();
=20
for(unsigned int z=3D0; z<vol->depth; ++z )
{=20
idx[2]=3Dz;
=20
for (unsigned int y =3D 0; y < vol->height; ++y)
{
idx[1] =3D y;
for (unsigned int x =3D 0; x < vol->width; ++x)
{
idx[0] =3D x;
vol_init->SetPixel(idx, *(Buffer =
+(z*vol->height*vol->width)+y *vol->width +x) );
=20
}
}
}
=20
=20
//Dilate Erode
itk::Size<3> size =3D {5,5,2};=20
typedef itk::NeighborhoodAllocator<PixelType> NAllocator;
NAllocator *nat=3Dnew NAllocator;
typedef itk::BinaryBallStructuringElement<unsigned short,3>
KernelType;
KernelType *NA=3Dnew KernelType;
NA->SetRadius(size);
NA->CreateStructuringElement();
=20
typedef itk::GrayscaleErodeImageFilter<ImageType,ImageType,KernelType> =
Morphology;
Morphology::Pointer GMF=3D Morphology::New();
GMF->SetInput(vol_init);
GMF->SetKernel(*NA);
GMF->Update();
vol_init=3DGMF->GetOutput();///here I think I am doing something wrong
=20
=20
for(unsigned int z=3D0; z<vol->depth; ++z )
{
idx[2]=3Dz;
=20
for (unsigned int y =3D 0; y < vol->height; ++y)
{
idx[1] =3D y;
for (unsigned int x =3D 0; x < vol->width; ++x)
{
idx[0] =3D x;
//here it is not able to write into buffer
*(Buffer +(z*vol->height*vol->width)+y *vol->width =
+x)=3Dvol_init->GetPixel(idx);
=20
}
}
}
vol->Mem =3D Buffer;
return vol;
=20
}
Please give me suggestion.
Thanking you,
Regards,
Ramakrishna
------=_NextPart_000_0034_01C235A6.BE3FCA10
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 5.50.4134.600" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Dear Mr.Bjorn & =
Friends,</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>I got the o/p using files.Now I am =
giving i/p from=20
buffer and put o/p in buffer.I am getting o/p using=20
itkGrayScaleDialteImageFilter.<BR>when using =
itkgrayscaleErodeImageFilter o/p is=20
not getting.It is giving some black screen.</FONT></DIV>
<DIV> </DIV><FONT face=3DArial size=3D2>
<DIV><BR>Volume* IntensityScaleVolume(Volume *vol)<BR>{ </DIV>
<DIV> </DIV>
<DIV> if (vol =3D=3D NULL) return ;<BR> unsigned short *Buffer =
=3D new=20
unsigned short[vol->width * vol->height *=20
vol->depth];<BR> typedef unsigned short =20
PixelType;<BR> Buffer =3D (unsigned short *) =
vol->Mem;<BR> typedef=20
itk::Image<unsigned short,3>=20
ImageType;<BR> itk::RawImageIO<unsigned short, 3>::Pointer=20
output_io<BR> =3D =
itk::RawImageIO<unsigned=20
short, 3>::New();<BR> <BR> =20
output_io->SetByteOrderToLittleEndian();<BR> =20
output_io->SetFileTypeToBinary();<BR> =20
output_io->SetFileDimensionality(3);</DIV>
<DIV> </DIV>
<DIV> // Initialize the initial and target=20
volumes.<BR> =
ImageType::Pointer=20
vol_init =3D ImageType::New();<BR> ImageType::Pointer vol_init1 =3D =
ImageType::New();<BR> <BR> =20
ImageType::SizeType sz;<BR> sz[0] =3D=20
vol->width;<BR> sz[1] =3D=20
vol->height;<BR> sz[2]=3Dvol->depth;=20
<BR> <BR> <BR> =20
ImageType::IndexType idx;<BR> idx[0] =3D=20
0;<BR> idx[1] =3D 0;<BR> idx[2] =3D=20
0;<BR> unsigned short pval;<BR> =20
<BR> ImageType::RegionType reg; =
<BR> =20
reg.SetSize(sz);<BR> =
reg.SetIndex(idx);<BR> =20
<BR> =
vol_init->SetRegions(reg);<BR> =20
vol_init->Allocate();<BR> <BR> for(unsigned int =
z=3D0;=20
z<vol->depth; ++z )<BR> {=20
<BR> idx[2]=3Dz;<BR> <BR> =
for=20
(unsigned int y =3D 0; y < vol->height;=20
++y)<BR> =20
{<BR> idx[1] =3D=20
y;<BR> for =
(unsigned int x=20
=3D 0; x < vol->width;=20
++x)<BR>  =
;=20
{<BR> &n=
bsp; =20
idx[0] =3D=20
x;<BR> &=
nbsp;=20
vol_init->SetPixel(idx, *(Buffer +(z*vol->height*vol->width)+y=20
*vol->width +x) );<BR> =20
<BR> =20
}<BR> =20
}<BR> }<BR> =20
<BR> </DIV>
<DIV> </DIV>
<DIV> //Dilate Erode<BR> itk::Size<3> size =3D {5,5,2}; =
<BR> typedef=20
itk::NeighborhoodAllocator<PixelType> =20
NAllocator;<BR> NAllocator *nat=3Dnew=20
NAllocator;<BR> typedef=20
itk::BinaryBallStructuringElement<unsigned =
short,3><BR> =20
KernelType;<BR> KernelType *NA=3Dnew=20
KernelType;<BR> NA->SetRadius(size);<BR> NA->CreateStruct=
uringElement();<BR> </DIV>
<DIV> </DIV>
<DIV> typedef=20
itk::GrayscaleErodeImageFilter<ImageType,ImageType,KernelType> =
; =20
Morphology;<BR> Morphology::Pointer GMF=3D=20
Morphology::New();<BR> GMF->SetInput(vol_init);<BR> GMF->=
SetKernel(*NA);<BR> GMF->Update();<BR> vol_init=3DGMF->Ge=
tOutput();///here=20
I think I am doing something wrong</DIV>
<DIV> </DIV>
<DIV> <BR> <BR> for(unsigned int z=3D0; =
z<vol->depth; ++z=20
)<BR> {<BR> idx[2]=3Dz;<BR> <BR> &n=
bsp; =20
for (unsigned int y =3D 0; y < vol->height;=20
++y)<BR> =20
{<BR> idx[1] =3D=20
y;<BR> for =
(unsigned int x=20
=3D 0; x < vol->width;=20
++x)<BR>  =
;=20
{<BR> &n=
bsp; =20
idx[0] =3D x;<BR> //here it is not able to write into=20
buffer<BR> *(Buffer=20
+(z*vol->height*vol->width)+y *vol->width=20
+x)=3Dvol_init->GetPixel(idx);<BR> =
=20
<BR> }<BR> =20
}<BR> }</DIV>
<DIV> </DIV>
<DIV> vol->Mem =3D Buffer;<BR> return =
vol;<BR> =20
<BR>}</DIV>
<DIV> </DIV>
<DIV><BR>Please give me suggestion.</DIV>
<DIV> </DIV>
<DIV>Thanking you,<BR>Regards,<BR>Ramakrishna</FONT></DIV></BODY></HTML>
------=_NextPart_000_0034_01C235A6.BE3FCA10--