<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<STYLE>P {
        PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px
}
BODY {
        FONT-SIZE: 10pt; FONT-FAMILY: Tahoma
}
</STYLE>
<META content="MSHTML 6.00.5730.11" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=373110917-02022007>ITK does not provide a
view of images as matrices. Instead, ITK views images as "containers",
similar to STL containers, and uses iterators to move about an
N-dimensional image.</SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=373110917-02022007></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=373110917-02022007>That being said,
y</SPAN><SPAN class=373110917-02022007>ou can grab a pointer to the image buffer
using the Image::GetBufferPointer() method. I don't like to promote its
use because I regret ever introducing it. Exposing the buffer pointer
has made it difficult to introduce alternative memory organization schemes,
such as images where only the pixels within a slice are contiguous in
memory.</SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=373110917-02022007></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=373110917-02022007>To could create a
vnl wrapper around an itk image buffer, you can do the
following </SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=373110917-02022007></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN
class=373110917-02022007>vnl_matrix_ref<ImageType::PixelType>
imgAsMatrix(img->GetBufferedRegion()->GetSize()[0], </SPAN></DIV>
<DIV dir=ltr align=left><SPAN
class=373110917-02022007>
img->GetBufferedRegion()->GetSize()[1], </SPAN></DIV>
<DIV dir=ltr align=left><SPAN
class=373110917-02022007>
img->GetBufferPointer());</SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=373110917-02022007></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=373110917-02022007>As for summing the pixels
in the rows or columns of an image, there is filter called
itk::AccumulateImageFilter to do this.</SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=373110917-02022007></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=373110917-02022007>Jim</SPAN></DIV><BR>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<B>From:</B> insight-users-bounces+millerjv=crd.ge.com@itk.org
[mailto:insight-users-bounces+millerjv=crd.ge.com@itk.org] <B>On Behalf Of
</B>Ali -<BR><B>Sent:</B> Friday, February 02, 2007 11:56 AM<BR><B>To:</B>
Robert Tamburo<BR><B>Cc:</B> ITK<BR><B>Subject:</B> RE: [Insight-users] How to
sum pixels row-by-row?<BR><BR></DIV>
<DIV></DIV>
<DIV style="TEXT-ALIGN: left"><BR>Perhaps this is not the most efficient way, is
it possible to get the pointer to <BR>the image data and pass it to the matrix?
If there is no such a class to convert <BR>images and matrices, then how is the
vnl matrix class used in itk?!<BR></DIV>
<BLOCKQUOTE
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #008080 2px solid; MARGIN-RIGHT: 0px"><BR><BR><FONT
class=EC_Apple-style-span size=4><SPAN class=EC_Apple-style-span
style="FONT-SIZE: 13px">>> </SPAN></FONT>Can you tell me how it is
possible to covert images to matrices and vice vera?
<DIV style="MARGIN-BOTTOM: 0px; MARGIN-LEFT: 0px; MARGIN-RIGHT: 0px"><BR
class=EC_khtml-block-placeholder></DIV>
<DIV style="MARGIN-BOTTOM: 0px; MARGIN-LEFT: 0px; MARGIN-RIGHT: 0px">I'm not
sure if there is an ITK class for this, but I imagine that you could:</DIV>
<DIV style="MARGIN-BOTTOM: 0px; MARGIN-LEFT: 0px; MARGIN-RIGHT: 0px">1.
Instantiate a vnl matrix that is of the same size as your 2D
image. </DIV>
<DIV style="MARGIN-BOTTOM: 0px; MARGIN-LEFT: 0px; MARGIN-RIGHT: 0px">2.
Iterate the image.</DIV>
<DIV style="MARGIN-BOTTOM: 0px; MARGIN-LEFT: 0px; MARGIN-RIGHT: 0px">3. As the
iterator traverses the image, grab the pixel index and value.</DIV>
<DIV style="MARGIN-BOTTOM: 0px; MARGIN-LEFT: 0px; MARGIN-RIGHT: 0px">4. Set
the pixel value in the matrix at the corresponding index.</DIV>
<DIV style="MARGIN-BOTTOM: 0px; MARGIN-LEFT: 0px; MARGIN-RIGHT: 0px"><BR
class=EC_khtml-block-placeholder></DIV><BR>
<DIV>
<DIV>On Feb 2, 2007, at 11:15 AM, Ali - wrote:</DIV><BR
class=EC_Apple-interchange-newline>
<BLOCKQUOTE><BR>> <BR>> > It is strange how ITK can perform so many
elaborated image processings, <BR>> > but it takes hours to figure out
how to implement some elementary matrix <BR>> > manipulations. I
thought the inclusion of VXL in ITK means having a fast <BR>> >
MATLAB-style image processing toolkit in c++.<BR>> <BR>> That's right
that many filters are missing to perform simple tasks.<BR>> ITK is open
source, and open to contributions. Feel free to contribute <BR>>
contribute new code to the insight journal :-)<BR><BR>Even if the community
provides it, I think it is not a good idea to <BR>create a 'database' of all
operations for images and I have at least 2 reasons for
that.<BR> <BR>First, it is really hard to find out which class does
what operation simply by guessing <BR>from its name. Secondly, not all the
operations can be created as a linear combination <BR>of the simple
operations. This means you have to write filters forever, many of them may
be <BR>used only once.<BR><BR>For example, the slice-by-slice filter you
provides does not accept binary filters <BR>to operate on each slice. So, if
I want to divide an N x N image A to a 1 x N image B <BR>row-by-row, I have
to modify the slice-by-slice filter. In the matrix form, this can be
<BR>down simply by 'literally' one line: B->GetTranspose() * A.
<BR><BR>Can you tell me how it is possible to covert images to matrices and
vice vera? I know ITK <BR>uses VNL matrices but I cannot see where this is
used to maniplulate image pixels directly. <BR>If this can be done, we won't
need hundereds of image operation classes.<BR><BR>> <BR>>
Gaetan<BR>> <BR>> <BR>> <BR>> -- <BR>> Gaëtan Lehmann<BR>>
Biologie du Développement et de la Reproduction<BR>> INRA de
Jouy-en-Josas (France)<BR>> tel: +33 1 34 65 29 66 fax: 01 34 65 29
09<BR>> <A href="http://voxel.jouy.inra.fr"
target=_blank>http://voxel.jouy.inra.fr</A><BR><BR>
<HR>
Personalize your Live.com homepage with the news, weather, and photos you
care about. <A
href="http://www.live.com/getstarted.aspx?icid=T001MSN30A0701"
target=_blank>Try it!</A>
<DIV
style="MARGIN-BOTTOM: 0px; MARGIN-LEFT: 0px; MARGIN-RIGHT: 0px">_______________________________________________</DIV>
<DIV
style="MARGIN-BOTTOM: 0px; MARGIN-LEFT: 0px; MARGIN-RIGHT: 0px">Insight-users
mailing list</DIV>
<DIV style="MARGIN-BOTTOM: 0px; MARGIN-LEFT: 0px; MARGIN-RIGHT: 0px"><A
href="mailto:Insight-users@itk.org">Insight-users@itk.org</A></DIV>
<DIV style="MARGIN-BOTTOM: 0px; MARGIN-LEFT: 0px; MARGIN-RIGHT: 0px"><A
href="http://www.itk.org/mailman/listinfo/insight-users"
target=_blank>http://www.itk.org/mailman/listinfo/insight-users</A></DIV></BLOCKQUOTE></DIV><BR></BLOCKQUOTE><BR>
<HR>
Live Search: Better results, fast <A href="http://get.live.com/search/overview"
target=_new>Try it now!</A> </BODY></HTML>