<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Not really. (Speak French, that is.)<br>
<br>
Sorry - last arg to memcpy should be the same as the amount that you
increment data by each time through the loop. It's the number of bytes
in one slice - width * height * 3 * sizeof(unsigned char)...<br>
<br>
Next time I'll finish my morning coffee before replying. <span
 class="moz-smiley-s6"><span> :-[ </span></span><br>
<br>
<br>
David<br>
<br>
<br>
med ali wrote:
<blockquote
 cite="mid20050610142353.71563.qmail@web26404.mail.ukl.yahoo.com"
 type="cite">
  <div>Hi David,</div>
  <div>&nbsp;</div>
  <div>do you speak french ??</div>
  <div>i don't see how the data can be copied&nbsp; like this&nbsp; with this
code;</div>
  <div>&nbsp;</div>
  <div>-------------&nbsp;&nbsp; data of image 0 </div>
  <div>-------------&nbsp;&nbsp; data of image 1</div>
  <div>-------------&nbsp;&nbsp; data of image 2</div>
  <div>-------------&nbsp;&nbsp; data image 3</div>
  <div>-------------&nbsp;&nbsp;&nbsp;&nbsp; ....</div>
  <div>&nbsp;</div>
  <div>&nbsp;</div>
  <div>///////////////************the code
*****************/////////////////////////////</div>
  <div>&nbsp;</div>
  <div>void TimacBase::constructImagedata(CImageBoxFL *img_box,int
nbr_slices,inter_slices)<br>
{</div>
  <div>&nbsp;int width;<br>
&nbsp;int height;</div>
  <div>&nbsp;width = img_box-&gt;tab[0].imgAff-&gt;largeur;<br>
&nbsp;height = img_box-&gt;tab[0].imgAff-&gt;hauteur;</div>
  <div>&nbsp; imageData-&gt;SetScalarTypeToUnsignedChar();<br>
&nbsp; imageData-&gt;SetNumberOfScalarComponents(3);<br>
&nbsp; imageData-&gt;SetDimensions(width,height, nbr_slices);<br>
&nbsp; imageData-&gt;AllocateScalars();</div>
  <div>&nbsp;&nbsp;</div>
  <div>&nbsp;&nbsp;unsigned char *data = (unsigned char *)
imageData-&gt;GetScalarPointer();</div>
  <div>&nbsp; int k = 0;<br>
&nbsp; for (k= 0; k&lt;nbr_slices; k+=inter_slices) <br>
&nbsp; {<br>
&nbsp; memcpy(data, img_box-&gt;tab[k].imgAff-&gt;data,
nbr_slices*3*sizeof(unsigned char));&nbsp;&nbsp;</div>
  <div>&nbsp;</div>
  <div>&nbsp; data += width * height *3*sizeof(unsigned char);</div>
  <div>&nbsp; }<br>
} </div>
  <div>&nbsp;</div>
  <div>///////////////////*******************************************************************</div>
  <div><br>
thanks ,</div>
  <div>*dali<br>
  </div>
  <blockquote class="replbq"
 style="border-left: 2px solid rgb(16, 16, 255); padding-left: 5px; margin-left: 5px;"><br>
    <br>
David Cole wrote:
    <blockquote cite="mid42A98C1E.5060609@kitware.com" type="cite">Nope.
(And again, please keep further questions on the list.)<br>
      <br>
When you call AllocateScalars you are allocating a chunk of memory that
is for the raw image data of type unsigned char with 3 components for
each voxel with 16x16x16 voxels. So you're allocating
16x16x16x3xsizeof(unsigned char) bytes which is expected to be used for
the data. You need to copy your raw data into that block of memory to
use the technique I've outlined.<br>
      <br>
You need something more like this:<br>
&nbsp; for (k= 0; k&lt;16; ++k) <br>
&nbsp; {<br>
&nbsp; memcpy(data, img_box-&gt;tab[k].imgAff-&gt;data, 16*3*sizeof(unsigned
char));&nbsp; // tab is an array og images <br>
&nbsp; data += 16*16*3*sizeof(unsigned char);<br>
&nbsp; }<br>
      <br>
If you want to use the memory you've already got allocated for a
vtkImageData, you need to dig in and figure out how it works inside or
have somebody else chime in to help you. I don't know if that's easily!
done - I'm still a relative newcomer to VTK myself.<br>
      <br>
      <br>
David<br>
      <br>
      <br>
med ali wrote:
      <blockquote
 cite="mid20050610104548.10781.qmail@web26401.mail.ukl.yahoo.com"
 type="cite">
        <div>hi,</div>
        <div>&nbsp;</div>
        <div>thanks for your help</div>
        <div>&nbsp;</div>
        <div>can you tell me if this part of code is right or not </div>
        <div>&nbsp;i have wrote this&nbsp;:</div>
        <div>&nbsp;</div>
        <div>&nbsp;</div>
        <div>////////////////////**********************&nbsp;
constructImageData***************/////////////////////////////</div>
        <div>void TimacBase::constructImageData(CImageBoxFL *img_box)<br>
{</div>
        <div>&nbsp; imageData-&gt;SetScalarTypeToUnsignedChar();<br>
&nbsp; imageData-&gt;SetNumberOfScalarComponents(3);<br>
&nbsp; imageData-&gt;SetDimensions(16, 16, 16);<br>
&nbsp; imageData-&gt;AllocateScalars();</div>
        <div>&nbsp; int i = 0;<br>
&nbsp; int j = 0;<br>
&nbsp; unsigned char r = 0;<br>
&nbsp; unsigned char g = 0;<br>
&nbsp; unsigned char b = 0;<br>
&nbsp; unsigned char *data = (unsigned char *)
imageData-&gt;GetScalarPointer();</div>
        <div>&nbsp; int k = 0;<br>
&nbsp; for (k= 0; k&lt;16; ++k) <br>
&nbsp; {<br>
&nbsp; data=img_box-&gt;tab[k].imgAff-&gt;data;&nbsp; // tab is an array og
images <br>
&nbsp; }<br>
} <br>
        <br>
        <b><i>David Cole <a class="moz-txt-link-rfc2396E"
 href="mailto:david.cole@kitware.com">&lt;david.cole@kitware.com&gt;</a></i></b>
a &eacute;crit :</div>
        <blockquote class="replbq"
 style="border-left: 2px solid rgb(16, 16, 255); padding-left: 5px; margin-left: 5px;">If
you need a 3d volume of bitmaps that are all the same x,y size, just do
the same thing, but add an iteration over the z-dimension. The
vtkImageData object supports 3 dimensions. Then, for each distinct
value of z, you'll be jamming a separate bitmap into a given z-slice of
the vtkImageData.<br>
          <br>
In the example, change the SetDimensions call to include more than one
z value:<br>
&nbsp; imageData-&gt;SetDimensions(16, 16, <b>16</b>);<br>
          <br>
Then add another loop to fill in the z data:<br>
&nbsp; int k = 0;<br>
&nbsp; for (k= 0; k&lt;16; ++k) // as outer loop; i and j loops in here;
conecptually, first slice filled is z=0, next z=1 and so on...<br>
          <br>
Then simply use the imageData object as the input to your algorithm,
just like you would have used the output of the BMP reader...<br>
          <br>
          <br>
David<br>
          <br>
          <br>
          <blockquote
 cite="mid20050609174215.91108.qmail@web26403.mail.ukl.yahoo.com"
 type="cite">
            <blockquote class="replbq"
 style="border-left: 2px solid rgb(16, 16, 255); padding-left: 5px; margin-left: 5px;">&nbsp;</blockquote>
          </blockquote>
        </blockquote>
        <hr size="1">
        <b><font color="#ff0000">Appel audio GRATUIT</font> partout
dans le monde</b> avec le nouveau Yahoo! Messenger<br>
        <a
 href="http://us.rd.yahoo.com/messenger/mail_taglines/default/*http://fr.messenger.yahoo.com">T&eacute;l&eacute;chargez
le ici !</a> </blockquote>
    </blockquote>
  </blockquote>
  <p> </p>
  <hr size="1"> <b><font color="#ff0000">Appel audio GRATUIT</font>
partout dans le monde</b> avec le nouveau Yahoo! Messenger<br>
  <a
 href="http://us.rd.yahoo.com/messenger/mail_taglines/default/*http://fr.messenger.yahoo.com">T&eacute;l&eacute;chargez
le ici !</a> </blockquote>
</body>
</html>