gpt4 book ai didi

opencv - 将不规则重新映射到规则网格

转载 作者:太空宇宙 更新时间:2023-11-03 21:54:14 25 4
gpt4 key购买 nike

我正在使用重映射函数将不规则网格(650 xyz 坐标)映射到常规网格(从 -5 开始的 160x160 点....5 步骤 1/160)但我似乎无法理解在职的。顺便说一句,我使用的插值是双三次的。有人可以告诉我是否可以这样做吗?提前致谢。

using namespace cv;
using namespace POINTS;

std::ofstream file;
Mat src(400,3,CV_32F);
Mat dst(160,160,CV_32F);
Mat map_x;
Mat map_y;
int ind = 0;

Mat matx( 400, 1, CV_32F, &pointsx );
Mat maty( 400, 1, CV_32F, &pointsy );
Mat matz( 400, 1, CV_32F, &pointsz );


void matrixDump( const Mat* mat );
void createMatrix( Mat* mat );

int main()
{

hconcat( matx, maty, matx );
hconcat( matx, matz, src );

map_x.create( 160,160, CV_32FC1 );
map_y.create( 160, 160, CV_32FC1 );

createMatrix( &map_x );
createMatrix( &map_y );
Mat T = map_y.t();
remap( src, dst, map_x, T, CV_INTER_CUBIC, BORDER_CONSTANT, Scalar(0, 0, 0) );

return 0;
}


void matrixDump( const Mat* mat )
{
file.open("interpolation.txt");

for( int i=0; i<mat->rows ; i++ )
{
for( int j=0; j<mat->cols;j++)
{
file << mat->at<float>(i,j) << " " ;
}
}
file.close();
}


void createMatrix( Mat* mat )
{
for( int i=0; i<mat->rows; i++)
{
for( int j=0; j<mat->cols; j++ )
{
float value = -1. + (j*2./(mat->rows-1));
mat->at<float>(i,j) = 5. * value;
}
}
}

最佳答案

map_x.create( 160,160, CV_32FC1 );是 float 的,但当你填充它时,你使用 mat.at<double>(i,j) = 5. * value; .我不知道它是否解决了您的问题,但应该更正。

关于opencv - 将不规则重新映射到规则网格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18403774/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com