资源简介
tamura texture c++ 使用openCV2.4.6 + vs2010 实现.
代码片段和文件信息
#include “tamura.h“
#include “fstream“
#define PI (3.141592653589793)
class MYERROR: public runtime_error{
public:
MYERROR(const char * msg = “ “): runtime_error(msg){}
};
void disMat( Mat mat string path ){
if( NULL == mat.data ){
throw MYERROR(“ “) ;
}
int rows = mat.rows ;
int cols = mat.cols ;
fstream out ;
out.open( path ios::out | ios::app ) ;
for( int i = 0 ; i < rows ; i ++ ){
for( int j = 0 ; j < cols ; j++ ){
if( mat.type() == CV_64FC1 ){
double temp = *(double*)( mat.data + i * mat.step.p[0] + j * mat.step.p[1] ) ;
out << temp << ‘\t‘ ;
}
else{
out << (int)*( mat.data + i * mat.step.p[0] + j * mat.step.p[1] ) << ‘\t‘ ;
}
}
out << endl ;
}
out.close() ;
}
TAMURA::TAMURA( Mat& mat int inkValue int inhistBins ){
imgMat = mat ;
kValue = inkValue ;
histBins = inhistBins ;
coarHist = new double[histBins] ;
coarseness = 0 ;
contrast = 0 ;
directionality = 0 ;
calFeatures() ;
}
//======================================================
/// constructor
//======================================================
TAMURA::TAMURA( const string& imgPath int inkValue int inhistBins ){
imgMat = imread( imgPath 0 ) ;
kValue = inkValue ;
histBins = inhistBins ;
coarHist = new double[histBins] ;
coarseness = 0 ;
contrast = 0 ;
directionality = 0 ;
calFeatures() ;
}
//====================================================
/// deconstructor
//====================================================
TAMURA::~TAMURA(){
if( NULL != coarHist ){
delete [] coarHist ;
coarHist = NULL ;
}
}
//======================================================
/// calculate features
//======================================================
void TAMURA::calFeatures( void ){
// coarseness
coarseness = calCoarseness( imgMat coarHist kValue histBins ) ;
// constrast
contrast = calContrast( imgMat ) ;
//directionality
directionality = calDirectionality( imgMat ) ;
}
//=====================================================
/// calculate coarseness for a greylevel image
//=====================================================
double TAMURA::calCoarseness( Mat& mat double* coarHist int kVal int histBins ){
if( NULL == mat.data ){
throw MYERROR( “ mat is empty “ ) ;
}
if( kVal < histBins ){
throw MYERROR( “ input parameters error !!“ ) ;
}
// mats for average horizonal and vertical engergy differece with size k*k
Mat *AverK = new Mat[kValue] ;
Mat *EnKh = new Mat[kValue] ;
Mat *EnKv = new Mat[kValue] ;
for( int i = 0 ; i < kVal ; i ++ ){
AverK[i] = Mat::zeros( mat.size() CV_64FC1 ) ;
EnKh[i] = Mat::zeros( mat.size() CV_64FC1 ) ;
EnKv[i] = Mat::zeros( mat.size() CV_64FC1 ) ;
}
int rows = mat.rows ;
int cols = mat.cols ;
int lenOfk = 1 ;
//step 1 : sum over different window size
for( int i = 0 ; i < kVal ; i
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 13482 2013-08-04 20:47 Tamura texture C++\tamura.cpp
文件 1082 2013-08-04 20:47 Tamura texture C++\tamura.h
目录 0 2013-08-04 20:48 Tamura texture C++\
- 上一篇:用C语言编写二叉排序树
- 下一篇:VB、C++机房管理程序
相关资源
- VB、C++机房管理程序
- OpenGL 真实感图形编程C++实现
- 仓库管理系统分别通过数据库实现和
- C++ TEST 6.0 破解
- 《数据结构——C++实现》第二版课本
- 哈夫曼树 C++算法
- tcp socket实现单进程单线程 高并发服务
- 八数码的深度优先算法c++实现
- C++实现灰度图像的边缘检测、提取及
- 摄影测量直接线性变换DLTVC++程序代码
- 用VC++6.0开发监控界面的方法
- 用Visual C++仿真实现卡尔曼滤波
- libstdc++.so.6.0.17
- c++写的操作系统课程设计:模拟文件
- C++编写的航空客运订票系统
- MFC 界面编程13个
- MFC入门教程:1天深入浅出MFC
- listing_4.1.cpp
- 摄影测量空间后方交会程序合集,含
- 进程调度的设计与实现代码C++
- window平台下c++ 对zip压缩解压缩工程源
- 人工智能旅行商问题实验报告及C++源
- VC++ 基于IE内核功能很齐全的浏览器(
- c++实现最简单的COM
- (转)VC老版主薄荷用VC++6.0写的TCP
- C++ 矩阵乘并行算法实现
- c++ 贪食蛇控制台游戏代码,不闪屏功
- C++实现音频录音wav格式
- 唯一可译码判决准则 1使用的编程:
- x新安江模型c++
评论
共有 条评论