[Insight-developers] GetPixel and SetPixel
Lydia Ng
lng at statsci.com
Tue Aug 1 20:42:11 EDT 2000
Hi,
I am a newbie to this list, so please excuse me if
this question has been posted before.
I am under the impression that:
1) the data in the Image<,> class is stored
such that the column index is the fastest
varying then row, then slices etc..., and
2) the Index class is defined such that
index[0] = column; index[1] = row; index[3] = slice etc..
If these two observation are right, it seems that
there is an error in Image<,>::SetPixel() and
Image<,>::GetPixel().
In the code below shouldn't
the for loop go from i = 0 to dimension -1 ?
Cheers,
Lydia
----------------------------------------------------
template<class TPixel, unsigned int VImageDimension>
void
Image<TPixel, VImageDimension>
::SetPixel(const Index &ind, const TPixel& value)
{
// FIXME: add bounds checking for the region/image
unsigned long offset=0;
unsigned long prod=1;
const unsigned long *index = ind.GetIndex();
const unsigned long *size = this->GetSize();
unsigned int dimension = this->GetDimension();
// data is arranged as [][][][slice][row][col]
for (int i=dimension-1; i >= 0; i--)
{
offset += prod*index[i];
prod *= size[i];
}
(*m_Data)[offset] = value;
}
----
Lydia Ng, Research Scientist
MathSoft, Inc.
1700 Westlake Ave N, Suite 500
Seattle WA 98109
lng at statsci.com
Tel: 206-283-8802 x308
Fax: 206-283-6310
More information about the Insight-developers
mailing list