My task is to rewrite the codes is_valid = (DoG == DoG_max) & (DoG >= threshold);
in matlab using armadillo with C++. The DoG
and DoG_max
are multidimensional arrays with the same size 907 x 1210 x 5
, and the threshold is a scalar
.
According to the documentation of armadillo, the bit-wise equal operator ==
is built-in and the bit-wise greater than operation can be replaced with the member function .clean()
which is to set all elements but the ones higher than the threshold to zeros.
Here is my codes:
// arma::cube DoG, DoG_max; // Size: 907 x 1210 x 5.
arma::ucube is_valid(arma::size(DoG), arma::fill::zeros);
DoG.clean(threshold);
for (int s = 0; s < is_valid.n_slices; ++s) {
is_valid.slice(s) = (DoG.slice(s) == DoG_max.slice(s));
}
What confuses me is the bit-wise AND operator, which is not provided by armadillo. I want to know whether the logic of my codes is consistent with is_valid = (DoG == DoG_max) & (DoG >= threshold);
? Based on my investigation, the result is different to that in matlab.
If there're solutions using Eigen, please also tell me!