Commit c4bb3f89 authored by Guillaume Lazzara's avatar Guillaume Lazzara
Browse files

mln/io/dicom/load.hh: Fix invalid data while loading large image.

parent 742ddd12
2011-05-12 Guillaume Lazzara <z@lrde.epita.fr>
* mln/io/dicom/load.hh: Fix invalid data while loading large
image.
2010-12-10 Roland Levillain <roland@lrde.epita.fr>
 
Ensure non implemented reconstructions on sets abort at run time.
// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
// Copyright (C) 2009, 2011 EPITA Research and Development Laboratory
// (LRDE)
//
// This file is part of Olena.
//
......@@ -139,14 +140,21 @@ namespace mln
algebra::vec<mln_site_(I)::dim, unsigned int> vmin;
algebra::vec<mln_site_(I)::dim, unsigned int> vmax;
algebra::vec<mln_site_(I)::dim, unsigned int> vdims;
for (int i = 0; i < ndims; ++i)
int j = ndims - 1;
for (int i = 0; i < ndims; ++i, --j)
{
vmin[i] = 0;
vmax[i] = dims[i] - 1;
if (i == 0)
vdims[i] = 1;
vdims[j] = 1;
else
vdims[i] = dims[i - 1] * vdims[i - 1];
vdims[j] = dims[i - 1] * vdims[j + 1];
}
if (ndims > 1)
{
std::swap(vmin[0], vmin[1]);
std::swap(vmax[0], vmax[1]);
}
mln_site(I) pmin(vmin);
......@@ -155,25 +163,23 @@ namespace mln
initialize(ima, result);
mln_piter(I) p(ima.domain());
unsigned int index = 0;
for_all(p)
{
index = 0;
for (int i = 0; i < ndims; ++i)
{
index += p.to_site().to_vec()[i] * vdims[i];
index += p[i] * vdims[i];
}
ima(p) = (unsigned char) dataBuffer[(index * bytes_allocated) * samples_per_pixel];
mln_value(I) v = (unsigned char) dataBuffer[(index * bytes_allocated) * samples_per_pixel];
// FIXME: RGB support, HighBit if HB == 1
for (int j = 0; j < bytes_allocated; ++j)
for (unsigned int j = 0; j < bytes_allocated; ++j)
{
ima(p) += ((unsigned char) dataBuffer[(index * bytes_allocated + j) * samples_per_pixel]) * 256 * j;
v += ((unsigned char) dataBuffer[(index * bytes_allocated + j) * samples_per_pixel]) * 256 * j;
}
/*std::cout << "[ x = " << p.to_site().to_vec()[0]
<< " | y = " << p.to_site().to_vec()[1]
<< " | z = " << p.to_site().to_vec()[2]
<< " ] => " << ima(p)
<< std::endl;*/
ima(p) = v;
}
delete(dataBuffer);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment