#pragma once
#include "raw_image_class.h"
//#include <mymist_ver2.h>
//#include <myOpenCV.h>
#include "myOpenCV3.h"
#include "mymist.h"
//出血検出に関する関数をまとめたクラス
//主に骨抽出手法と出血候補領域抽出手法
static class Extravasation_detect
{
public:
//座標
struct LabelData {
int x = 0;
int y = 0;
int z = 0;
int minz = 0;
int maxz = 0;
int minx = 0;
int maxx = 0;
int miny = 0;
int maxy = 0;
int xCount = 0;
int yCount = 0;
int zCount = 0;
int Area = 0;
int CTValue = 0;
bool Delete = true;
bool Detectcheck = true;
};
//どの位置を示しているかを表す列挙型
enum BODYTYPE{HEAD,UPPER,LOWER};
//骨抽出関連
//人工物除去
static array3<uchar> Artificial_Segmentation(Raw_image<short>& ct);
//適応的閾値決定
static int Adaptive_Threshold(Raw_image<short>& ct);
//watershed
static array3<uchar> Watershed(short* ct, array3<uchar> prebone, int thre);
//従来の骨抽出手法
static array3<uchar> Old_BoneExtractMethod(Raw_image<short>& ct, BODYTYPE type);
//thresholdを変えることで適応的閾値処理になる
static array3<uchar> Bone_Extract(Raw_image<short>& ct, BODYTYPE type,int threshold = 350);
//出血候補領域抽出手法
/*候補領域抽出パラメータ*/
struct Parameter {
//骨抽出
int HighCut;
//平均CT値
int MaxCTValue;
int MinCTValue;
//候補領域抽出
int MINV;
int CutVeno;
int ExtractKarnel;
float sigma;
int MaxVolume;
};
//二段階閾値処理
static array3<uchar> double_thresholding(Raw_image<short>& ct, array3<uchar>& bone, BODYTYPE type);
//ピーク点ベース(dencity_vertexをやる前に骨領域除去が必要)
template <typename Type>
static array3<float> unshape(array3<Type>& input);
static std::vector<mist::vector3<int>> reduction_point(array3<short> ct, std::vector<mist::vector3<int>>& point, float rate);
static array3<uchar> dencity_vertex(Raw_image<short>& ct,array3<uchar>& bon);
//評価
//結果の構造体
struct Result {
array3<uchar> Evalu_Array;
int region = 0;
int TP = 0;
int FP = 0;
int MissCount = 0;
int OriginalP = 0;
int HEADP = 0;
int LOWERP = 0;
int UPPERP = 0;
int MissH = 0;
int MissL = 0;
int MissU = 0;
int HFP = 0;
int UFP = 0;
int LFP = 0;
public:
void ToString(int casenum = 0);
};
static Result Evaluation(array3<unsigned int>& InputLabel, size_t& VenoCount,
array3<uchar>& Mask, int SIZE1, int SIZE2);
//その他
static array3<uchar> ArrayLink(array3<uchar>& FirstArray, array3<uchar>& SecondArray);
};