From 418ce1b81adf4637c885fd07581096a5ad30fc59 Mon Sep 17 00:00:00 2001 From: moco Date: Fri, 3 Jan 2025 22:53:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=8F=8C=E8=90=BD=E8=AE=A1?= =?UTF-8?q?=E6=95=B0=E7=9A=84=E7=AE=97=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/PBAnaly/Module/ColonyMannage.cs | 21 ++++ src/PBBiologyVC/PBColonyVC.cpp | 104 ++++++++++---------- src/PBBiologyVC/PBColonyVC.h | 143 +++++++++++++++------------- src/PBBiologyVC/PBImageProcessVC.h | 2 +- 4 files changed, 151 insertions(+), 119 deletions(-) diff --git a/src/PBAnaly/Module/ColonyMannage.cs b/src/PBAnaly/Module/ColonyMannage.cs index 6507744..c0de18d 100644 --- a/src/PBAnaly/Module/ColonyMannage.cs +++ b/src/PBAnaly/Module/ColonyMannage.cs @@ -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 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 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 diff --git a/src/PBBiologyVC/PBColonyVC.cpp b/src/PBBiologyVC/PBColonyVC.cpp index f60fdf1..aecd0c9 100644 --- a/src/PBBiologyVC/PBColonyVC.cpp +++ b/src/PBBiologyVC/PBColonyVC.cpp @@ -1,53 +1,53 @@ #include "pch.h" -//#include "PBColonyVC.h" -//#include -//#include -// -//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 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 +#include + +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 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() +{ + +} + diff --git a/src/PBBiologyVC/PBColonyVC.h b/src/PBBiologyVC/PBColonyVC.h index 3b5f759..3d51557 100644 --- a/src/PBBiologyVC/PBColonyVC.h +++ b/src/PBBiologyVC/PBColonyVC.h @@ -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^ 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(); -// -// ~PBColonyVC(); -// -// public: -// void run(System::Byte* image, int bit, unsigned short width, unsigned short height, int lower , int upper ); -// -// private: -// //PBColony* pbcolony; -// }; -//} \ No newline at end of file +#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^ 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(); + + //public: + // //void run(System::Byte* image, int bit, unsigned short width, unsigned short height, int lower , int upper ); + + //private: + // //PBColony* pbcolony; + //}; +} \ No newline at end of file diff --git a/src/PBBiologyVC/PBImageProcessVC.h b/src/PBBiologyVC/PBImageProcessVC.h index 1d228ef..d7e5a38 100644 --- a/src/PBBiologyVC/PBImageProcessVC.h +++ b/src/PBBiologyVC/PBImageProcessVC.h @@ -7,7 +7,7 @@ using namespace System::Collections::Generic; using namespace System::Runtime::InteropServices; namespace PBBiologyVC { - + public ref struct Pseudo_infoVC { public: