增加菌落计数的算法

This commit is contained in:
moco 2025-01-03 22:53:29 +08:00
parent 2c6997ec99
commit 418ce1b81a
4 changed files with 151 additions and 119 deletions

View File

@ -9,6 +9,9 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using System.Threading;
using System.Web.UI.WebControls;
namespace PBAnaly.Module namespace PBAnaly.Module
{ {
@ -25,6 +28,12 @@ namespace PBAnaly.Module
private Image<Rgb24> image_rgb_24 = null; private Image<Rgb24> image_rgb_24 = null;
private LanesImagePanel imagePanel = null; private LanesImagePanel imagePanel = null;
private BioanayImagePaletteForm imagePaletteForm = null; private BioanayImagePaletteForm imagePaletteForm = null;
private PBBiologyVC.PBColonyVC pbvc = new PBBiologyVC.PBColonyVC();
private Thread algThread;
private bool isalgRun = false;
private bool isUpdateAlg = false;
#endregion #endregion
public ColonyMannage(string _path, ReaLTaiizor.Controls.Panel _pl_right, Dictionary<string,ColonyMannage> colonyMannages) public ColonyMannage(string _path, ReaLTaiizor.Controls.Panel _pl_right, Dictionary<string,ColonyMannage> colonyMannages)
@ -43,11 +52,23 @@ namespace PBAnaly.Module
return; return;
} }
ImageAlg();
RefreshImage(); RefreshImage();
} }
#region #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() private bool ReadTif()
{ {
// 读tif 或 tiff // 读tif 或 tiff

View File

@ -1,53 +1,53 @@
#include "pch.h" #include "pch.h"
//#include "PBColonyVC.h" #include "PBColonyVC.h"
//#include <opencv2/opencv.hpp> #include <opencv2/opencv.hpp>
//#include <PBColony.h> #include <PBColony.h>
//
//PBBiologyVC::PBColonyVC::PBColonyVC() void PBBiologyVC::PBColonyVC::run(System::Byte* image, int bit, unsigned short width, unsigned short height,int lower,int upper)
//{ {
// // pbcolony = new PBColony; PBColony pbcolony;
//} cv::Mat input_cn1;
//PBBiologyVC::PBColonyVC::~PBColonyVC() if (bit == 16)
//{ {
// //delete pbcolony; 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
//void PBBiologyVC::PBColonyVC::run(System::Byte* image, int bit, unsigned short width, unsigned short height,int lower=-1,int upper=-1) }
//{ else if (bit == 8)
// //cv::Mat input_cn1; {
// //if (bit == 16) input_cn1 = cv::Mat(height, width, CV_8UC1, image);
// //{ }
// // input_cn1 = cv::Mat(height, width, CV_16UC1, image); else
// // cv::normalize(input_cn1, input_cn1, 0, 255, cv::NORM_MINMAX); // ¹éÒ»»¯µ½ 0-255 {
// // input_cn1.convertTo(input_cn1, CV_8UC1); // ת»»Îª CV_8UC1 return;
// //} }
// //else if (bit == 8) Mat input_cn3;
// //{ Point2f center;
// // input_cn1 = cv::Mat(height, width, CV_8UC1, image); float radius;
// //} int ret =pbcolony.colony_get_circle(input_cn1, center, radius);
// //else if (ret)
// //{ {
// // return; cv::Mat mask = pbcolony.generateMaskImage(input_cn1.cols, input_cn1.rows, center.x - radius, center.y - radius, 2 * radius, 2 * radius);
// //} int lower = -1;
// //Mat input_cn3; int upper = -1;
// //Point2f center; Mat bin = pbcolony.get_lower_upper(input_cn1, mask, lower, upper);
// //float radius;
// //int ret =pbcolony->colony_get_circle(input_cn1, center, radius); ClassifyStandard class_stand;
// //if (ret) pbcolony.init_classify_standard(class_stand);
// //{ vector<ColonyInfo> Cinfo = pbcolony.get_colony_info(input_cn1, bin, input_cn3, class_stand, pbcolony.image_inverted_flag);
// // cv::Mat mask = pbcolony->generateMaskImage(input_cn1.cols, input_cn1.rows, center.x - radius, center.y - radius, 2 * radius, 2 * radius); ColonyStatistic CStatistic = pbcolony.get_colony_statistics(Cinfo);
// // int lower = -1;
// // int upper = -1; cv::imshow("a", input_cn3);
// // Mat bin = pbcolony->get_lower_upper(input_cn1, mask, lower, upper); cv::waitKey(0);
//
// // 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()
// {
//
// // } }
//}

View File

@ -1,66 +1,77 @@
//#pragma once #pragma once
//
//using namespace System; using namespace System;
//using namespace System::Collections::Generic; using namespace System::Collections::Generic;
//using namespace System::Runtime::InteropServices; using namespace System::Runtime::InteropServices;
//
//namespace PBBiologyVC namespace PBBiologyVC{
//{
// public enum dataClassVC public ref struct ColonyInfoVC
// { {
// AREA = 0, //面积 public:
// PERIMETER, //周长 int IDX; //菌落序号
// DIAMETER, //直径 int area; //菌落面积
// IOD, //IOD int perimeter; //菌落周长
// }; float diameter; //菌落直径
// public ref struct ColonyInfoVC int IOD; //菌落IOD
// { int classify; //菌落分类
// int IDX; //菌落序号
// int area; //菌落面积 };
// int perimeter; //菌落周长 public enum dataClassVC
// float diameter; //菌落直径 {
// int IOD; //菌落IOD AREA = 0, //面积
// int classify; //菌落分类 PERIMETER, //周长
// }; DIAMETER, //直径
// public ref struct ClassifyStandardVC IOD, //IOD
// { };
// List<float>^ interval; //分类依据间隔标志数据 public ref struct ClassifyStandardVC
// float maxd; //分类最大间隔标志 {
// float mind; //分类最小间隔标志 List<float>^ interval; //分类依据间隔标志数据
// int num; //分类间隔数 float maxd; //分类最大间隔标志
// dataClassVC classes; //分类类别 float mind; //分类最小间隔标志
// }; int num; //分类间隔数
// public ref struct MinMaxInfoVC dataClassVC classes; //分类类别
// { };
// float mind; //最小值 public ref struct MinMaxInfoVC
// float minIDX; //最小值对应序号 {
// float maxd; //最大值 float mind; //最小值
// float maxIDX; //最大值对应序号 float minIDX; //最小值对应序号
// float range; //范围 float maxd; //最大值
// float mean; //均值 float maxIDX; //最大值对应序号
// float sum; //和 float range; //范围
// int number; //数量 float mean; //均值
// }; float sum; //和
// int number; //数量
// };
// public ref struct ColonyStatisticVC
// {
// MinMaxInfoVC area; //面积统计结果 public ref struct ColonyStatisticVC
// MinMaxInfoVC perimeter; //周长统计结果 {
// MinMaxInfoVC diameter; //直径统计结果 MinMaxInfoVC area; //面积统计结果
// MinMaxInfoVC IOD; //IOD统计结果 MinMaxInfoVC perimeter; //周长统计结果
// MinMaxInfoVC classify; //分类统计结果 MinMaxInfoVC diameter; //直径统计结果
// }; MinMaxInfoVC IOD; //IOD统计结果
// public ref class PBColonyVC MinMaxInfoVC classify; //分类统计结果
// { };
// PBColonyVC(); public ref class PBColonyVC
// {
// ~PBColonyVC(); ~PBColonyVC();
// public:
// 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;
// }; //public ref class PBColonyVC
//} //{
// //PBColonyVC();
// //~PBColonyVC();
//public:
// //void run(System::Byte* image, int bit, unsigned short width, unsigned short height, int lower , int upper );
//private:
// //PBColony* pbcolony;
//};
}

View File

@ -7,7 +7,7 @@ using namespace System::Collections::Generic;
using namespace System::Runtime::InteropServices; using namespace System::Runtime::InteropServices;
namespace PBBiologyVC { namespace PBBiologyVC {
public ref struct Pseudo_infoVC public ref struct Pseudo_infoVC
{ {
public: public: