Reputation: 823
I have a Eigen Matrix with the size 256x256.
I want to shrink it to 100x100 and want to keep the inner values so the values from index 78,78 till 178,178.
I want to do this with the block operation but I get a matrix with a wrong size. The block has 178 rows and 178 columns instead of 100 rows and columns.
Eigen::MatrixXf small = Eigen::MatrixXf::Constant(100, 100, 0.0);
small = matrix.block(78, 78, 178, 178).eval();
cout<<small.rows()<<endl;
cout<<small.cols()<<endl;`
outputs 178 and 178.
What am I doing wrong?
Upvotes: 1
Views: 150
Reputation: 2695
As per documentation https://eigen.tuxfamily.org/dox/group__TutorialBlockOperations.html :
matrix.block(i,j,p,q);
means
Block of size (p,q), starting at (i,j)
So you need, in your case p=q=100
, hence something like
small = matrix.block(78, 78, 100, 100).eval();
Upvotes: 4
Reputation: 385405
You misread the documentation.
The third and fourth arguments are width and height, not X2 or Y2.
So, simply pass 100, 100 instead.
Upvotes: 4