增加菌落计数的算法
This commit is contained in:
parent
2c6997ec99
commit
418ce1b81a
@ -9,6 +9,9 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using System.Threading;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
|
||||
namespace PBAnaly.Module
|
||||
{
|
||||
@ -25,6 +28,12 @@ namespace PBAnaly.Module
|
||||
private Image<Rgb24> image_rgb_24 = null;
|
||||
private LanesImagePanel imagePanel = null;
|
||||
private BioanayImagePaletteForm imagePaletteForm = null;
|
||||
private PBBiologyVC.PBColonyVC pbvc = new PBBiologyVC.PBColonyVC();
|
||||
|
||||
private Thread algThread;
|
||||
private bool isalgRun = false;
|
||||
private bool isUpdateAlg = false;
|
||||
|
||||
#endregion
|
||||
|
||||
public ColonyMannage(string _path, ReaLTaiizor.Controls.Panel _pl_right, Dictionary<string,ColonyMannage> colonyMannages)
|
||||
@ -43,11 +52,23 @@ namespace PBAnaly.Module
|
||||
return;
|
||||
}
|
||||
|
||||
ImageAlg();
|
||||
RefreshImage();
|
||||
}
|
||||
|
||||
|
||||
#region 方法
|
||||
|
||||
private void ImageAlg()
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
fixed (byte* p = image_byte)
|
||||
{
|
||||
pbvc.run(p, 16, (ushort)image_L16.Width, (ushort)image_L16.Height, -1, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
private bool ReadTif()
|
||||
{
|
||||
// 读tif 或 tiff
|
||||
|
@ -1,53 +1,53 @@
|
||||
#include "pch.h"
|
||||
//#include "PBColonyVC.h"
|
||||
//#include <opencv2/opencv.hpp>
|
||||
//#include <PBColony.h>
|
||||
//
|
||||
//PBBiologyVC::PBColonyVC::PBColonyVC()
|
||||
//{
|
||||
// // pbcolony = new PBColony;
|
||||
//}
|
||||
//PBBiologyVC::PBColonyVC::~PBColonyVC()
|
||||
//{
|
||||
// //delete pbcolony;
|
||||
//}
|
||||
//
|
||||
//void PBBiologyVC::PBColonyVC::run(System::Byte* image, int bit, unsigned short width, unsigned short height,int lower=-1,int upper=-1)
|
||||
//{
|
||||
// //cv::Mat input_cn1;
|
||||
// //if (bit == 16)
|
||||
// //{
|
||||
// // input_cn1 = cv::Mat(height, width, CV_16UC1, image);
|
||||
// // cv::normalize(input_cn1, input_cn1, 0, 255, cv::NORM_MINMAX); // ¹éÒ»»¯µ½ 0-255
|
||||
// // input_cn1.convertTo(input_cn1, CV_8UC1); // ת»»Îª CV_8UC1
|
||||
// //}
|
||||
// //else if (bit == 8)
|
||||
// //{
|
||||
// // input_cn1 = cv::Mat(height, width, CV_8UC1, image);
|
||||
// //}
|
||||
// //else
|
||||
// //{
|
||||
// // return;
|
||||
// //}
|
||||
// //Mat input_cn3;
|
||||
// //Point2f center;
|
||||
// //float radius;
|
||||
// //int ret =pbcolony->colony_get_circle(input_cn1, center, radius);
|
||||
// //if (ret)
|
||||
// //{
|
||||
// // cv::Mat mask = pbcolony->generateMaskImage(input_cn1.cols, input_cn1.rows, center.x - radius, center.y - radius, 2 * radius, 2 * radius);
|
||||
// // int lower = -1;
|
||||
// // int upper = -1;
|
||||
// // Mat bin = pbcolony->get_lower_upper(input_cn1, mask, lower, upper);
|
||||
//
|
||||
// // ClassifyStandard class_stand;
|
||||
// // pbcolony->init_classify_standard(class_stand);
|
||||
// // vector<ColonyInfo> Cinfo = pbcolony->get_colony_info(input_cn1, bin, input_cn3, class_stand, pbcolony->image_inverted_flag);
|
||||
// // ColonyStatistic CStatistic = pbcolony->get_colony_statistics(Cinfo);
|
||||
//
|
||||
// // cv::imshow("a", input_cn3);
|
||||
// // cv::waitKey(0);
|
||||
//
|
||||
//
|
||||
// // }
|
||||
//}
|
||||
#include "PBColonyVC.h"
|
||||
#include <opencv2/opencv.hpp>
|
||||
#include <PBColony.h>
|
||||
|
||||
void PBBiologyVC::PBColonyVC::run(System::Byte* image, int bit, unsigned short width, unsigned short height,int lower,int upper)
|
||||
{
|
||||
PBColony pbcolony;
|
||||
cv::Mat input_cn1;
|
||||
if (bit == 16)
|
||||
{
|
||||
input_cn1 = cv::Mat(height, width, CV_16UC1, image);
|
||||
cv::normalize(input_cn1, input_cn1, 0, 255, cv::NORM_MINMAX); // ¹éÒ»»¯µ½ 0-255
|
||||
input_cn1.convertTo(input_cn1, CV_8UC1); // ת»»Îª CV_8UC1
|
||||
}
|
||||
else if (bit == 8)
|
||||
{
|
||||
input_cn1 = cv::Mat(height, width, CV_8UC1, image);
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
Mat input_cn3;
|
||||
Point2f center;
|
||||
float radius;
|
||||
int ret =pbcolony.colony_get_circle(input_cn1, center, radius);
|
||||
if (ret)
|
||||
{
|
||||
cv::Mat mask = pbcolony.generateMaskImage(input_cn1.cols, input_cn1.rows, center.x - radius, center.y - radius, 2 * radius, 2 * radius);
|
||||
int lower = -1;
|
||||
int upper = -1;
|
||||
Mat bin = pbcolony.get_lower_upper(input_cn1, mask, lower, upper);
|
||||
|
||||
ClassifyStandard class_stand;
|
||||
pbcolony.init_classify_standard(class_stand);
|
||||
vector<ColonyInfo> Cinfo = pbcolony.get_colony_info(input_cn1, bin, input_cn3, class_stand, pbcolony.image_inverted_flag);
|
||||
ColonyStatistic CStatistic = pbcolony.get_colony_statistics(Cinfo);
|
||||
|
||||
cv::imshow("a", input_cn3);
|
||||
cv::waitKey(0);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
PBBiologyVC::PBColonyVC::~PBColonyVC()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,66 +1,77 @@
|
||||
//#pragma once
|
||||
//
|
||||
//using namespace System;
|
||||
//using namespace System::Collections::Generic;
|
||||
//using namespace System::Runtime::InteropServices;
|
||||
//
|
||||
//namespace PBBiologyVC
|
||||
//{
|
||||
// public enum dataClassVC
|
||||
// {
|
||||
// AREA = 0, //面积
|
||||
// PERIMETER, //周长
|
||||
// DIAMETER, //直径
|
||||
// IOD, //IOD
|
||||
// };
|
||||
// public ref struct ColonyInfoVC
|
||||
// {
|
||||
// int IDX; //菌落序号
|
||||
// int area; //菌落面积
|
||||
// int perimeter; //菌落周长
|
||||
// float diameter; //菌落直径
|
||||
// int IOD; //菌落IOD
|
||||
// int classify; //菌落分类
|
||||
// };
|
||||
// public ref struct ClassifyStandardVC
|
||||
// {
|
||||
// List<float>^ interval; //分类依据间隔标志数据
|
||||
// float maxd; //分类最大间隔标志
|
||||
// float mind; //分类最小间隔标志
|
||||
// int num; //分类间隔数
|
||||
// dataClassVC classes; //分类类别
|
||||
// };
|
||||
// public ref struct MinMaxInfoVC
|
||||
// {
|
||||
// float mind; //最小值
|
||||
// float minIDX; //最小值对应序号
|
||||
// float maxd; //最大值
|
||||
// float maxIDX; //最大值对应序号
|
||||
// float range; //范围
|
||||
// float mean; //均值
|
||||
// float sum; //和
|
||||
// int number; //数量
|
||||
// };
|
||||
//
|
||||
//
|
||||
// public ref struct ColonyStatisticVC
|
||||
// {
|
||||
// MinMaxInfoVC area; //面积统计结果
|
||||
// MinMaxInfoVC perimeter; //周长统计结果
|
||||
// MinMaxInfoVC diameter; //直径统计结果
|
||||
// MinMaxInfoVC IOD; //IOD统计结果
|
||||
// MinMaxInfoVC classify; //分类统计结果
|
||||
// };
|
||||
#pragma once
|
||||
|
||||
using namespace System;
|
||||
using namespace System::Collections::Generic;
|
||||
using namespace System::Runtime::InteropServices;
|
||||
|
||||
namespace PBBiologyVC{
|
||||
|
||||
public ref struct ColonyInfoVC
|
||||
{
|
||||
public:
|
||||
int IDX; //菌落序号
|
||||
int area; //菌落面积
|
||||
int perimeter; //菌落周长
|
||||
float diameter; //菌落直径
|
||||
int IOD; //菌落IOD
|
||||
int classify; //菌落分类
|
||||
|
||||
};
|
||||
public enum dataClassVC
|
||||
{
|
||||
AREA = 0, //面积
|
||||
PERIMETER, //周长
|
||||
DIAMETER, //直径
|
||||
IOD, //IOD
|
||||
};
|
||||
public ref struct ClassifyStandardVC
|
||||
{
|
||||
List<float>^ interval; //分类依据间隔标志数据
|
||||
float maxd; //分类最大间隔标志
|
||||
float mind; //分类最小间隔标志
|
||||
int num; //分类间隔数
|
||||
dataClassVC classes; //分类类别
|
||||
};
|
||||
public ref struct MinMaxInfoVC
|
||||
{
|
||||
float mind; //最小值
|
||||
float minIDX; //最小值对应序号
|
||||
float maxd; //最大值
|
||||
float maxIDX; //最大值对应序号
|
||||
float range; //范围
|
||||
float mean; //均值
|
||||
float sum; //和
|
||||
int number; //数量
|
||||
};
|
||||
|
||||
|
||||
public ref struct ColonyStatisticVC
|
||||
{
|
||||
MinMaxInfoVC area; //面积统计结果
|
||||
MinMaxInfoVC perimeter; //周长统计结果
|
||||
MinMaxInfoVC diameter; //直径统计结果
|
||||
MinMaxInfoVC IOD; //IOD统计结果
|
||||
MinMaxInfoVC classify; //分类统计结果
|
||||
};
|
||||
public ref class PBColonyVC
|
||||
{
|
||||
~PBColonyVC();
|
||||
public:
|
||||
void run(System::Byte* image, int bit, unsigned short width, unsigned short height, int lower, int upper);
|
||||
};
|
||||
|
||||
|
||||
|
||||
//public ref class PBColonyVC
|
||||
//{
|
||||
// PBColonyVC();
|
||||
//
|
||||
// ~PBColonyVC();
|
||||
//
|
||||
// //PBColonyVC();
|
||||
|
||||
// //~PBColonyVC();
|
||||
|
||||
//public:
|
||||
// void run(System::Byte* image, int bit, unsigned short width, unsigned short height, int lower , int upper );
|
||||
//
|
||||
// //void run(System::Byte* image, int bit, unsigned short width, unsigned short height, int lower , int upper );
|
||||
|
||||
//private:
|
||||
// //PBColony* pbcolony;
|
||||
//};
|
||||
//}
|
||||
}
|
Loading…
Reference in New Issue
Block a user