[prev in list] [next in list] [prev in thread] [next in thread]
List: vtk-developers
Subject: [vtk-developers] Re: [vtkusers] Problem with using
From: Randall Hand <randall.hand () gmail ! com>
Date: 2005-09-14 18:21:24
Message-ID: b022647205091411214e54f99d () mail ! gmail ! com
[Download RAW message or body]
Done... Bug #2234
http://www.vtk.org/Bug/bug.php?op=show&bugid=2234&pos=2
On 9/14/05, Mathieu Malaterre <mathieu.malaterre@kitware.com> wrote:
>
> Ok this is a bug:
>
> i ========== End of Data Statistics ===============
> ==30679==
> ==30679== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 9 from 4)
> ==30679==
> ==30679== 1 errors in context 1 of 1:
> ==30679== Invalid read of size 8
> ==30679== at 0x12A4B8F5: void
> vtkImageFFTExecute<double>(vtkImageFFT*, vtkImageData*, int*, double*,
> vtkImageData*, int*, double*, int) (vtkImageFFT.cxx:137)
> ==30679== by 0x12A4A645: vtkImageFFT::ThreadedExecute(vtkImageData*,
> vtkImageData*, int*, int) (vtkImageFFT.cxx:203)
> ==30679== by 0x1353AEA2:
> vtkThreadedImageAlgorithm::ThreadedRequestData(vtkInformation*,
> vtkInformationVector**, vtkInformationVector*, vtkImageData***,
> vtkImageData**, int*, int) (vtkThreadedImageAlgorithm.cxx:327)
> ==30679== by 0x1353AA8E:
> vtkThreadedImageAlgorithmThreadedExecute(void*)
> (vtkThreadedImageAlgorithm.cxx:200)
> ==30679== by 0x13BA30F9: start_thread (in /lib64/tls/libpthread-2.3.5.so<http://2.3.5.so>
> )
> ==30679== by 0x1561AA62: clone (in /lib64/tls/libc-2.3.5.so<http://2.3.5.so>
> )
> ==30679== Address 0x19992030 is 0 bytes after a block of size 16777216
> alloc'd
> ==30679== at 0x11B1A8E2: operator new[](unsigned long) (in
> /usr/lib64/valgrind/vgpreload_memcheck.so)
> ==30679== by 0x1380B136: vtkDataArrayTemplate<double>::Allocate(long
> long, long long) (vtkDataArrayTemplate.txx:99)
> ==30679== by 0x1380BF2E:
> vtkDataArrayTemplate<double>::SetNumberOfValues(long long)
> (vtkDataArrayTemplate.txx:536)
> ==30679== by 0x1380B409:
> vtkDataArrayTemplate<double>::SetNumberOfTuples(long long)
> (vtkDataArrayTemplate.txx:330)
> ==30679== by 0x12154566:
> vtkArrayCalculator::RequestData(vtkInformation*, vtkInformationVector**,
> vtkInformationVector*) (vtkArrayCalculator.cxx:279)
> ==30679== by 0x1341A5AA:
> vtkDataSetAlgorithm::ProcessRequest(vtkInformation*,
> vtkInformationVector**, vtkInformationVector*)
> (vtkDataSetAlgorithm.cxx:175)==30679== by 0x1342CBC9:
> vtkExecutive::CallAlgorithm(vtkInformation*, int,
> vtkInformationVector**, vtkInformationVector*) (vtkExecutive.cxx:679)
> ==30679== by 0x13427AF7:
> vtkDemandDrivenPipeline::ExecuteData(vtkInformation*,
> vtkInformationVector**, vtkInformationVector*)
> (vtkDemandDrivenPipeline.cxx:464)
> ==30679== by 0x1342732B:
> vtkDemandDrivenPipeline::ProcessRequest(vtkInformation*, int,
> vtkInformationVector**, vtkInformationVector*)
> (vtkDemandDrivenPipeline.cxx:244)
> ==30679== by 0x1352487E:
> vtkStreamingDemandDrivenPipeline::ProcessRequest(vtkInformation*, int,
> vtkInformationVector**, vtkInformationVector*)
> (vtkStreamingDemandDrivenPipeline.cxx:144)
> ==30679== by 0x13427927: vtkDemandDrivenPipeline::UpdateData(int)
> (vtkDemandDrivenPipeline.cxx:406)
> ==30679== by 0x13524A04:
> vtkStreamingDemandDrivenPipeline::Update(int)
> (vtkStreamingDemandDrivenPipeline.cxx:190)
>
>
> Could you open a bug in the bugtracker(*) for this. Add your program as
> an attachment.
>
> Thanks
> Mathieu
> (*) http://vtk.org/Bug
>
>
>
> Randall Hand wrote:
> > Ok, I posted this once before, but here it is again with some more
> > information.
> >
> > I've written a piece of code to create a synthetic dataset. It's a
> > 128^3 dataset, each point with a 3-component double value consisting of
> > (sin(x), junk, morejunk). I extract just the first component, and do an
> > FFT. You'll find the code at the end of this message, along with my
> > "PrintStatistics" function attached.
> >
> > You'll see from the #if/#endif blocks that there's two possible ways to
> > do it. The first is with a vtkArrayCalculator, where I set a very
> > trivial function to simply copy out the one value. The other way is
> > with a vtkImageExtractComponents. When doing it with the
> > vtkArrayCalculator, the filter seems to work just fine but then the FFT
> > yields values like :
> > p Array [0]: vtkDoubleArray "result", 2,097,152 points, 8 bytes
> > per point
> > p Magnitude Range: 0.0000 1482912.5793
> > p Component 0 Range: -1048575.9848 1048575.8760
> > p Component 1 Range: -1048572.9243 1048579.0968
> > With a simple sin wave, the result should be almost purely imaginary, so
> > the Component 0 range should be almost 0 to 0.
> >
> > When I switch to using the vtkImageExtractComponents, the results look
> > better:
> > p Array [0]: vtkDoubleArray "image", 2,097,152 points, 8 bytes per
> > point
> > p Magnitude Range: 0.0000 1048576.0091
> > p Component 0 Range: -0.0557 0.0011
> > p Component 1 Range: -1048576.0089 1048576.0091
> >
> >
> > Unfortunately, when working with the vtkImageExtractComponents filter, I
> > lose the other two fields if I had planned on using them for coloring or
> > something. Also, my results aren't quite what I expected. Much better,
> > but on more complex datasets I seem to get results that are a little off
> > from the expected result. I don't know if the cause of all this is
> > related, but I'm chasing down what I can.
> >
> > So, any ideas?
> >
> > ----- Code starts here -------
> > #include <stdio.h>
> > #include <string.h>
> > #include <stdlib.h>
> > #include <unistd.h>
> > #include "stat.h"
> > #include <sys/types.h>
> > #include <sys/stat.h>
> > #include <sys/mman.h>
> > #include <fcntl.h>
> > #include <vtkObject.h>
> > #include "vtkImageData.h"
> > #include "vtkPointData.h"
> > #include <vtkDataArray.h>
> > #include <vtkUnsignedCharArray.h>
> > #include <vtkDoubleArray.h>
> > #include <vtkImageData.h>
> > #include <vtkImageFFT.h>
> > #include <vtkArrayCalculator.h>
> > #include <vtkImageExtractComponents.h>
> >
> > int main (int argc, char *argv[])
> > {
> > double *data;
> > int xdim, ydim, zdim;
> > double kx;
> > int x,y,z;
> > long index;
> > xdim = 128;
> > ydim = 128;
> > zdim = 128;
> >
> > if ((data = (double*)malloc(sizeof(double)*xdim*ydim*zdim*3)) == NULL) {
> > perror("Unable to allocate memory!\n\t");
> > return -1;
> > }
> >
> > printf("Constructing sin(kx * x) dataset...\n");
> > kx = 2.0 * 3.1415926 / (double)xdim;
> > for(x=0; x<xdim; x++) {
> > for(y=0; y<ydim; y++) {
> > for(z=0; z<zdim; z++) {
> > index = z + (y*zdim) + (x * ydim * zdim);
> > data[(index*3)+0] = sin(kx * (double)x);
> > data[(index*3)+1] = cos(kx * (double)x);
> > data[(index*3)+2] = tan(kx * (double)x);
> > }
> > }
> > }
> >
> > vtkDoubleArray *ucPointer = vtkDoubleArray::New();
> > ucPointer->SetNumberOfComponents(3);
> > ucPointer->SetArray(data, xdim*ydim*zdim*3, 1);
> > ucPointer->SetName("image");
> >
> > vtkImageData *image = vtkImageData::New();
> > image->Initialize();
> > image->SetDimensions(xdim, ydim, zdim);
> > image->SetExtent(1, xdim, 1, ydim, 1, zdim);
> > image->SetScalarTypeToDouble();
> > image->SetNumberOfScalarComponents(3);
> > image->GetPointData()->SetScalars(ucPointer);
> > PrintStatistics(image);
> > printf("Extracting Velocity X-Component...\n");
> >
> > #if 0
> > vtkArrayCalculator *extract = vtkArrayCalculator::New();
> > extract->SetInput(image);
> > extract->SetResultArrayName("result");
> > extract->AddScalarVariable("x", "image", 0);
> > extract->SetFunction("(x*1.0)+0.0");
> > extract->ReplaceInvalidValuesOff();
> > extract->Update();
> > extract->GetOutput()->GetPointData()->RemoveArray("image");
> > extract->GetOutput()->GetPointData()->SetActiveScalars("result");
> > #else
> > vtkImageExtractComponents *extract = vtkImageExtractComponents::New();
> > extract->SetInput(image);
> > extract->SetComponents(0);
> > extract->Update();
> > #endif
> > PrintStatistics(extract->GetOutput());
> >
> > printf("Computing FFT...\n");
> > vtkImageFFT *fft = vtkImageFFT::New();
> > fft->SetInput(extract->GetOutput());
> > fft->Update();
> > PrintStatistics(fft->GetOutput());
> >
> > }
> >
> >
> > --
> > Randall Hand
> > Visualization Scientist,
> > ERDC-MSRC Vicksburg, MS
> > Homepage: http://www.yeraze.com
> >
> >
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > This is the private VTK discussion list.
> > Please keep messages on-topic. Check the FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> > Follow this link to subscribe/unsubscribe:
> > http://www.vtk.org/mailman/listinfo/vtkusers
>
>
--
Randall Hand
Visualization Scientist,
ERDC-MSRC Vicksburg, MS
Homepage: http://www.yeraze.com
[Attachment #3 (text/html)]
Done... Bug #2234<br>
<br>
<a href="http://www.vtk.org/Bug/bug.php?op=show&bugid=2234&pos=2">http://www.vtk.org/Bug/bug.php?op=show&bugid=2234&pos=2</a><br><br><div><span \
class="gmail_quote">On 9/14/05, <b class="gmail_sendername"> Mathieu Malaterre</b> \
<<a href="mailto:mathieu.malaterre@kitware.com">mathieu.malaterre@kitware.com</a>> \
wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, \
204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> Ok this is a bug:<br><br>i \
========== End of Data Statistics ===============<br>==30679==<br>==30679== ERROR \
SUMMARY: 1 errors from 1 contexts (suppressed: 9 from 4)<br>==30679==<br>==30679== 1 \
errors in context 1 of 1:<br> ==30679== Invalid read of size \
8<br>==30679== at 0x12A4B8F5: \
void<br>vtkImageFFTExecute<double>(vtkImageFFT*, vtkImageData*, int*, \
double*,<br>vtkImageData*, int*, double*, int) \
(vtkImageFFT.cxx:137)<br>==30679== by 0x12A4A645: \
vtkImageFFT::ThreadedExecute(vtkImageData*, <br>vtkImageData*, int*, int) \
(vtkImageFFT.cxx:203)<br>==30679== by \
0x1353AEA2:<br>vtkThreadedImageAlgorithm::ThreadedRequestData(vtkInformation*,<br>vtkInformationVector**, \
vtkInformationVector*, vtkImageData***,<br>vtkImageData**, int*, int) ( \
vtkThreadedImageAlgorithm.cxx:327)<br>==30679== by \
0x1353AA8E:<br>vtkThreadedImageAlgorithmThreadedExecute(void*)<br>(vtkThreadedImageAlgorithm.cxx:200)<br>==30679== by \
0x13BA30F9: start_thread (in /lib64/tls/libpthread- <a \
href="http://2.3.5.so">2.3.5.so</a>)<br>==30679== by \
0x1561AA62: clone (in /lib64/tls/libc-<a \
href="http://2.3.5.so">2.3.5.so</a>)<br>==30679== Address 0x19992030 is 0 \
bytes after a block of size 16777216<br>alloc'd \
<br>==30679== at 0x11B1A8E2: operator new[](unsigned long) \
(in<br>/usr/lib64/valgrind/vgpreload_memcheck.so)<br>==30679== by \
0x1380B136: vtkDataArrayTemplate<double>::Allocate(long<br>long, long long) \
(vtkDataArrayTemplate.txx :99)<br>==30679== by \
0x1380BF2E:<br>vtkDataArrayTemplate<double>::SetNumberOfValues(long \
long)<br>(vtkDataArrayTemplate.txx:536)<br>==30679== by \
0x1380B409:<br>vtkDataArrayTemplate<double>::SetNumberOfTuples(long long) \
<br>(vtkDataArrayTemplate.txx:330)<br>==30679== by \
0x12154566:<br>vtkArrayCalculator::RequestData(vtkInformation*, \
vtkInformationVector**,<br>vtkInformationVector*) \
(vtkArrayCalculator.cxx:279)<br>==30679== by 0x1341A5AA: \
<br>vtkDataSetAlgorithm::ProcessRequest(vtkInformation*,<br>vtkInformationVector**, \
vtkInformationVector*)<br>(vtkDataSetAlgorithm.cxx:175)==30679== by \
0x1342CBC9:<br>vtkExecutive::CallAlgorithm(vtkInformation*, int,<br> \
vtkInformationVector**, vtkInformationVector*) \
(vtkExecutive.cxx:679)<br>==30679== by \
0x13427AF7:<br>vtkDemandDrivenPipeline::ExecuteData(vtkInformation*,<br>vtkInformationVector**, \
vtkInformationVector*)<br>(vtkDemandDrivenPipeline.cxx \
:464)<br>==30679== by \
0x1342732B:<br>vtkDemandDrivenPipeline::ProcessRequest(vtkInformation*, \
int,<br>vtkInformationVector**, \
vtkInformationVector*)<br>(vtkDemandDrivenPipeline.cxx:244)<br>==30679== by \
0x1352487E:<br> vtkStreamingDemandDrivenPipeline::ProcessRequest(vtkInformation*, \
int,<br>vtkInformationVector**, \
vtkInformationVector*)<br>(vtkStreamingDemandDrivenPipeline.cxx:144)<br>==30679== by \
0x13427927: vtkDemandDrivenPipeline::UpdateData(int) \
<br>(vtkDemandDrivenPipeline.cxx:406)<br>==30679== by \
0x13524A04:<br>vtkStreamingDemandDrivenPipeline::Update(int)<br>(vtkStreamingDemandDrivenPipeline.cxx:190)<br><br><br>Could \
you open a bug in the bugtracker(*) for this. Add your program as <br>an \
attachment.<br><br>Thanks<br>Mathieu<br>(*) <a \
href="http://vtk.org/Bug">http://vtk.org/Bug</a><br><br><br><br>Randall Hand \
wrote:<br>> Ok, I posted this once before, but here it is again with some \
more<br>> information. <br>><br>> I've written a piece of code to create a \
synthetic dataset. It's a<br>> 128^3 dataset, each point with a \
3-component double value consisting of<br>> (sin(x), junk, morejunk). I \
extract just the first component, and do an <br>> FFT. You'll find the \
code at the end of this message, along with my<br>> "PrintStatistics" \
function attached.<br>><br>> You'll see from the #if/#endif blocks that there's \
two possible ways to<br> > do it. The first is with a \
vtkArrayCalculator, where I set a very<br>> trivial function to simply copy out \
the one value. The other way is<br>> with a \
vtkImageExtractComponents. When doing it with the<br>> \
vtkArrayCalculator, the filter seems to work just fine but then the FFT <br>> \
yields values like :<br>> p Array [0]: \
vtkDoubleArray "result", 2,097,152 points, 8 bytes<br>> per \
point<br>> p
Magnitude
Range: 0.0000 1482912.5793<br>>
p
Component 0
Range: -1048575.9848
1048575.8760<br>>
p
Component 1
Range: -1048572.9243
1048579.0968<br>> With a simple sin wave, the result should be almost purely \
imaginary, so<br>> the Component 0 range should be almost 0 to 0.<br>><br>> \
When I switch to using the vtkImageExtractComponents, the results look <br>> \
better:<br>> p Array [0]: vtkDoubleArray \
"image", 2,097,152 points, 8 bytes per<br>> point<br>> \
p
Magnitude
Range: 0.0000 1048576.0091<br>>
p
Component 0 Range: -0.0557 0.0011<br>>
p
Component 1
Range: -1048576.0089
1048576.0091<br>><br>><br>> Unfortunately, when working with the \
vtkImageExtractComponents filter, I<br>> lose the other two fields if I had \
planned on using them for coloring or<br>> something. Also, my results \
aren't quite what I expected. Much better, <br>> but on more complex \
datasets I seem to get results that are a little off<br>> from the expected \
result. I don't know if the cause of all this is<br>> related, but I'm \
chasing down what I can.<br>><br>> So, any ideas? <br>><br>> ----- Code \
starts here -------<br>> #include <stdio.h><br>> #include \
<string.h><br>> #include <stdlib.h><br>> #include \
<unistd.h><br>> #include "stat.h"<br> > #include \
<sys/types.h><br>> #include <sys/stat.h><br>> #include \
<sys/mman.h><br>> #include <fcntl.h><br>> #include \
<vtkObject.h><br>> #include "vtkImageData.h"<br> > #include \
"vtkPointData.h"<br>> #include <vtkDataArray.h><br>> #include \
<vtkUnsignedCharArray.h><br>> #include <vtkDoubleArray.h><br>> \
#include <vtkImageData.h><br>> #include < vtkImageFFT.h><br>> \
#include <vtkArrayCalculator.h><br>> #include \
<vtkImageExtractComponents.h><br>><br>> int main (int argc, char \
*argv[])<br>> {<br>> double \
*data;<br>> int xdim, ydim, zdim; \
<br>> double kx;<br>> int \
x,y,z;<br>> long index;<br>> \
xdim = 128;<br>> ydim = \
128;<br>> zdim = \
128;<br>><br>> if ((data = \
(double*)malloc(sizeof(double)*xdim*ydim*zdim*3)) == NULL) { \
<br>> perror("Unable to \
allocate memory!\n\t");<br>> \
return -1;<br>> }<br>><br>> \
printf("Constructing sin(kx * x) \
dataset...\n");<br>> kx = 2.0 * 3.1415926 / \
(double)xdim;<br>> for(x=0; x<xdim; x++) \
{<br>> for(y=0; y<ydim; y++) \
{<br>> \
for(z=0; z<zdim; z++) \
{<br>>
index = z + (y*zdim) + (x * ydim * \
zdim);<br>>
data[(index*3)+0] = sin(kx * \
(double)x);<br>>
data[(index*3)+1] = cos(kx * \
(double)x);<br>>
data[(index*3)+2] = tan(kx * \
(double)x);<br>> \
}<br>> \
}<br>> }<br>><br>> \
vtkDoubleArray *ucPointer = vtkDoubleArray::New();<br>> \
ucPointer->SetNumberOfComponents(3);<br> > \
ucPointer->SetArray(data, xdim*ydim*zdim*3, 1);<br>> \
ucPointer->SetName("image");<br>><br>> \
vtkImageData *image = vtkImageData::New();<br>> \
image->Initialize();<br>> image->SetDimensions(xdim, \
ydim, zdim); <br>> image->SetExtent(1, xdim, 1, ydim, \
1, zdim);<br>> \
image->SetScalarTypeToDouble();<br>> \
image->SetNumberOfScalarComponents(3);<br>> \
image->GetPointData()->SetScalars(ucPointer); <br>> \
PrintStatistics(image);<br>> printf("Extracting \
Velocity X-Component...\n");<br>><br>> #if \
0<br>> vtkArrayCalculator *extract = \
vtkArrayCalculator::New();<br>> \
extract->SetInput(image); <br>> \
extract->SetResultArrayName("result");<br>> \
extract->AddScalarVariable("x", "image", \
0);<br>> \
extract->SetFunction("(x*1.0)+0.0");<br>> \
extract->ReplaceInvalidValuesOff(); <br>> \
extract->Update();<br>> \
extract->GetOutput()->GetPointData()->RemoveArray("image");<br>> \
extract->GetOutput()->GetPointData()->SetActiveScalars("result"); \
<br>> #else<br>> vtkImageExtractComponents *extract = \
vtkImageExtractComponents::New();<br>> \
extract->SetInput(image);<br>> \
extract->SetComponents(0);<br>> \
extract->Update();<br>> #endif <br>> \
PrintStatistics(extract->GetOutput());<br>><br>> \
printf("Computing FFT...\n");<br>> vtkImageFFT \
*fft = vtkImageFFT::New();<br>> \
fft->SetInput(extract->GetOutput());<br> > \
fft->Update();<br>> \
PrintStatistics(fft->GetOutput());<br>><br>> }<br>><br>><br>> \
--<br>> Randall Hand<br>> Visualization Scientist,<br>> ERDC-MSRC Vicksburg, \
MS<br>> Homepage: <a \
href="http://www.yeraze.com">http://www.yeraze.com</a><br>><br>><br>> \
------------------------------------------------------------------------<br>><br>> \
_______________________________________________<br> > This is the private VTK \
discussion list.<br>> Please keep messages on-topic. Check the FAQ at: <a \
href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</a><br>> \
Follow this link to subscribe/unsubscribe: <br>> <a \
href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</a><br><br></blockquote></div><br><br \
clear="all"><br>-- <br>Randall Hand<br>Visualization Scientist, <br>ERDC-MSRC \
Vicksburg, MS <br>Homepage: <a href="http://www.yeraze.com">http://www.yeraze.com</a>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic