NPL
Neurological Programs and Libraries
|
Iterator for an image, that allows for easy access to the neighbors of the current element/pixel. Neighbors can be accessed through offset(i) which simply provides the value of the i'th neighbor. To get that neighbors index you can use it.offset_index(i). For the center use it.center()/it.center_index(). [] may also be used in place of offset. To get the number of neighbors in the kernel use ksize(), so it.offset(0), it.offset(1), ..., it.offset(ksize()-1) are valid calls. More...
#include <iterators.h>
Inherits npl::KSlicer.
Public Member Functions | |
KernelIter () | |
Default constructor. Note, this will segfault if you don't use setArray to set the target NDArray/Image. More... | |
KernelIter (std::shared_ptr< const NDArray > in) | |
void | setArray (ptr< const NDArray > in) |
KernelIter & | operator++ () |
Prefix increment operator. More... | |
KernelIter & | operator-- () |
Prefix decrement operator. More... | |
T | operator* () const |
Dereference operator, get center pixel value. More... | |
T | getC () const |
Same as dereference operator, get center pixel value. More... | |
T | getK (int64_t k) const |
Dereference (get) the pixel at the k'th offset position. To figure out WHERE this pixel is in relation to the center use offsetK. More... | |
T | operator[] (int64_t k) const |
Dereference (get) the pixel at the k'th offset position. To figure out WHERE this pixel is in relation to the center use offsetK. More... | |
bool | operator== (const KernelIter &other) const |
Whether the position and parent are the same as another. More... | |
bool | operator!= (const KernelIter &other) const |
Whether the position and parent are different from another. More... | |
bool | operator< (const KernelIter &other) const |
If the parents are different then false, if they are the same, returns whether this iterator is before the other. More... | |
bool | operator> (const KernelIter &other) const |
If the parents are different then false, if they are the same, returns whether this iterator is after the other. More... | |
bool | operator<= (const KernelIter &other) const |
If the parents are different then false, if they are the same, returns whether this iterator is the same or before the other. More... | |
bool | operator>= (const KernelIter &other) const |
If the parents are different then false, if they are the same, returns whether this iterator is the same or after the other. More... | |
void | setROI (const std::vector< std::pair< int64_t, int64_t >> roi={}) |
Sets the region of interest. During iteration or any motion the position will not move outside the specified range. More... | |
void | setROI (size_t len, const size_t *roisize, const int64_t *roistart=NULL) |
Sets the region of interest, with lower bound of 0. During iteration or any motion the position will not move outside the specified range. Invalidates position. More... | |
void | setOrder (const std::vector< size_t > order={}, bool revorder=false) |
Set the order of iteration, in terms of which dimensions iterate the fastest and which the slowest. More... | |
const std::vector< size_t > & | getOrder () const |
Returns the array giving the order of dimension being traversed. So 3,2,1,0 would mean that the next point in dimension 3 will be next, when wrapping the next point in 2 is visited, when that wraps the next in one and so on. More... | |
void | setRadius (std::vector< size_t > kradius={}) |
Set the radius of the kernel window. All directions will have equal distance, with the radius in each dimension set by the magntitude of the kradius vector. So if kradius = {2,1,0} then dimension 0 (x) will have a radius of 2, dimension 1 (y) will have a readius of 1 and dimension 2 will have a radius of 0 (won't step out from the middle at all). More... | |
void | setRadius (size_t kradius) |
Set the radius of the kernel window. All directions will have equal distance in all dimensions. So if kradius = 2 then dimension 0 (x) will have a radius of 2, dimension 2 (y) will have a readius of 2 and so on. Warning images may have more dimensions than you know, so if the image has a dimension that is only size 1 it will have a radius of 0, but if you didn't know you had a 10D image all the dimensions about to support the radius will. More... | |
void | setWindow (const std::vector< std::pair< int64_t, int64_t >> &krange) |
Set the ROI from the center of the kernel. The first value should be <= 0, the second should be >= 0. The ranges are inclusive. So if kradius = {{-1,1},{0,1},{-1,0}}, in the x dimension values will range from center - 1 to center + 1, y indices will range from center to center + 1, and z indices will range from center-1 to center. Kernel will range from [kRange[0].first, kRange[0].second] [kRange[1].first, kRange[1].second] ... More... | |
bool | isBegin () const |
Are we at the begining of iteration? More... | |
bool | isEnd () const |
Are we at the end of iteration? Note that this will be 1 past the end, as typically is done in c++. More... | |
bool | eof () const |
Are we at the end of iteration? Note that this will be 1 past the end, as typically is done in c++. More... | |
int64_t | linIndex () const |
get linear position of current point More... | |
int64_t | getStride (size_t dd) |
get stride in specified dimension More... | |
void | goBegin () |
Go to the beginning. More... | |
void | goEnd () |
Jump to the end of iteration. More... | |
void | goIndex (const std::vector< int64_t > &newpos) |
Jump to the given position. More... | |
void | indexC (size_t len, int64_t *index) const |
Places the first len dimensions of ND-position in the given array. If the number of dimensions exceed the len then the additional dimensions will be ignored, if len exceeds the dimensionality then index[dim...len-1] = 0. In other words index will be completely overwritten in the most sane way possible if the internal dimensions and size index differ. More... | |
void | indexK (size_t kit, size_t len, int64_t *index, bool bound=true) const |
Get the ND position of the specified offset (kernel) element. More... | |
int64_t | offsetK (size_t kit, size_t dim) |
Returns the distance from the center projected onto the specified dimension. So center is {0,0,0}, and {1,2,1} would return 1,2,1 for inputs dim=0, dim=1, dim=2. Note that this is the ideal offset (so it doesn't respect image bounds). More... | |
void | offsetK (size_t kit, size_t len, int64_t *dindex) const |
Returns offset from center of specified pixel (kit). Note that this is the ideal offset (so it doesn't respect image bounds). More... | |
bool | insideK (size_t k) |
Returns whether the k'th kernel member is inside the region of interest. More... | |
size_t | ksize () const |
Get linear position. More... | |
void | setDim (size_t ndim, const size_t *dim) |
All around intializer. Sets all internal variables. More... | |
Protected Attributes | |
size_t | m_ndim |
std::vector< size_t > | m_size |
std::vector< size_t > | m_strides |
std::vector< size_t > | m_order |
size_t | m_numoffs |
std::vector< int64_t * > | m_offs |
std::vector< int64_t > | m_offs_raw |
size_t | m_center |
int64_t | m_fradius |
int64_t | m_rradius |
std::vector< std::pair< int64_t, int64_t > > | m_roi |
size_t | m_begin |
bool | m_end |
std::vector< int64_t * > | m_pos |
std::vector< int64_t > | m_pos_raw |
std::vector< int64_t > | m_linpos |
Iterator for an image, that allows for easy access to the neighbors of the current element/pixel. Neighbors can be accessed through offset(i) which simply provides the value of the i'th neighbor. To get that neighbors index you can use it.offset_index(i). For the center use it.center()/it.center_index(). [] may also be used in place of offset. To get the number of neighbors in the kernel use ksize(), so it.offset(0), it.offset(1), ..., it.offset(ksize()-1) are valid calls.
The primary functions are operator[] which allows you to get the k'th offset value, indexK() which returns the index of the k'th offset, and offsetK() which returns the offset of k'th offset, IE where it is in relation to the center.
Note that order is the not the default order. If you use using this iterator with another iterator, be sure to setOrder(it.getOrder()) so that both iterators have the same directions.
There are no 'set' functions so this is const iterator.
T |
Definition at line 1871 of file iterators.h.
|
inline |
Default constructor. Note, this will segfault if you don't use setArray to set the target NDArray/Image.
Definition at line 1879 of file iterators.h.
|
inline |
Definition at line 1881 of file iterators.h.
|
inlineinherited |
|
inline |
Same as dereference operator, get center pixel value.
Definition at line 1987 of file iterators.h.
|
inline |
Dereference (get) the pixel at the k'th offset position. To figure out WHERE this pixel is in relation to the center use offsetK.
Definition at line 2001 of file iterators.h.
|
inlineinherited |
|
inlineinherited |
|
inherited |
Go to the beginning.
|
inherited |
Jump to the end of iteration.
|
inherited |
Jump to the given position.
newpos | location to move to |
|
inherited |
Places the first len dimensions of ND-position in the given array. If the number of dimensions exceed the len then the additional dimensions will be ignored, if len exceeds the dimensionality then index[dim...len-1] = 0. In other words index will be completely overwritten in the most sane way possible if the internal dimensions and size index differ.
len | size of index |
index | output index variable |
|
inherited |
Get the ND position of the specified offset (kernel) element.
kit | Kernel index |
len | size of index |
index | output index variable |
bound | report the actual sampled point (ie point after clamping position to be in the image. Interior points will be the same, but on the boundary if you set bound you will only get indices inside the image ROI, otherwise you would get values like -1, -1 -1 for radius 1 pos 0,0,0 |
|
inherited |
Returns whether the k'th kernel member is inside the region of interest.
k | Which pixel to return distance from |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inherited |
Returns the distance from the center projected onto the specified dimension. So center is {0,0,0}, and {1,2,1} would return 1,2,1 for inputs dim=0, dim=1, dim=2. Note that this is the ideal offset (so it doesn't respect image bounds).
kit | Which pixel to return distance from |
dim | dimension to get distance in |
|
inherited |
Returns offset from center of specified pixel (kit). Note that this is the ideal offset (so it doesn't respect image bounds).
kit | Pixel we are referring to |
len | lenght of dindex array |
dindex | output paramter indicating distance of pixel from the center of the kernel in each dimension. If this array is shorter than the iteration dimensions, only the first len will be filled. If it is longer the additional values won't be touched |
|
inline |
Whether the position and parent are different from another.
other |
Definition at line 2042 of file iterators.h.
|
inline |
Dereference operator, get center pixel value.
Definition at line 1974 of file iterators.h.
|
inline |
|
inline |
|
inline |
If the parents are different then false, if they are the same, returns whether this iterator is before the other.
other |
Definition at line 2055 of file iterators.h.
|
inline |
If the parents are different then false, if they are the same, returns whether this iterator is the same or before the other.
other |
Definition at line 2097 of file iterators.h.
|
inline |
Whether the position and parent are the same as another.
other |
Definition at line 2030 of file iterators.h.
|
inline |
If the parents are different then false, if they are the same, returns whether this iterator is after the other.
other |
Definition at line 2076 of file iterators.h.
|
inline |
If the parents are different then false, if they are the same, returns whether this iterator is the same or after the other.
other |
Definition at line 2116 of file iterators.h.
|
inline |
Dereference (get) the pixel at the k'th offset position. To figure out WHERE this pixel is in relation to the center use offsetK.
Definition at line 2015 of file iterators.h.
|
inline |
Definition at line 1886 of file iterators.h.
|
inherited |
All around intializer. Sets all internal variables.
ndim | Rank (number of dimensions), also length of dim array |
dim | Dimension (size) of memory block. |
|
inherited |
Set the order of iteration, in terms of which dimensions iterate the fastest and which the slowest.
order | order of iteration. {0,1,2} would mean that dimension 0 (x) would move the fastest and 2 the slowest. If the image is a 5D image then that unmentioned (3,4) would be the slowest. |
revorder | Reverse the speed of iteration. So the first dimension in the order vector would in fact be the slowest and un-referenced dimensions will be the fastest. (in the example for order this would be 4 and 3). |
|
inherited |
Set the radius of the kernel window. All directions will have equal distance, with the radius in each dimension set by the magntitude of the kradius vector. So if kradius = {2,1,0} then dimension 0 (x) will have a radius of 2, dimension 1 (y) will have a readius of 1 and dimension 2 will have a radius of 0 (won't step out from the middle at all).
kradius | vector of radii in the given dimension. Unset values assumed to be 0. So a 10 dimensional image with 3 values will have non-zero values for x,y,z but 0 values in higher dimensions |
|
inherited |
Set the radius of the kernel window. All directions will have equal distance in all dimensions. So if kradius = 2 then dimension 0 (x) will have a radius of 2, dimension 2 (y) will have a readius of 2 and so on. Warning images may have more dimensions than you know, so if the image has a dimension that is only size 1 it will have a radius of 0, but if you didn't know you had a 10D image all the dimensions about to support the radius will.
kradius | Radius in all directions. |
|
inherited |
Sets the region of interest. During iteration or any motion the position will not move outside the specified range.
roi | pair of [min,max] values in the desired hypercube |
|
inherited |
Sets the region of interest, with lower bound of 0. During iteration or any motion the position will not move outside the specified range. Invalidates position.
Invalidates position
len | length of roi array |
roistart | lower bound of ROI |
roisize | Size of ROI (which runs in the block from: [0 to roisize[0]-1,0. to roisize[1]-1, etc] |
|
inherited |
Set the ROI from the center of the kernel. The first value should be <= 0, the second should be >= 0. The ranges are inclusive. So if kradius = {{-1,1},{0,1},{-1,0}}, in the x dimension values will range from center - 1 to center + 1, y indices will range from center to center + 1, and z indices will range from center-1 to center. Kernel will range from [kRange[0].first, kRange[0].second] [kRange[1].first, kRange[1].second] ...
krange | Vector of [inf, sup] in each dimension. Unaddressed (missing) values are assumed to be [0,0]. |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |