(Return to Images)
This code is in image1.cc. Note that MaskedImage iterators work almost identically, the main difference being how pixel values are set.
If you need access to nearby pixels, see the Image locator tutorial.
img = 100;
ImageT img2(img.getDimensions(), 100.0);
for (
int y = 0; y != img.getHeight(); ++
y) {
for (ImageT::x_iterator
ptr = img.row_begin(y),
end = img.row_end(y);
ptr !=
end; ++
ptr) {
}
}
for (
int y = 0; y != img.getHeight(); ++
y) {
for (ImageT::x_iterator
ptr = img.row_begin(y);
ptr != img.row_end(y); ++
ptr) {
}
}
for (ImageT::iterator
ptr = img.begin(),
end = img.end();
ptr !=
end; ++
ptr) {
}
for (ImageT::reverse_iterator
ptr = img.rbegin(),
end = img.rend();
ptr !=
end; ++
ptr) {
}
for (ImageT::iterator
ptr = img.at(0, 0),
end = img.end();
ptr !=
end; ++
ptr) {
}
for (ImageT::fast_iterator
ptr = img.begin(
true),
end = img.end(
true);
ptr !=
end; ++
ptr) {
}
for (
int x = 0; x != img.getWidth(); ++
x) {
for (ImageT::y_iterator
ptr = img.col_begin(x),
end = img.col_end(x);
ptr !=
end; ++
ptr) {
}
}
int x = 0;
for (; x != img.getWidth() % 4; ++
x) {
for (ImageT::y_iterator
ptr = img.col_begin(x),
end = img.col_end(x);
ptr !=
end; ++
ptr) {
}
}
for (; x != img.getWidth(); x += 4) {
for (ImageT::y_iterator ptr0 = img.col_begin(x + 0), end0 = img.col_end(x + 0),
ptr1 = img.col_begin(x + 1), ptr2 = img.col_begin(x + 2),
ptr3 = img.col_begin(x + 3);
ptr0 != end0; ++ptr0, ++ptr1, ++ptr2, ++ptr3) {
*ptr0 = *ptr1 = *ptr2 = *ptr3 = 100;
}
}
img.writeFits("foo.fits");
return 0;
}