[Insight-users] to divide images (sorry, one bug in my other mail)

David Llanos gva02 at elai.upm.es
Thu, 29 Apr 2004 19:24:17 +0200


This is a multi-part message in MIME format.

------=_NextPart_000_0026_01C42E1F.902F2850
Content-Type: multipart/alternative;
	boundary="----=_NextPart_001_0027_01C42E1F.902F2850"


------=_NextPart_001_0027_01C42E1F.902F2850
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable


----- Original Message -----=20
From: David Llanos=20
To: insight-users at itk.org=20
Sent: Thursday, April 29, 2004 7:20 PM
Subject: to divide images


Hi all,

I am looking for classes and methods to divide a binary image in several =
binary images, in function of the I number of objects that the original =
binary image has. For example, of the image binar.png, to obtain four =
images like uno.jpg.
I have gotten the first requirement for this objective that is to label =
this objects, by means of the following code:
-------------------------------------------------------------------------=
-------------------------------------------------------------------------=
------------
                    .....
 xorfilter->SetInput1( grindpeak->GetOutput() );
 xorfilter->SetInput2( binaryDilate->GetOutput() );
 imgEsperBWsin->SetInput( xorfilter->GetOutput() );
 imgEsperBWsin->Update();
 std::cout << "Numero de iteraciones: " << =
grindpeak->GetNumberOfIterationsUsed() << "  .....bordes borrados" << =
std::endl;
    std::cout << "Imagen imgEsperBWsin.jpg creada... " << std::endl;

// Etiquetado de la imagen
 itkConnectedComponentFilterType::Pointer labeller =3D=20
  itkConnectedComponentFilterType::New();
 labeller->SetInput( xorfilter->GetOutput() );
 labeller->Update();

itkRelabelComponentFilterType::Pointer relabeller =3D =
itkRelabelComponentFilterType::New();
 relabeller->SetInput( labeller->GetOutput() );
 relabeller->Update();

unsigned long nObjects =3D relabeller->GetNumberOfObjects();
 const std::vector<unsigned long> sizeOfObjects =3D =
relabeller->GetSizeOfObjectsInPixels();
 std::cout << "Number of objects : " << nObjects << std::endl;
 std::vector<unsigned long>::const_iterator it;
 int i; =20
 for(i =3D 0, it =3D  sizeOfObjects.begin(); it !=3D =
sizeOfObjects.end(); ++i, ++it) {=20
  std::cout << "Size of object " << i+1 << ": " << (*it) << " pixels" << =
std::endl;
 }
-------------------------------------------------------------------------=
-------------------------------------

I have been looking for some relabeller or labeller method  (in =
http://www.itk.org/Insight/Doxygen/html/classitk_1_1RelabelComponentImage=
Filter-members.html and in =
http://www.itk.org/Insight/Doxygen/html/classitk_1_1ConnectedComponentIma=
geFilter-members.html) to go keeping the different objects of the image =
in pointers, either to write files or to work with them for separate, =
but I have not found anything with that that to be able to work.
does some form exist of using these classes for my objective, or do I =
have to use another class? In that case, What relabeller or labeller =
method  can I use to relate an object labeled with another class?=20

Thanks inadvange and regards,

David.



------=_NextPart_001_0027_01C42E1F.902F2850
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 6.00.2800.1400" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV style=3D"FONT: 10pt arial">----- Original Message -----=20
<DIV style=3D"BACKGROUND: #e4e4e4; font-color: black"><B>From:</B> <A=20
title=3Dgva02 at elai.upm.es href=3D"mailto:gva02 at elai.upm.es">David =
Llanos</A> </DIV>
<DIV><B>To:</B> <A title=3Dinsight-users at itk.org=20
href=3D"mailto:insight-users at itk.org">insight-users at itk.org</A> </DIV>
<DIV><B>Sent:</B> Thursday, April 29, 2004 7:20 PM</DIV>
<DIV><B>Subject:</B> to divide images</DIV></DIV>
<DIV><BR></DIV>
<DIV><FONT face=3DArial size=3D2>Hi all,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I am looking for classes and methods to =
divide a=20
binary image in several binary images, in function of the I number of =
objects=20
that the original binary image has. For example, of the image binar.png, =
to=20
obtain four images like uno.jpg.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I have gotten the first requirement for =
this=20
objective that is to label this objects, by means of the following=20
code:</FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2>----------------------------------------------------------------=
-------------------------------------------------------------------------=
---------------------</FONT></DIV>
<DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; =
.....</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;xorfilter-&gt;SetInput1(=20
grindpeak-&gt;GetOutput() );<BR>&nbsp;xorfilter-&gt;SetInput2(=20
binaryDilate-&gt;GetOutput() );<BR>&nbsp;imgEsperBWsin-&gt;SetInput(=20
xorfilter-&gt;GetOutput() =
);<BR>&nbsp;imgEsperBWsin-&gt;Update();</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;std::cout &lt;&lt; "Numero de =
iteraciones: "=20
&lt;&lt; grindpeak-&gt;GetNumberOfIterationsUsed() &lt;&lt; "&nbsp; =
.....bordes=20
borrados" &lt;&lt; std::endl;<BR>&nbsp;&nbsp;&nbsp; std::cout &lt;&lt; =
"Imagen=20
imgEsperBWsin.jpg creada... " &lt;&lt; std::endl;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>//&nbsp;Etiquetado de la=20
imagen<BR>&nbsp;itkConnectedComponentFilterType::Pointer labeller =3D=20
<BR>&nbsp;&nbsp;itkConnectedComponentFilterType::New();<BR>&nbsp;labeller=
-&gt;SetInput(=20
xorfilter-&gt;GetOutput() =
);<BR>&nbsp;labeller-&gt;Update();</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>itkRelabelComponentFilterType::Pointer =
relabeller =3D=20
itkRelabelComponentFilterType::New();<BR>&nbsp;relabeller-&gt;SetInput(=20
labeller-&gt;GetOutput() =
);<BR>&nbsp;relabeller-&gt;Update();</FONT></DIV>
<DIV><FONT face=3DArial size=3D2><BR>unsigned long nObjects =3D=20
relabeller-&gt;GetNumberOfObjects();<BR>&nbsp;const =
std::vector&lt;unsigned=20
long&gt; sizeOfObjects =3D =
relabeller-&gt;GetSizeOfObjectsInPixels();</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;std::cout &lt;&lt; "Number of =
objects : "=20
&lt;&lt; nObjects &lt;&lt; std::endl;<BR>&nbsp;std::vector&lt;unsigned=20
long&gt;::const_iterator it;<BR>&nbsp;int i;&nbsp;&nbsp;<BR>&nbsp;for(i =
=3D 0, it=20
=3D&nbsp; sizeOfObjects.begin(); it !=3D sizeOfObjects.end(); ++i,=20
++it)&nbsp;{&nbsp;<BR>&nbsp;&nbsp;std::cout &lt;&lt; "Size of object " =
&lt;&lt;=20
i+1 &lt;&lt; ": " &lt;&lt; (*it) &lt;&lt; " pixels" &lt;&lt;=20
std::endl;<BR>&nbsp;}</FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2>----------------------------------------------------------------=
----------------------------------------------</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV>I have been looking for some relabeller or labeller method&nbsp; =
(in <A=20
href=3D"http://www.itk.org/Insight/Doxygen/html/classitk_1_1RelabelCompon=
entImageFilter-members.html">http://www.itk.org/Insight/Doxygen/html/clas=
sitk_1_1RelabelComponentImageFilter-members.html</A>=20
and in <A=20
href=3D"http://www.itk.org/Insight/Doxygen/html/classitk_1_1ConnectedComp=
onentImageFilter-members.html">http://www.itk.org/Insight/Doxygen/html/cl=
assitk_1_1ConnectedComponentImageFilter-members.html</A>)=20
to go keeping the different objects of the image in pointers, either to =
write=20
files or to work with them for separate, but I have not found anything =
with that=20
that to be able to work.</DIV>
<DIV>does some form exist of using these classes for my objective, or do =
I have=20
to use another class? In that case, What relabeller or labeller =
method&nbsp; can=20
I use to relate an object labeled with another class? </DIV>
<DIV>&nbsp;</DIV>
<DIV>Thanks inadvange and regards,</DIV>
<DIV>&nbsp;</DIV>
<DIV>David.</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV></FONT></DIV></BODY></HTML>

------=_NextPart_001_0027_01C42E1F.902F2850--

------=_NextPart_000_0026_01C42E1F.902F2850
Content-Type: image/png;
	name="binar.png"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
	filename="binar.png"

