赞
踩
1.Eigen普通支持Matrix为二维矩阵,三维矩阵,或者更高维的,叫Tensor
2.对于深度学习训练还是想使用tensorflow
3.多维的Tensor矩阵操作起来还是很不方便,至少现在不太清楚是怎么操作的
4.在处理Tensor.mean时,数据过多且tensor为int类型时,可能存在总和越界,求出来为负值情况,而且只有tensor数据类型为double时,与opencv结果保持一致
学习过程中的部分测试代码:
- #include "color.h"
- void main()
- {
- std::string image_path = "test_image/temp.bmp";
- Color* color = Color::Init();
- cv::Mat image;
- color->readImage(image_path, image);
- //image.convertTo(image, CV_32F,1.0/255.0);
- //cv::resize(image, image, cv::Size(0, 0), 0.5, 0.5);
- cv::cvtColor(image, image, cv::COLOR_BGR2RGB);
- Eigen::Tensor<double, 3> m_image(image.rows,image.cols,image.channels());
- cv::cv2eigen(image, m_image);
- // 对每个维度求均值
- //Eigen::Tensor<int, 0> mean_0 = m_image.mean(0);
- //Eigen::Tensor<int, 0> mean_1 = m_image.mean(1);
- //Eigen::Tensor<int, 0> mean_2 = m_image.mean(2);
- //std::cout << m_image << std::endl;
- std::cout << "mean 0: " << m_image.mean() << std::endl;
- //std::cout << "mean 1: " << mean_1(0) << std::endl;
- //std::cout << "mean 2: " << mean_2(0) << std::endl;
- std::cout << cv::mean(image) << std::endl;
- std::cout << (cv::mean(image)[0] + cv::mean(image)[1] + cv::mean(image)[2])/3.0 << std::endl;
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。