在网上找了些代码 凑了凑 好歹实现了把火焰提取出来,算法主要是ostu算法,网上关于ostu的解释很多,大家可以看看,我就直接贴图了代码了,图大了点,希望对大家有用
代码如下
#include "cv.h"
#include "highgui.h"
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <time.h>
//OSTU算法
int HistogramBins = 256;
float HistogramRange1[2] = {0,255};
float *HistogramRange[1] = {&HistogramRange1[0]};
typedef enum {back,object} entropy_state;
double caculateCurrentEntropy(CvHistogram * Histogram1, int cur_threshold, entropy_state state)
{
int start,end;
if(state == back)
{
start = 0;
end = cur_threshold;
}
else
{
start = cur_threshold;
end = 256;
}
int total = 0;