You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

98 lines
2.9 KiB
C++

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#pragma once
#include "afxcoll.h"
#include <vector>
#include <string>
#include "CxImage/CxImage/ximage.h"
#include "..\Xy.h"
struct ColorPoint {
int R;
int G;
int B;
double zValue;
};
class AFX_EXT_CLASS GenerateImageMesh
{
public:
// 颜色采样方式
enum ColorMethod {
HSV_M = 0, //HSV极端方法
UNIFORMSAMPLING_M = 1, //均匀采样方法
KMEANS_M = 2 //K-Means聚类方法
};
// 颜色排序方式
enum SortMethod {
BRIGHTNESS_SORT = 0, //亮度(升序)
HUE_SORT_COLD = 1, //色调冷
HUE_SORT_WARM = 2, //色调暖
HUE_SORT = 3
};
GenerateImageMesh();
~GenerateImageMesh();
//设置输入数据
void SetImageBase(CxImage image);
void SetImageBase(const std::string& path);
std::string GetImagePath();
//设置色标(默认色标)
void SetColorCardPath(const std::string& path);
std::string GetColorCardPath();
void SetGridNumber(int num);
int GetGridNumber();
void SetZminByZmax(double zMin, double zMax);
double GetZmin();
double GetZmax();
/**
* 自动获取生成色标文件组成色彩(默认由冷到暖)
* \param colorVectors 颜色和z值集合z值从小到大
* \param ColorMethod 颜色采样方式
* \param SortMethod 颜色排序方式
* \param numColors 提取数量
* \return
*/
bool CreateColorBarData(std::vector<ColorPoint>& colorPVector, GenerateImageMesh::ColorMethod type, GenerateImageMesh::SortMethod sortType, int numColors = 5);
/**
* 生成色标文件:
* \param colorVector 颜色和z值集合z值从小到大
* \param barSavePath 色标文件路径
* \param xmlPath 色标文件xml
* \param width 色标文件图片宽
* \param height 色标文件图片高
* \return
*/
bool CreateMeshColorBar(const std::vector<ColorPoint>& colorVector, const std::string& barSavePath, double minz, double maxz,
const std::string& xmlPath = "", int width = 1200, int height = 60);
// 生成网格图像数据
CMesh * CreateImageMeshProcess(int numX, int numY
, double dLocationX, double dLocationY
, double dDeltX, double dDeltY, double dmaxX, double dmaxY
, const std::vector<ColorPoint>& colorVector, const std::vector<ColorPoint>& colorListVector);
bool CreateImageMesh(int numX, int numY
, double dLocationX, double dLocationY, double dDeltX, double dDeltY , double dmaxX, double dmaxY,
const std::vector<ColorPoint>& colorVector);
double FindThirdValues(const std::vector<std::tuple<int, int, double>>& data,
int first, int second);
protected:
void Init();
bool LaodImageCV();//加载内存数据
private:
int m_num; //网格大小10 10*10
double m_zMinCV; //最开始创建的区间值
double m_zMaxCV;
std::string m_colorCardPath; //颜色卡
std::string m_imagePath; //图像
CxImage m_xImage; //输入图像内存数据
CMesh *p_mesh;
};