CTA算法
Conditional Texture Anisotropy
Roli 提 出 了 各 向 异 性 测 度 ( Conditional Texture Anisotropy, CTA) 的概念和计算原理, Nguyen 提出了各向异性测度的具体计算方法
选取某个像素的灰度,计算4个方向的P值,再计算CTA,然后把CTA从[0,1]映射到[0,255],生成灰度图,便于观察。
A是原图,B是灰度图
X是一个向量,由(均值,方差)组成。
m 和 σ 分别为整张图像的深度均值和标准差;
j表示4个方向,每个方向产生一条线,当成一个向量,线上有2d+1个像素,计算他们的P值
沿中心像素的 0°、45°、90° 和 135° 四个方向
L2为裂缝点,l1非裂缝点
裂缝的某个方向的P值会与其他方向的P值有很大的差距,使得CTA的值接近1,
非裂缝则是4个方向大致一样,使CTA接近0.
把4个P中的最大和最小值选出来计算CTA。
自己的代码测试效果图
上干货代码:(需要opencv 3.5以上版本)
CTA_function.cpp
#include "pch.h"
#include <iostream>
#include "math.h"
#include <algorithm>
#include<core/core.hpp>
#include<highgui/highgui.hpp>
#include "opencv2/opencv.hpp"
#include <opencv2/core/core.hpp>
#include <imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/ml/ml.hpp>
using namespace std;
using namespace cv;
/*
计算每一个像素点的CTA
*/
/*
求均值,0度
X(rows)动,Y不动
*/
float fun_sum_1(pixel px1, int d, Mat pic) {
/*
135度
X增Y增
*/
float fun_sum_2(pixel px1, int d, Mat pic) {
}
/*
求均值,90度,
*/
float fun_sum_3(pixel px1, int d, Mat pic) {
}
/*
45度
X增Y减
*/
float fun_sum_4(pixel px1, int d, Mat pic) {
}
/*
差的平方的求和,0度
X动,Y不动
*/
float fun_dif_1(pixel px1, int d, float mean, Mat pic) {
}
/*
差的平方的求和,45度
X增Y增
*/
float fun_dif_2(pixel px1, int d, float mean, Mat pic) {
}
/*
差的平方的求和,90度
X不动,Y动
*/
float fun_dif_3(pixel px1, int d, float mean, Mat pic) {
}
/*
差的平方的求和,135度
X增,Y减
*/
float fun_dif_4(pixel px1, int d, float mean, Mat pic) {
}
/*
标准差
*/
float fun_dif(float means, Mat pic) {
}
float fun_p(float mean1, float stdev1, float means, float stdev)
{
}
float fun_CTA(pixel px1, int d, Mat pic) {
}
/*
映射[0,1]->[0,255]
*/
int Projection01to0255(float cta) {
}
Mat CTA(Mat inPut, int distance) {
}
CTA_function.h
#include "pch.h"
#include <iostream>
#include "math.h"
#include <algorithm>
#include<core/core.hpp>
#include<highgui/highgui.hpp>
#include "opencv2/opencv.hpp"
#include <opencv2/core/core.hpp>
#include <imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/ml/ml.hpp>
using namespace std;
using namespace cv;
typedef struct
{
int x;
int y;
}pixel;
float fun_sum_1(pixel px1, int d, Mat pic);
float fun_sum_2(pixel px1, int d, Mat pic);
float fun_sum_3(pixel px1, int d, Mat pic);
float fun_sum_4(pixel px1, int d, Mat pic);
float fun_dif_1(pixel px1, int d, float mean, Mat pic);
float fun_dif_2(pixel px1, int d, float mean, Mat pic);
float fun_dif_3(pixel px1, int d, float mean, Mat pic);
float fun_dif_4(pixel px1, int d, float mean, Mat pic);
float fun_dif(float means, Mat pic);
float fun_means(Mat pic);
float fun_p(float mean1, float stdev1, float means, float stdev);
float fun_CTA(pixel px1, int d, Mat pic);
int Projection01to0255(float cta);
Mat CTA(Mat inPut,int distance) ;
void test();
之后发现,计算速度很慢,又进行了多线程的优化,是原来的2.5倍速(笑)。
这里给出文件:
CTA_function_thread.cpp
最后,引用论文是
【Automatic Detection and Classification of Defect on road Pavement using Anisotropy Measure】 Tien Sy Nguyen, Manuel Avila, St´ephane Begot