iVBORw0KGgoAAAANSUhEUgAAAecAAAFsCAAAAADTES6TAAAACXBIWXMAAC4jAAAuIwF4pT92AAAE
bUlEQVR4nO3dy1ZVMRBFUf7/p7EhooLIeSSVnVNzdmyyU0s6cMfg5QUAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAADo6vWD1XuY42NnpR/pc2axH+Utp86P9lVenZ/k28o6P8GBzELv71Bmnbd3rLPU
uzvcWemdncgs9K5ORdZ6P1cC67wfnXu40VnojdzprPQ+dO5B5x507uFeZ6l3ofPj3U6s8xZ07kHn
HnTuYUxnocMNyqx0uHGdpU42tLPQsXTuQecWxmbWOZXOLcjcgsw96NyDzj3o3IPOPajchM496NyD
zj2M7Cx0Lp170LkHnXvQuQeZe9C5CZ170LkHnXvQuQuZm9C5B5170LkHmXuQuAedu5C5B5270LkH
nXuQuQed29C5EZF70LkHnRtRuQeRe9C5B5170LiL954f8sr8ML9yfvw2lvmhfAMDAAAAAFT69ENZ
P6V9pN9Z/db0yf79azWhn+bLj0HI/Shff+JF50f46+MtOj/WN4V1foBDjXXe3uHOQu/reGSl93Wy
stinBBzrLdi1zmp/J+Jif3zhO52F/lrE3W7F1fmIiMvpPF3E5XSeLuJ4Ok8XcT2d50o535aV379o
/H+znAPuGHr5gKNyDjgmc9Gd1y84J+iEN9LWnnn5gAuCLnixavmZY4acEXTBc1PWnTdmyAlJNzy9
Zc15Y4Ycl3XDC2sWnDdoylFhN7wyp3plzpIToi44tPOsmTFDTsm64QadY4acE3XDoZnnbMxaM313
zpLSjRv/DZmY1TdOWDVx58+sxay+c8MdJo6fUzE9ZEbhxK3/NGfK6nsnrNmo88IdhRs7dk7ZUboy
a03J9JQdhSuz1hSNjxlStzJrTdX4mCFlQ6PGlI2PGVI2NGpM2fiYIVVLk7YUro8ZUrQ0aUvl/Jgh
RUuTtlTOz1lSsjRpS+n+nCUlS5O2VO7PWVIzM25Q1f6cJRUr4waVPSFkRtHKuEFlb4gYUbYyb1HV
GyJGlK3MW1T1hogRZSvzFlW9IWJE2cq8RVVviBhRNTJwUs071i8oXZm3qOIhAROKp6btqXlIwITi
qXGDKh4SMOHIypFbR+5aKmDpwFu+vup89yEBE47tHLt24LDFVo8cd8kZS2OHzXnK4i+/7pyxwy5Z
OXLcJWcsjR121bKR4y45Y2nssKuWTRx3yRlTc5ddtGzduEvO2Bs77IY164Zdcsrg2GE31Y97+0qh
5xw0K67zMqHHHDJryrI9pR5zyK4507aUeswhu+ZM21LqLUfsmrVtR6m3HLFr1rYdpZ5xSGSV36Ue
UubxEs+o8xx5Z9R5hrwzyjxF3B01nijolvc6C/1fhy5YdUmdp4m6oM4TJV1Q5xLLL6hzibd7/fxH
56d7P1v5AXXuQeceVO5B5iZEbkLnRnTuQecedO5C4DZk7kHnHnRu4j+BdX4W38OtaNyDygAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA0NAP9SymMqfm
gH8AAAAASUVORK5CYII=

------=_NextPart_000_0026_01C42E1F.902F2850
Content-Type: image/png;
	name="uno.png"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
	filename="uno.png"

iVBORw0KGgoAAAANSUhEUgAAAecAAAFsCAAAAADTES6TAAAACXBIWXMAAC4jAAAuIwF4pT92AAAA
BGdBTUEAALGOfPtRkwAAACBjSFJNAAB6JQAAgIMAAPn/AACA6QAAdTAAAOpgAAA6mAAAF2+SX8VG
AAAMOUlEQVR42mJiGAUjAQAEENNoEIwIABBAo/E8MgBAAI3G88gAAAE0Gs8jAwAE0Gg8jw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