diff --git a/.gitignore b/.gitignore
index 835d40b..683fe9d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,5 +3,8 @@
*.tif
*.bmp
*.avif
-IRImageProcessing/output/
+opticalFlowProcessing/output/
+opticalFlowProcessing/input/
+opticalFlowProcessing/error/
+opticalFlowProcessing/x64
.vs/
diff --git a/IRImageProcessing.sln b/IRImageProcessing.sln
deleted file mode 100644
index df21926..0000000
--- a/IRImageProcessing.sln
+++ /dev/null
@@ -1,31 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 17
-VisualStudioVersion = 17.8.34525.116
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "IRImageProcessing", "IRImageProcessing\IRImageProcessing.vcxproj", "{D48B5F5F-E967-4A6D-A6FE-EFE946014037}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|x64 = Debug|x64
- Debug|x86 = Debug|x86
- Release|x64 = Release|x64
- Release|x86 = Release|x86
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {D48B5F5F-E967-4A6D-A6FE-EFE946014037}.Debug|x64.ActiveCfg = Debug|x64
- {D48B5F5F-E967-4A6D-A6FE-EFE946014037}.Debug|x64.Build.0 = Debug|x64
- {D48B5F5F-E967-4A6D-A6FE-EFE946014037}.Debug|x86.ActiveCfg = Debug|Win32
- {D48B5F5F-E967-4A6D-A6FE-EFE946014037}.Debug|x86.Build.0 = Debug|Win32
- {D48B5F5F-E967-4A6D-A6FE-EFE946014037}.Release|x64.ActiveCfg = Release|x64
- {D48B5F5F-E967-4A6D-A6FE-EFE946014037}.Release|x64.Build.0 = Release|x64
- {D48B5F5F-E967-4A6D-A6FE-EFE946014037}.Release|x86.ActiveCfg = Release|Win32
- {D48B5F5F-E967-4A6D-A6FE-EFE946014037}.Release|x86.Build.0 = Release|Win32
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
- GlobalSection(ExtensibilityGlobals) = postSolution
- SolutionGuid = {8EE5FA51-A4CB-4678-A0B9-227203EAAF28}
- EndGlobalSection
-EndGlobal
diff --git a/IRImageProcessing/IRImageProcessing.vcxproj b/IRImageProcessing/IRImageProcessing.vcxproj
deleted file mode 100644
index a6163aa..0000000
--- a/IRImageProcessing/IRImageProcessing.vcxproj
+++ /dev/null
@@ -1,136 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Release
- Win32
-
-
- Debug
- x64
-
-
- Release
- x64
-
-
-
- 15.0
- {D48B5F5F-E967-4A6D-A6FE-EFE946014037}
- RemoveArea
- 10.0
-
-
-
- Application
- true
- v143
- MultiByte
-
-
- Application
- false
- v143
- true
- MultiByte
-
-
- Application
- true
- v143
- MultiByte
-
-
- Application
- false
- v143
- true
- MultiByte
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- D:\SDK\opencv-4.0.0\build\install\include;$(IncludePath)
- D:\SDK\opencv-4.0.0\build\install\x64\vc15\lib;$(LibraryPath)
-
-
- D:\SDK\opencv-4.0.0\build\install\include;$(IncludePath)
- D:\SDK\opencv-4.0.0\build\install\x64\vc15\lib;$(LibraryPath)
-
-
-
- Level3
- Disabled
- true
- true
-
-
-
-
- Level3
- Disabled
- true
- true
- stdcpp17
-
-
-
-
- Level3
- MaxSpeed
- true
- true
- true
- true
-
-
- true
- true
-
-
-
-
- Level3
- MaxSpeed
- true
- true
- true
- true
- stdcpp17
-
-
- true
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/IRImageProcessing/Source.cpp b/IRImageProcessing/Source.cpp
deleted file mode 100644
index 1e20275..0000000
--- a/IRImageProcessing/Source.cpp
+++ /dev/null
@@ -1,396 +0,0 @@
-#include "myOpenCV3.h"
-#include
-#include
-#include
-#include
-#include
-#include
-
-void thinningIteration(cv::Mat& img, int iteration) {
- cv::Mat marker = cv::Mat::ones(img.size(), CV_8UC1);
-
- for (int y = 1; y < img.rows - 1; ++y) {
- for (int x = 1; x < img.cols - 1; ++x) {
- uchar p2 = img.at(y - 1, x);
- uchar p3 = img.at(y - 1, x + 1);
- uchar p4 = img.at(y, x + 1);
- uchar p5 = img.at(y + 1, x + 1);
- uchar p6 = img.at(y + 1, x);
- uchar p7 = img.at(y + 1, x - 1);
- uchar p8 = img.at(y, x - 1);
- uchar p9 = img.at(y - 1, x - 1);
-
- int C = (!p2 & (p3 | p4)) + (!p4 & (p5 | p6)) +
- (!p6 & (p7 | p8)) + (!p8 & (p9 | p2));
- int N1 = (p9 | p2) + (p3 | p4) + (p5 | p6) + (p7 | p8);
- int N2 = (p2 | p3) + (p4 | p5) + (p6 | p7) + (p8 | p9);
- int N = N1 < 3 ? N1 : N2;
- int m = iteration == 0 ? ((p6 | p7 | (!p9)) & p8) : ((p2 | p3 | (!p5)) & p4);
-
- if (C == 1 && (N >= 2 && N <= 3) & m == 0)
- marker.at(y, x) = 0;
- }
- }
- img &= marker;
-}
-
-void thinning(const cv::Mat& src, cv::Mat& dst) {
- dst = src.clone();
- dst /= 255;
- // ���K��
- cv::Mat normalizedImage;
- cv::normalize(src, normalizedImage, 0, 1, cv::NORM_MINMAX, CV_32F);
- cv::Mat prev = cv::Mat::zeros(dst.size(), CV_8UC1);
- cv::Mat diff;
-
- do {
- thinningIteration(dst, 0);
- thinningIteration(dst, 1);
- cv::absdiff(dst, prev, diff);
- dst.copyTo(prev);
- } while (cv::countNonZero(diff) > 0);
- dst *= 255;
-}
-
-std::vector findBranchPoints(cv::Mat& img)
-{
- std::vector branchPoints;
-
- for (int y = 1; y < img.rows - 1; ++y)
- {
- for (int x = 1; x < img.cols - 1; ++x)
- {
- // �摜�����i�܂��͍��j�łȂ��ꍇ�͖���
- if (img.at(y, x) == 255) continue;
-
- // 8�ߖT�̔��i�܂��͍��j�s�N�Z���̐����J�E���g
- int count = 0;
- if (img.at(y - 1, x - 1) > 0) ++count;
- if (img.at(y - 1, x) > 0) ++count;
- if (img.at(y - 1, x + 1) > 0) ++count;
- if (img.at(y, x - 1) > 0) ++count;
- if (img.at(y, x + 1) > 0) ++count;
- if (img.at(y + 1, x - 1) > 0) ++count;
- if (img.at(y + 1, x) > 0) ++count;
- if (img.at(y + 1, x + 1) > 0) ++count;
-
- // ���i�܂��͍��j�s�N�Z����3�ȏ゠��ꍇ�͕���_�Ƃ��ċL�^
- if (count >= 3)
- branchPoints.push_back(cv::Point(x, y));
- }
- }
-
- return branchPoints;
-}
-
-std::vector extractBifurcationPoints(cv::Mat& thinnedImage) {
- int rows = thinnedImage.rows;
- int cols = thinnedImage.cols;
- int neighbor[2][8] = { {-1, -1, 0, 1, 1, 1, 0, -1}, {0, 1, 1, 1, 0, -1, -1, -1} };
- std::vector bifurcationPoints;
-
- for (int i = 1; i < rows - 1; i++) {
- for (int j = 1; j < cols - 1; j++) {
- if (thinnedImage.at(i, j) == 255) {
- int transitions = 0;
- int neighborCount = 0;
-
- for (int k = 0; k < 8; k++) {
- int x = i + neighbor[0][k];
- int y = j + neighbor[1][k];
-
- //int nextX = i + neighbor[0][(k + 1) % 8];
- //int nextY = j + neighbor[1][(k + 1) % 8];
-
- if (thinnedImage.at(x, y) == 255) {
- neighborCount++;
-
- //if (thinnedImage.at(nextX, nextY) == 0)
- // transitions++;
- }
- }
-
- if (neighborCount >= 3)
- bifurcationPoints.push_back(cv::Point(j, i)); // OpenCV�ł́Ax���W����ԍ��Ay���W���s�ԍ��ɑΉ����܂��B
- }
- }
- }
-
- return bifurcationPoints;
-}
-
-cv::Mat removeSmallAreaImage(const cv::Mat& src, const double areaThreshold)
-{
- cv::Mat dst;
- dst = src.clone();
- std::vector> contours;
- cv::findContours(src, contours, cv::RETR_EXTERNAL, cv::CHAIN_APPROX_SIMPLE);
- std::ofstream outFile("area.txt");
- // �ʐς�臒l�ȉ��̗֊s���폜
- for (int i = 0; i < contours.size(); i++) {
- double area = cv::contourArea(contours[i]);
- outFile << i << ": = " << area < branchPoints = extractBifurcationPoints(thinnedImage); // ����_�����o
-
- // ����_�ɉ~��`��
- for (const auto& point : branchPoints) {
- cv::circle(circleImageRGB, point, 10, cv::Scalar(0, 0, 255), 2); // ���a3�̉~��ԐF�ŕ`�悵�܂�
- }
-
- cv::imwrite(dirName + "/Circle.png", circleImageRGB);
-
-}
-
-void WindowProcessing(const cv::Mat& src16U, cv::Mat& dst8U, double limit, std::string dirName)
-{
-
- double amin, amax;
- cv::minMaxLoc(src16U, &amin, &amax);
-
- // �X�P�[�����O�W�����v�Z
- double scale = limit / (amax - amin);
-
- src16U.convertTo(dst8U, CV_8U, scale, -amin * scale);
- //cv::imwrite(dirName + "/Windowed_2.png", dst8U);
-}
-
-void GaborProcessing(const cv::Mat& ori, cv::Mat& src, std::string dirName)
-{
-
- int division = 16;
- int ksize = 51;
- double sigma = 18;
- double theta;
- double lambda = 42;
- double gamma = 1;
- double psi = 0;
- double angle = 0;
-
- cv::Mat maxGaborImage;
- double maxGaborSum = -1.0;
- int maxAngle = -1;
- cv::Mat src64F;
- src.convertTo(src64F, CV_64F);
- cv::Mat margeImage = cv::Mat::zeros(src64F.size(), CV_64F);
- cv::Mat margeNormImage;
-
- // Find the angle that gives the maximum sum of gaborImage8U
- for (int i = 0; i < division; i++, angle += (180 / division))
- {
- theta = angle * CV_PI / 180.0;
- // opencv��gabor filter
- cv::Mat kern = cv::getGaborKernel(cv::Size(ksize, ksize), sigma, theta, lambda, gamma, psi, CV_64F);
- kern /= cv::sum(kern)[0];
-
- cv::Mat gaborImage, gaborBinaryImage;
- cv::filter2D(src64F, gaborImage, CV_64F, kern);
-
- //�摜�̌^�ϊ��Ɛ��K��
- double gaborMinVal, gaborMaxVal;
- cv::minMaxLoc(gaborImage, &gaborMinVal, &gaborMaxVal); // gaborImage�̍ŏ��l�ƍő�l���擾
- margeImage = maximumImage(gaborImage, margeImage);
-
- // �^�ϊ�
-
- // �J�[�l���̒l��0����255�͈̔͂ɐ��K��
- double kernMinVal, kernMaxVal;
- cv::minMaxLoc(kern, &kernMinVal, &kernMaxVal); // �ŏ��l�ƍő�l���擾
- kern = 255 * (kern - kernMinVal) / (kernMaxVal - kernMinVal);
-
- // CV_64F����CV_8U�ɕϊ�
- cv::Mat kern8U;
- kern.convertTo(kern8U, CV_8U);
-
- cv::Mat gaborImageScaled, diffImage;
-
- // �����摜
- cv::convertScaleAbs(diffImage, gaborImageScaled, 1.0 / division);
-
- std::string fileStr = std::to_string(i) + "_over_" + std::to_string(division) + "pi";
-
- std::cout << fileStr << ":min = " << gaborMinVal << " :max = " << gaborMaxVal << std::endl;
- // �摜�̕ۑ�
- cv::imwrite(dirName + "/Gabor_" + fileStr + ".png", gaborImage);
- //cv::imwrite(dirName + "/GaborNorm_" + fileStr + ".png", gaborNormImage);
- //cv::imwrite(dirName + "/diff_" + fileStr + ".png", diffImage);
- //cv::imwrite(dirName + "/GaborOtsuBinaryImage_" + fileStr + ".png", gaborBinaryImage);
-
- // �J�[�l�����摜�t�@�C���Ƃ��ĕۑ�
- cv::imwrite(dirName + "/Kernel_" + fileStr + ".png", kern);
-
- // �摜�̍���
- //cv::add(margeImage, gaborImageScaled, margeImage, cv::noArray(), CV_8U);
-
- }
-
- double margeMinVal, margeMaxVal;
- cv::minMaxLoc(margeImage, &margeMinVal, &margeMaxVal); // �ŏ��l�ƍő�l���擾
- cv::normalize(margeImage, margeNormImage, 0, 255, cv::NORM_MINMAX, CV_8U);
-
- //cv::imwrite(dirName + "/MargeOtsuBinaryImage.png", margeOtsuBinaryImage);
- //cv::imwrite(dirName + "/RemovedSmallAreaMargeOtsuBinaryImage_" + std::to_string((int)areaThreshold) + ".png", removedMargeOtsuBinaryImage);
- cv::imwrite(dirName + "/Marge.png", margeImage);
- cv::imwrite(dirName + "/MargeNorm.png", margeNormImage);
- BinaryProcessing(ori, margeNormImage, dirName);
-
-}
-
-
-
-
-
-int main() {
- std::string inputFileName = "trimmed.tif";
-
- // �o�͏���
- std::string baseDir = "result_output/";
- std::string dirBaseName = "th50_border30_kernel5_ite2_area1000";
- std::string dirName = baseDir + dirBaseName;
-
-
- // output�f�B���N�g�������݂��Ȃ��ꍇ�͍쐬
- if
- (!std::filesystem::exists(baseDir)) {
- std::filesystem::create_directory(baseDir);
- }
-
- int dirCount = 2;
- // �w�肳�ꂽ�f�B���N�g�������݂���ꍇ�́A�V�������O��
- while (std::filesystem::exists(dirName)) {
- dirName = baseDir + dirBaseName + std::to_string(dirCount);
- ++dirCount;
- }
-
- std::filesystem::create_directory(dirName);
-
- cv::Mat image = cv::imread(inputFileName, cv::IMREAD_ANYDEPTH);
-
- // �K������
- cv::Mat windowedImage;
- WindowProcessing(image, windowedImage, 255.0, dirName);
-
-
-
- // CLAHE��p�����q�X�g�O�������R��
- cv::Ptr clahe = cv::createCLAHE(10.0, cv::Size(16, 16));
- cv::Mat claheImage;
- clahe->apply(windowedImage, claheImage);
-
- // �R���g���X�g����
- cv::Mat claheOtsuBinaryImage;
- cv::threshold(claheImage, claheOtsuBinaryImage, 128, 255, cv::THRESH_BINARY);
-
- //BinaryProcessing(windowedImage, claheImage, dirName);
- // �m�C�Y����
- cv::Mat gaussianBlurImage;
- cv::GaussianBlur(claheImage, gaussianBlurImage, cv::Size(19, 19), 9, 0);
-
- cv::Mat inversedClaheImage;
- inversedClaheImage = inverseImage(gaussianBlurImage);
-
- // �K�{�[���t�B���^
- GaborProcessing(windowedImage, inversedClaheImage, dirName);
-
-
-
- cv::imwrite(dirName + "/Original.tif", image);
- cv::imwrite(dirName + "/WindowedImage.png", windowedImage);
- cv::imwrite(dirName + "/CLAHEGaussian.png", gaussianBlurImage);
- cv::imwrite(dirName + "/CLAHE.png", claheImage);
- cv::imwrite(dirName + "/CLAHEGaussianInversion.png", inversedClaheImage);
- cv::imwrite(dirName + "/CLAHEOtsu.png", claheOtsuBinaryImage);
-
- return 0;
-}
-
diff --git a/IRImageProcessing/myOpenCV3.h b/IRImageProcessing/myOpenCV3.h
deleted file mode 100644
index 60ad8df..0000000
--- a/IRImageProcessing/myOpenCV3.h
+++ /dev/null
@@ -1,76 +0,0 @@
-
-// OpenCV 3�n ���ʃw�b�_�[�t�@�C��
-// T.Nakaguchi
-
-// �w�b�_�[�t�@�C��
-#pragma warning(disable: 4819)
-#include
-#pragma warning(default: 4819)
-
-// �o�[�W�����擾
-#define CV_VERSION_STR CVAUX_STR(CV_MAJOR_VERSION) CVAUX_STR(CV_MINOR_VERSION) CVAUX_STR(CV_SUBMINOR_VERSION)
-
-// �r���h���[�h
-#ifdef _DEBUG
-#define CV_EXT_STR "d.lib"
-#else
-#define CV_EXT_STR ".lib"
-#endif
-
-// ���C�u�����̃����N�i�s�v�ȕ��̓R�����g�A�E�g�j
-#define PRE_COMPILE 0 // �C���X�g�[���łȂ� 1 �ʃ��C�u�����g�p���� 0
-#define PREHEAD "opencv_"
-
-#if PRE_COMPILE
-// OpenCV3.0 �C���X�g�[����
-#pragma comment(lib, PREHEAD "world" CV_VERSION_STR CV_EXT_STR) // �S��
-#pragma comment(lib, PREHEAD "ts" CV_VERSION_STR CV_EXT_STR) // �f���֘A
-
-#else
-// �ʂ̃��C�u�����w�� �iCmake��Static�Ŏg�p���Ȃǁj
-// ��{���W���[��
-#pragma comment(lib, PREHEAD "core" CV_VERSION_STR CV_EXT_STR) // ��{�@�\
-#pragma comment(lib, PREHEAD "imgproc" CV_VERSION_STR CV_EXT_STR) // �摜����
-#pragma comment(lib, PREHEAD "imgcodecs" CV_VERSION_STR CV_EXT_STR) // �摜�t�@�C�����o��
-#pragma comment(lib, PREHEAD "videoio" CV_VERSION_STR CV_EXT_STR) // ����t�@�C�����o��
-#pragma comment(lib, PREHEAD "highgui" CV_VERSION_STR CV_EXT_STR) // ���@�\GUI
-#pragma comment(lib, PREHEAD "video" CV_VERSION_STR CV_EXT_STR) // ���摜���
-#pragma comment(lib, PREHEAD "calib3d" CV_VERSION_STR CV_EXT_STR) // �J�����Z���ƎO�����č\�z
-#pragma comment(lib, PREHEAD "features2d" CV_VERSION_STR CV_EXT_STR) // �摜�������
-#pragma comment(lib, PREHEAD "objdetect" CV_VERSION_STR CV_EXT_STR) // ���̌��o
-#pragma comment(lib, PREHEAD "ml" CV_VERSION_STR CV_EXT_STR) // �@�B�w�K
-#pragma comment(lib, PREHEAD "flann" CV_VERSION_STR CV_EXT_STR) // �������N���X�^�����O�ƌ���
-#pragma comment(lib, PREHEAD "photo" CV_VERSION_STR CV_EXT_STR) // �v�Z�@�ʐ^
-#pragma comment(lib, PREHEAD "stitching" CV_VERSION_STR CV_EXT_STR) // �摜�ڑ�
-//#pragma comment(lib, PREHEAD "hal" CV_VERSION_STR CV_EXT_STR) // �n�[�h�E�F�A������
-#pragma comment(lib, PREHEAD "shape" CV_VERSION_STR CV_EXT_STR) // �`���v���o
-#pragma comment(lib, PREHEAD "superres" CV_VERSION_STR CV_EXT_STR) // ����
-#pragma comment(lib, PREHEAD "videostab" CV_VERSION_STR CV_EXT_STR) // ���摜���艻
-//#pragma comment(lib, PREHEAD "vis" CV_VERSION_STR CV_EXT_STR) // 3��������
-
-// �g�����W���[��
-//#pragma comment(lib, PREHEAD "adas" CV_VERSION_STR CV_EXT_STR) // ��i�I�f�o�C�X�T�|�[�g
-//#pragma comment(lib, PREHEAD "aruco" CV_VERSION_STR CV_EXT_STR) // AR�p�}�[�J�[
-#pragma comment(lib, PREHEAD "bgsegm" CV_VERSION_STR CV_EXT_STR) // ���nj^�w�i�E�O�i����
-#pragma comment(lib, PREHEAD "bioinspired" CV_VERSION_STR CV_EXT_STR) // ���̂Ɋ�Â����o�I����
-#pragma comment(lib, PREHEAD "ccalib" CV_VERSION_STR CV_EXT_STR) // �J�X�^���p�^�[���ɂ��J�����Z���ƎO�����č\��
-//#pragma comment(lib, PREHEAD "cvv" CV_VERSION_STR CV_EXT_STR) // �Θb�I���o�I�f�o�b�OGUI
-#pragma comment(lib, PREHEAD "datasets" CV_VERSION_STR CV_EXT_STR) // ����f�[�^�Z�b�g��舵���t���[�����[�N
-#pragma comment(lib, PREHEAD "face" CV_VERSION_STR CV_EXT_STR) // ��F��
-//#pragma comment(lib, PREHEAD "latentsvm" CV_VERSION_STR CV_EXT_STR) // Latent-SVM
-#pragma comment(lib, PREHEAD "line_descriptor" CV_VERSION_STR CV_EXT_STR) // �����o�̃o�C�i���\��
-//#pragma comment(lib, PREHEAD "matlab" CV_VERSION_STR CV_EXT_STR) // MATLAB�u���b�W
-#pragma comment(lib, PREHEAD "optflow" CV_VERSION_STR CV_EXT_STR) // �I�v�e�B�J���t���[
-#pragma comment(lib, PREHEAD "reg" CV_VERSION_STR CV_EXT_STR) // �摜�ʒu���킹
-#pragma comment(lib, PREHEAD "rgbd" CV_VERSION_STR CV_EXT_STR) // RGB-�[�x�J����
-#pragma comment(lib, PREHEAD "saliency" CV_VERSION_STR CV_EXT_STR) // �摜 ������ API
-#pragma comment(lib, PREHEAD "surface_matching" CV_VERSION_STR CV_EXT_STR) // �\�ʃ��f����v���o
-#pragma comment(lib, PREHEAD "text" CV_VERSION_STR CV_EXT_STR) // �V�[���������o�ƔF��
-#pragma comment(lib, PREHEAD "tracking" CV_VERSION_STR CV_EXT_STR) // �ǐ�
-#pragma comment(lib, PREHEAD "xfeatures2d" CV_VERSION_STR CV_EXT_STR) // �g���� �摜�������
-#pragma comment(lib, PREHEAD "ximgproc" CV_VERSION_STR CV_EXT_STR) // �g���� �摜����
-#pragma comment(lib, PREHEAD "xobjdetect" CV_VERSION_STR CV_EXT_STR) // �g���� ���̌��o
-#pragma comment(lib, PREHEAD "xphoto" CV_VERSION_STR CV_EXT_STR) // �g���� �v�Z�@�ʐ^
-#endif
-
-using namespace cv;
diff --git a/IRImageProcessing/source.h b/IRImageProcessing/source.h
deleted file mode 100644
index 782b2dd..0000000
--- a/IRImageProcessing/source.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#pragma
-
-
-Mat src_img;
-Mat change;
-
-Point Cancer_centroid_point;
-Rect cancer_roi;
\ No newline at end of file
diff --git a/opticalFlowProcessing.sln b/opticalFlowProcessing.sln
new file mode 100644
index 0000000..13463fa
--- /dev/null
+++ b/opticalFlowProcessing.sln
@@ -0,0 +1,31 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.8.34525.116
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opticalFlowProcessing", "opticalFlowProcessing\opticalFlowProcessing.vcxproj", "{D48B5F5F-E967-4A6D-A6FE-EFE946014037}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {D48B5F5F-E967-4A6D-A6FE-EFE946014037}.Debug|x64.ActiveCfg = Debug|x64
+ {D48B5F5F-E967-4A6D-A6FE-EFE946014037}.Debug|x64.Build.0 = Debug|x64
+ {D48B5F5F-E967-4A6D-A6FE-EFE946014037}.Debug|x86.ActiveCfg = Debug|Win32
+ {D48B5F5F-E967-4A6D-A6FE-EFE946014037}.Debug|x86.Build.0 = Debug|Win32
+ {D48B5F5F-E967-4A6D-A6FE-EFE946014037}.Release|x64.ActiveCfg = Release|x64
+ {D48B5F5F-E967-4A6D-A6FE-EFE946014037}.Release|x64.Build.0 = Release|x64
+ {D48B5F5F-E967-4A6D-A6FE-EFE946014037}.Release|x86.ActiveCfg = Release|Win32
+ {D48B5F5F-E967-4A6D-A6FE-EFE946014037}.Release|x86.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {8EE5FA51-A4CB-4678-A0B9-227203EAAF28}
+ EndGlobalSection
+EndGlobal
diff --git a/opticalFlowProcessing/ImageProcessor.cpp b/opticalFlowProcessing/ImageProcessor.cpp
new file mode 100644
index 0000000..44b48f5
--- /dev/null
+++ b/opticalFlowProcessing/ImageProcessor.cpp
@@ -0,0 +1,521 @@
+#include "ImageProcessor.h"
+
+void ImageProcessor::inputProcess(const cv::Mat& inputImage)
+{
+ m_originalImage = inputImage.clone();
+}
+
+void ImageProcessor::applyCLAHEProcess()
+{
+ auto c_start = std::chrono::high_resolution_clock::now();
+
+ // �O���[�X�P�[���ɕϊ�
+ cv::Mat grayOriginalImage;
+ cv::cvtColor(m_originalImage, grayOriginalImage, cv::COLOR_BGR2GRAY);
+
+
+ // ��Â̓�l���ɂ��}�X�N�쐬
+ cv::Mat mask;
+ cv::threshold(grayOriginalImage, mask, 0, 255, cv::THRESH_BINARY | cv::THRESH_OTSU);
+ // �֊s�����o
+ std::vector> contours;
+ std::vector hierarchy;
+ findContours(mask, contours, hierarchy, RETR_EXTERNAL, CHAIN_APPROX_SIMPLE);
+
+ // �����ϊ����g���ė֊s����̋������v�Z
+ cv::Mat distanceMap;
+ distanceTransform(mask, distanceMap, DIST_L2, 3);
+ m_distanceMap = distanceMap.clone();
+ m_maskAreaImage = mask.clone();
+ // �}�X�N������
+ cv::GaussianBlur(mask, mask, cv::Size(5, 5), 0.4);
+
+ //mask = gray.clone();
+
+ // �}�X�N��K�p���āA�Ώۗ̈�݂̂�����
+ cv::Mat maskedOriginalImage;
+ grayOriginalImage.copyTo(maskedOriginalImage, mask);
+ m_maskOriginalImage = maskedOriginalImage.clone();
+ // CLAHE
+ cv::Ptr clahe = cv::createCLAHE(m_CLAHEClipLimit, cv::Size(m_CLAHETileSize, m_CLAHETileSize));
+ //cv::Ptr clahe_2 = cv::createCLAHE(m_CLAHEClipLimit, cv::Size(m_CLAHETileSize + 3, m_CLAHETileSize + 3));
+
+ cv::Mat clahe_Image;
+ //clahe->apply(maskedOriginalImage, clahe_Image);
+ clahe->apply(grayOriginalImage, clahe_Image);
+ std::cout << "CLAHE Parameter : " << m_CLAHETileSize << std::endl;
+
+ cv::Mat maskedCLAHEImage;
+ //clahe_Image.copyTo(maskedCLAHEImage, mask);
+ m_claheImage = clahe_Image.clone();
+
+ // �������Ԃ̌v���I��
+ auto c_end = std::chrono::high_resolution_clock::now();
+ std::chrono::duration CLAHEProcessingTime = c_end - c_start;
+ std::cout << "CLAHE Processing time: " << CLAHEProcessingTime.count() << " seconds." << std::endl;
+}
+
+
+void ImageProcessor::applyGaborProcess()
+{
+ applyCLAHEProcess();
+
+ // �m�C�Y����
+ cv::Mat gaussianBlurImage;
+
+ cv::GaussianBlur(m_claheImage, gaussianBlurImage, cv::Size(0, 0), 1.0);
+ /*cv::Mat maskedCLAHEImage;
+ m_claheImage.copyTo(maskedCLAHEImage, m_maskAreaImage);
+ m_claheImage = maskedCLAHEImage.clone();*/
+
+ // ���]����
+ cv::Mat inversedClaheImage = inverseImage(gaussianBlurImage);
+ //cv::Mat inversedClaheImage = inverseImage(m_claheImage);
+
+
+ // Gabor�t�B���^
+ int division = 8;
+ int ksize = 49;
+ double sigma = 22.4;
+ double lambda = 32.4;
+ double gamma = 1;
+ double psi = 0;
+ double angle = 0;
+
+ cv::Mat src32F;
+ inversedClaheImage.convertTo(src32F, CV_32F);
+ cv::Mat margeImage;
+ cv::Mat marge8UImage;
+
+ // �p�x�X�e�b�v�̌v�Z
+ double angle_step = 180.0 / division;
+
+ for (int i = 0; i < division; i++) {
+ double angle = i * angle_step;
+ double theta = angle * CV_PI / 180.0;
+ cv::Mat kernel = cv::getGaborKernel(cv::Size(ksize, ksize), sigma, theta, lambda, gamma, CV_32F);
+
+ cv::Mat gaborImage;
+ cv::filter2D(inversedClaheImage, gaborImage, CV_32F, kernel);
+
+ // �}�X�N��K�p���ăK�{�[���t�B���^���}�[�W����
+ cv::Mat gaborMasked;
+
+ cv::Mat gaborClippedImage;
+ gaborClippedImage = gaborImage.clone();
+ double min_val, max_val;
+
+ cv::minMaxLoc(gaborImage, &min_val, &max_val);
+ double positive_cutoff = max_val * (0 / 100.0);
+ std::cout << min_val << "," << max_val << std::endl;
+ // �K�{�[���摜
+ /*for (int i = 0; i < gaborImage.rows; ++i) {
+ for (int j = 0; j < gaborImage.cols; ++j) {
+ float pixel_value = gaborImage.at(i, j);
+ if (pixel_value >= positive_cutoff) {
+ gaborClippedImage.at(i, j) = pixel_value - positive_cutoff;
+ }
+ else {
+ gaborClippedImage.at(i, j) = 0.0f;
+ }
+ }
+ }*/
+ // Clipped�摜�͈̔͂��Ċm�F
+ cv::minMaxLoc(gaborImage, &min_val, &max_val);
+ std::cout << "Clipped filtered image range: min = " << min_val << ", max = " << max_val << std::endl;
+ //gaborImage.copyTo(gaborMasked, m_maskAreaImage);
+
+ //margeImage = maximumImage(gaborImage, margeImage);
+ if (margeImage.empty())
+ {
+ margeImage = gaborClippedImage.clone();
+ }
+ else
+ {
+ margeImage = maximumImage(gaborClippedImage, margeImage);
+ }
+ }
+
+ double margeMinVal, margeMaxVal;
+ cv::minMaxLoc(margeImage, &margeMinVal, &margeMaxVal);
+ cv::normalize(margeImage, marge8UImage, 0, 255, cv::NORM_MINMAX, CV_8U);
+ //margeImage.convertTo(marge8UImage, CV_8U);
+
+ m_gaborImage = marge8UImage.clone();
+
+}
+
+
+
+void ImageProcessor::applyAllProcess()
+{
+ applyGaborProcess();
+
+ // ��l��
+ cv::Mat binaryImage;
+ cv::threshold(m_gaborImage, binaryImage, 0, 255, cv::THRESH_BINARY);
+ m_binaryImage = binaryImage.clone();
+
+
+ // ���̈�폜
+ cv::Mat removedMargeBinaryImage;
+ double areaThreshold = 100.0;
+ removedMargeBinaryImage = binaryImage.clone();
+ removeSmallArea(binaryImage, removedMargeBinaryImage, areaThreshold);
+ m_smallRegionRemovedImage = removedMargeBinaryImage.clone();
+
+ // �א���
+ cv::Mat thinnedImage;
+ thinning(removedMargeBinaryImage, thinnedImage);
+
+ cv::Mat dilatedthinnedImage;
+ cv::Mat dilatedthinnedImageRGB;
+ // �א��������摜������i�c�������j
+ int dilation_size = 5; // �c������s�N�Z����
+ cv::Mat element = cv::getStructuringElement(cv::MORPH_RECT,
+ cv::Size(2 * dilation_size + 1, 2 * dilation_size + 1),
+ cv::Point(dilation_size, dilation_size));
+ cv::dilate(thinnedImage, dilatedthinnedImage, element);
+
+ m_thinnedImage = thinnedImage.clone();
+
+ // ����_�T��
+ int borderSize = 3;
+ int minDistance = 15;
+ std::vector branchPoints = extractBifurcationPoints(thinnedImage, m_distanceMap, borderSize, minDistance);
+ //std::vector branchPoints = extractDistanceMapBifurcationPoints(thinnedImage, m_distanceMap, borderSize, minDistance);
+ m_branchPoints = branchPoints;
+
+ // ���摜�ɉ~������
+
+ cv::cvtColor(dilatedthinnedImage, dilatedthinnedImageRGB, cv::COLOR_GRAY2BGR);
+ cv::Mat circleImageRGB = m_originalImage.clone();
+ for (const auto& point : branchPoints) {
+ cv::circle(circleImageRGB, point, 0, cv::Scalar(223, 161, 0), 5);
+ }
+
+ m_circleImage = circleImageRGB.clone();
+}
+
+void ImageProcessor::setCLAHETile(int CLAHETileSize)
+{
+ m_CLAHETileSize = CLAHETileSize;
+}
+
+void ImageProcessor::setCLAHEClipLimit(double CLAHEClipLimit)
+{
+ m_CLAHEClipLimit = CLAHEClipLimit;
+}
+
+
+cv::Mat ImageProcessor::getOriginalImage() const
+{
+ return m_originalImage;
+}
+
+cv::Mat ImageProcessor::getCLAHEImage() const
+{
+ return m_claheImage;
+}
+
+cv::Mat ImageProcessor::getGaborImage() const
+{
+ return m_gaborImage;
+}
+
+cv::Mat ImageProcessor::getBinaryImage() const
+{
+ return m_binaryImage;
+}
+
+cv::Mat ImageProcessor::getSmallRegionRemovedImage() const
+{
+ return m_smallRegionRemovedImage;
+}
+
+cv::Mat ImageProcessor::getThinnedImage() const
+{
+ return m_thinnedImage;
+}
+
+cv::Mat ImageProcessor::getCircleImage() const
+{
+ return m_circleImage;
+}
+
+std::vector ImageProcessor::getBranchPoints() const
+{
+ return m_branchPoints;
+}
+
+
+void ImageProcessor::removeSmallArea(const cv::Mat& src, cv::Mat& dst, double areaThreshold)
+{
+ dst = src.clone();
+ std::vector> contours;
+ cv::findContours(src, contours, cv::RETR_EXTERNAL, cv::CHAIN_APPROX_SIMPLE);
+
+ // �֊s�����o����Ȃ������ꍇ�̗�O����
+ if (contours.empty()) {
+ std::cerr << "No contours found in the image." << std::endl;
+ return; // �֊s���Ȃ��ꍇ�͏������I��
+ }
+
+ // �ʐς�臒l�ȉ��̗֊s���폜
+ for (size_t i = 0; i < contours.size(); i++) {
+ double area = cv::contourArea(contours[i]);
+ if (area <= areaThreshold) {
+ cv::drawContours(dst, contours, i, cv::Scalar(0), cv::FILLED);
+ }
+ }
+}
+
+
+
+void ImageProcessor::thinning(const cv::Mat& binaryImage, cv::Mat& thinnedImage)
+{
+ thinnedImage = binaryImage.clone();
+ thinnedImage /= 255;
+ // ���K��
+ cv::Mat prev = cv::Mat::zeros(thinnedImage.size(), CV_8UC1);
+ cv::Mat diff;
+
+ do {
+ thinningIteration(thinnedImage, 0);
+ thinningIteration(thinnedImage, 1);
+ cv::absdiff(thinnedImage, prev, diff);
+ thinnedImage.copyTo(prev);
+ } while (cv::countNonZero(diff) > 0);
+ thinnedImage *= 255;
+}
+
+void ImageProcessor::thinningIteration(cv::Mat& smallRegionRemovedImage, int iteration)
+{
+ cv::Mat marker = cv::Mat::ones(smallRegionRemovedImage.size(), CV_8UC1);
+
+ for (int y = 1; y < smallRegionRemovedImage.rows - 1; ++y) {
+ for (int x = 1; x < smallRegionRemovedImage.cols - 1; ++x) {
+ uchar p2 = smallRegionRemovedImage.at(y - 1, x);
+ uchar p3 = smallRegionRemovedImage.at(y - 1, x + 1);
+ uchar p4 = smallRegionRemovedImage.at(y, x + 1);
+ uchar p5 = smallRegionRemovedImage.at(y + 1, x + 1);
+ uchar p6 = smallRegionRemovedImage.at(y + 1, x);
+ uchar p7 = smallRegionRemovedImage.at(y + 1, x - 1);
+ uchar p8 = smallRegionRemovedImage.at(y, x - 1);
+ uchar p9 = smallRegionRemovedImage.at(y - 1, x - 1);
+
+ int C = (!p2 & (p3 | p4)) + (!p4 & (p5 | p6)) +
+ (!p6 & (p7 | p8)) + (!p8 & (p9 | p2));
+ int N1 = (p9 | p2) + (p3 | p4) + (p5 | p6) + (p7 | p8);
+ int N2 = (p2 | p3) + (p4 | p5) + (p6 | p7) + (p8 | p9);
+ int N = N1 < 3 ? N1 : N2;
+ int m = iteration == 0 ? ((p6 | p7 | (!p9)) & p8) : ((p2 | p3 | (!p5)) & p4);
+
+ if (C == 1 && (N >= 2 && N <= 3) & m == 0)
+ marker.at(y, x) = 0;
+ }
+ }
+ smallRegionRemovedImage &= marker;
+}
+
+std::vector ImageProcessor::extractBifurcationPoints(const cv::Mat& thinnedImage, const cv::Mat& distanceMap, int borderSize, float minDistance)
+{
+ int rows = thinnedImage.rows;
+ int cols = thinnedImage.cols;
+ int neighbor[2][8] = { {-1, -1, 0, 1, 1, 1, 0, -1}, {0, 1, 1, 1, 0, -1, -1, -1} };
+ std::vector branchPoints;
+
+ for (int i = borderSize; i < rows - borderSize; i++) {
+ for (int j = borderSize; j < cols - borderSize; j++) {
+ // �w�肳�ꂽ�ŏ������ȏォ�ǂ������m�F
+ if (distanceMap.at(i, j) < minDistance)
+ continue; // �������������ꍇ�̓X�L�b�v
+
+ if (thinnedImage.at(i, j) == 255) {
+ int neighborCount = 0;
+
+ for (int k = 0; k < 8; k++) {
+ int x = i + neighbor[0][k];
+ int y = j + neighbor[1][k];
+
+ if (thinnedImage.at(x, y) == 255) {
+ neighborCount++;
+ }
+ }
+
+ if (neighborCount >= 3)
+ branchPoints.push_back(cv::Point(j, i));
+ }
+ }
+ }
+
+ return branchPoints;
+}
+
+std::vector ImageProcessor::extractStrictBifurcationPoints(const cv::Mat& thinnedImage, int borderSize)
+{
+ int rows = thinnedImage.rows;
+ int cols = thinnedImage.cols;
+ int neighbor[2][8] = { {-1, -1, 0, 1, 1, 1, 0, -1}, {0, 1, 1, 1, 0, -1, -1, -1} };
+ std::vector branchPoints;
+
+ for (int i = borderSize; i < rows - borderSize; i++) {
+ for (int j = borderSize; j < cols - borderSize; j++) {
+
+ if (thinnedImage.at(i, j) == 255) {
+ int neighborCount = 0;
+ int connectivity = 0;
+
+ // Check the number of white pixels in the 8-neighborhood
+ for (int k = 0; k < 8; k++) {
+ int x = i + neighbor[0][k];
+ int y = j + neighbor[1][k];
+ if (thinnedImage.at(x, y) == 255) {
+ neighborCount++;
+ }
+ }
+
+ // Check the connectivity of the white pixels
+ for (int k = 0; k < 8; k++) {
+ int x1 = i + neighbor[0][k];
+ int y1 = j + neighbor[1][k];
+ int x2 = i + neighbor[0][(k + 1) % 8];
+ int y2 = j + neighbor[1][(k + 1) % 8];
+ if (thinnedImage.at(x1, y1) == 255 && thinnedImage.at(x2, y2) == 255) {
+ connectivity++;
+ }
+ }
+
+ // More strict condition for bifurcation point
+ if (neighborCount >= 3 && connectivity >= 3) {
+ branchPoints.push_back(cv::Point(j, i));
+ }
+ }
+ }
+ }
+
+ return branchPoints;
+}
+
+std::vector ImageProcessor::extractDistanceMapBifurcationPoints(const cv::Mat& thinnedImage, const cv::Mat& distanceMap, int borderSize, float minDistance)
+{
+
+ int rows = thinnedImage.rows;
+ int cols = thinnedImage.cols;
+ int neighbor[2][8] = { {-1, -1, 0, 1, 1, 1, 0, -1}, {0, 1, 1, 1, 0, -1, -1, -1} };
+ std::vector> branchLengthMap(rows, std::vector(cols, 0));
+ std::vector branchPoints;
+
+ /*int rows = thinnedImage.rows;
+ int cols = thinnedImage.cols;
+ int neighbor[2][8] = { {-1, -1, 0, 1, 1, 1, 0, -1}, {0, 1, 1, 1, 0, -1, -1, -1} };
+ std::vector> branchLengthMap(rows, std::vector(cols, 0));
+ std::vector branchPoints;*/
+
+ //�܂��}������̒������v�Z���Ȃ��烋�[�v����
+ for (int i = borderSize; i < rows - borderSize; i++) {
+ for (int j = borderSize; j < cols - borderSize; j++) {
+ // �w�肳�ꂽ�ŏ������ȏォ�ǂ������m�F
+ if (distanceMap.at(i, j) < minDistance)
+ continue; // �������������ꍇ�̓X�L�b�v
+
+ if (thinnedImage.at(i, j) == 255) {
+
+ int neighborCount = 0;
+ for (int k = 0; k < 8; k++) {
+ int x = i + neighbor[0][k];
+ int y = j + neighbor[1][k];
+
+ // �摜�͈͊O���`�F�b�N
+ if (x >= 0 && x < rows && y >= 0 && y < cols && thinnedImage.at(x, y) == 255) {
+ if(branchLengthMap[x][y] == 0)
+ branchLengthMap[x][y] = branchLengthMap[i][j] + 1;
+ neighborCount++;
+ }
+ }
+ if (neighborCount >= 3)
+ branchLengthMap[i][j] = 0;
+ }
+ }
+ }
+ visualizeBranchLengthMap(branchLengthMap);
+ // ���ɕ���_�����o����
+ for (int i = borderSize; i < rows - borderSize; i++) {
+ for (int j = borderSize; j < cols - borderSize; j++) {
+ if (distanceMap.at(i, j) < minDistance)
+ continue; // �������������ꍇ�̓X�L�b�v
+
+ if (thinnedImage.at(i, j) == 255) {
+ int neighborCount = 0;
+ int lengthCount = 0;
+ for (int k = 0; k < 8; k++) {
+ int x = i + neighbor[0][k];
+ int y = j + neighbor[1][k];
+
+ // �摜�͈͓��ŗאڂ���s�N�Z���������ǂ������`�F�b�N
+ if (x >= 0 && x < rows && y >= 0 && y < cols && thinnedImage.at(x, y) == 255) {
+ if (branchLengthMap[x][y] >= 100)
+ lengthCount++;
+ //neighborCount++;
+ }
+ }
+
+ // ����_�̏������m�F
+ //if (neighborCount >= 3)
+ // branchPoints.push_back(cv::Point(j, i)); // ����_��ۑ�
+ if(lengthCount >= 3)
+ branchPoints.push_back(cv::Point(j, i)); // ����_��ۑ�
+ }
+ }
+ }
+
+ return branchPoints;
+}
+
+void visualizeBranchLengthMap(const std::vector>& branchLengthMap)
+{
+ int rows = branchLengthMap.size();
+ int cols = branchLengthMap[0].size();
+
+ // branchLengthMap ��ۑ����邽�߂̉摜���쐬�i32�r�b�g�����`���j
+ cv::Mat branchLengthImage = cv::Mat::zeros(rows, cols, CV_32SC1);
+
+ // branchLengthMap�̒l�����̂܂܃R�s�[
+ for (int i = 0; i < rows; i++) {
+ for (int j = 0; j < cols; j++) {
+ branchLengthImage.at(i, j) = branchLengthMap[i][j];
+ }
+ }
+
+ // �摜��\������i�����̂܂܂ł͕\���ł��Ȃ����߁A�ʂ̌`���ɕϊ����K�v�j
+ // �\���̂��߂Ɉꎞ�I��8�r�b�g�ɕϊ�
+ cv::Mat displayImage;
+ branchLengthImage.convertTo(displayImage, CV_8UC1); // 8�r�b�g�`���ɕϊ�
+ //cv::imshow("Branch Length Map (8-bit for display)", displayImage);
+
+
+ //return branchLengthImage; // �摜��Ԃ��i�ۑ��ȂǂɎg�p�j
+}
+
+
+cv::Mat inverseImage(const cv::Mat& src)
+{
+ cv::Mat invertedImage;
+ invertedImage = 255 - src;
+ return invertedImage;
+}
+
+cv::Mat maximumImage(const cv::Mat& src1, const cv::Mat& src2)
+{
+ // img1��img2�������T�C�Y�ƃf�[�^�^�C�v�ł��邱�Ƃ��m�F
+ if (src1.size() != src2.size() || src1.type() != src2.type()) {
+ std::cerr << "Error: img1 and img2 must have the same size and type." << std::endl;
+ return cv::Mat(); // ���Mat��Ԃ�
+ }
+
+ cv::Mat maxImage = src1.clone(); // ���ʂ��i�[����Mat���쐬�iimg1�̃R�s�[���g�p�j
+
+ cv::max(src1, src2, maxImage);
+
+ return maxImage;
+}
diff --git a/opticalFlowProcessing/ImageProcessor.h b/opticalFlowProcessing/ImageProcessor.h
new file mode 100644
index 0000000..0074913
--- /dev/null
+++ b/opticalFlowProcessing/ImageProcessor.h
@@ -0,0 +1,54 @@
+#pragma once
+#include "myOpenCV3.h"
+#include
+class ImageProcessor {
+public:
+ // �R���X�g���N�^�œ��͉摜�����
+ void inputProcess(const cv::Mat& inputImage);
+ // �摜���������s���郁�\�b�h
+ void applyCLAHEProcess();
+ void applyGaborProcess();
+ void applyAllProcess();
+ void setCLAHETile(int CLAHETileSize);
+ void setCLAHEClipLimit(double CLAHEClipLimit);
+ // �e������̉摜���擾���邽�߂�getter���\�b�h
+ cv::Mat getOriginalImage() const;
+ cv::Mat getCLAHEImage() const;
+ cv::Mat getGaborImage() const;
+ cv::Mat getBinaryImage() const;
+ cv::Mat getSmallRegionRemovedImage() const;
+ cv::Mat getThinnedImage() const;
+ cv::Mat getCircleImage() const;
+ std::vector getBranchPoints() const;
+
+private:
+ cv::Mat m_originalImage;
+ cv::Mat m_maskAreaImage;
+ cv::Mat m_distanceMap;
+ cv::Mat m_maskOriginalImage;
+ cv::Mat m_claheImage;
+ cv::Mat m_gaborImage;
+ cv::Mat m_binaryImage;
+ cv::Mat m_smallRegionRemovedImage;
+ cv::Mat m_thinnedImage;
+ cv::Mat m_circleImage;
+ std::vector m_branchPoints;
+ int m_CLAHETileSize = 17;
+ double m_CLAHEClipLimit = 10.0;
+
+ // �e��摜������
+ // ���̑��̃w���p�[��
+
+ void removeSmallArea(const cv::Mat& binaryImage, cv::Mat& smallRegionRemovedImage, double areaThreshold);
+ void thinning(const cv::Mat& smallRegionRemovedImage, cv::Mat& thinnedImage);
+ void thinningIteration(cv::Mat& smallRegionRemovedImage, int iteration);
+ std::vector extractBifurcationPoints(const cv::Mat& thinnedImage, const cv::Mat& distanceMap, int borderSize, float minDistance);
+ std::vector extractStrictBifurcationPoints(const cv::Mat& thinnedImage, int borderSize);
+ std::vector extractDistanceMapBifurcationPoints(const cv::Mat& thinnedImage, const cv::Mat& distanceMap, int borderSize, float minDistance);
+
+ // ���̑��̉摜������
+};
+
+void visualizeBranchLengthMap(const std::vector>& branchLengthMap);
+cv::Mat inverseImage(const cv::Mat& src);
+cv::Mat maximumImage(const cv::Mat& src1, const cv::Mat& src2);
\ No newline at end of file
diff --git a/opticalFlowProcessing/Source.cpp b/opticalFlowProcessing/Source.cpp
new file mode 100644
index 0000000..28a22c0
--- /dev/null
+++ b/opticalFlowProcessing/Source.cpp
@@ -0,0 +1,445 @@
+#include "myOpenCV3.h"
+#include "ImageProcessor.h"
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+using namespace std;
+using namespace cv;
+
+struct OpticalFlowResult {
+ cv::Mat image;
+ std::vector branchPoints;
+};
+
+// �����摜�̐���
+cv::Mat createMultiImage(std::vector& imgs, // �S�Ă̕\���摜�i8bit 3ch or 8bit 1ch�̂�)
+ unsigned int cols, // ���̘A����
+ unsigned int rows, // �c�̘A����
+ cv::Size imgsize, // �\������摜�T�C�Y
+ unsigned int border)
+{
+ if (imgs.size() < 1 || cols < 1 || rows < 1) cerr << "�G���[" << endl;
+
+ unsigned int w = imgsize.width + border, h = imgsize.height + border;
+ cv::Mat board(h * rows + border, w * cols + border, CV_8UC3, CV_RGB(128, 128, 128));
+ for (unsigned int r = 0, i = 0; r < rows; r++) {
+ for (unsigned int c = 0; c < cols; c++, i++) {
+ cv::Rect roi_rect = cv::Rect(c * w + border, r * h + border, imgsize.width, imgsize.height);
+ cv::Mat roi(board, roi_rect);
+ if (i < imgs.size()) {
+ if (imgs[i].type() == CV_8UC3) {
+ resize(imgs[i], roi, imgsize);
+ }
+ else if (imgs[i].type() == CV_8UC1) {
+ cv::Mat c3;
+ cv::cvtColor(imgs[i], c3, cv::COLOR_GRAY2BGR);
+ resize(c3, roi, imgsize);
+ }
+ else {
+ putText(roi, "Color mode not matched", cv::Point(20, 20), cv::FONT_HERSHEY_COMPLEX, 0.5, CV_RGB(0, 0, 0));
+ }
+ }
+ else {
+ putText(roi, "No image", cv::Point(20, 20), cv::FONT_HERSHEY_COMPLEX, 0.5, CV_RGB(0, 0, 0));
+ }
+ }
+ }
+ return board;
+}
+
+// CSV�t�@�C������|�C���g��ǂݍ��ފ�
+std::vector> readPointsFromCSV(const std::string& csvFilePath) {
+ std::ifstream file(csvFilePath);
+ std::vector> points;
+ std::string line;
+
+ while (std::getline(file, line)) {
+ std::stringstream ss(line);
+ std::string value;
+ std::vector framePoints;
+
+ // "Frame N," �̕���������
+ std::getline(ss, value, ',');
+
+ while (std::getline(ss, value, ',')) {
+ float x = std::stof(value);
+ std::getline(ss, value, ',');
+ float y = std::stof(value);
+ framePoints.push_back(cv::Point2f(x, y));
+ }
+ points.push_back(framePoints);
+ }
+
+ return points;
+}
+
+// �ł��߂��_�y�A�����߂�
+// �ł��߂��_�Ƃ̌덷���v�Z�����
+cv::Point2f defineClosePoint(const cv::Point2f& groundTruthPoint, const std::vector& points) {
+ cv::Point2f closePoint;
+ float minError = std::numeric_limits::max();
+ for (const auto& pt : points) {
+ float error = std::sqrt(std::pow(groundTruthPoint.x - pt.x, 2) + std::pow(groundTruthPoint.y - pt.y, 2));
+ if (error < minError) {
+ minError = error;
+ closePoint = pt;
+ }
+ }
+ return closePoint;
+}
+
+// �ł��߂��_�Ƃ̌덷���v�Z�����
+float calculateMinError(const cv::Point2f& groundTruthPoint, const std::vector& points) {
+ float minError = std::numeric_limits::max();
+ for (const auto& pt : points) {
+ float error = std::sqrt(std::pow(groundTruthPoint.x - pt.x, 2) + std::pow(groundTruthPoint.y - pt.y, 2));
+ if (error < minError) {
+ minError = error;
+ }
+ }
+ return minError;
+}
+
+int main()
+{
+ std::string inputVideoFileName = "nipple_video/nemoto.avi"; // ���͓���t�@�C��
+ std::string csvFilePath = "result_mean/dummy.csv";
+ std::string outputDir = "nemoto_last"; // �o�̓f�B���N�g��
+
+ // CSV�t�@�C������|�C���g��ǂݍ���
+ std::vector> groundTruthPoints = readPointsFromCSV(csvFilePath);
+
+ // �o�̓f�B���N�g���̍쐬
+ std::filesystem::create_directory(outputDir);
+
+
+ cv::VideoCapture cap(inputVideoFileName);
+
+
+ // ��O����
+ if (!cap.isOpened()) {
+ std::cerr << "����t�@�C�����J���܂���ł����B" << std::endl;
+ return -1;
+ }
+
+ // ����̃v���p�e�B���擾
+ int frame_width = static_cast(cap.get(cv::CAP_PROP_FRAME_WIDTH));
+ int frame_height = static_cast(cap.get(cv::CAP_PROP_FRAME_HEIGHT));
+ int fps = static_cast(cap.get(cv::CAP_PROP_FPS));
+
+ std::cout << "fps is " << fps << std::endl;
+
+
+ for (int i = 16; i <= 16; i *= 2) {
+ std::cout << "Processing with i = " << i << std::endl;
+
+ // ����L���v�`���̃��Z�b�g
+ cap.set(cv::CAP_PROP_POS_FRAMES, 0);
+ // ���[�v���ƂɃf�B���N�g�����쐬
+ std::string subDir = outputDir + "/CLAHETileSize_" + std::to_string(i);
+ std::filesystem::create_directory(subDir);
+
+ // �o�̓t�@�C������i�ɉ����ĕύX
+ std::string noBranchPointsFileName = subDir + "/noBranchPoints.avi";
+ std::string branchPointsFileName = subDir + "/BranchPoints.avi";
+ std::string claheVideoFileName = subDir + "/CLAHE.avi";
+ std::string gaborVideoFileName = subDir + "/Gabor.avi";
+
+ // CSV�t�@�C�����̍쐬
+ std::string csvFileName = subDir + "/error_" + std::to_string(i) + ".csv";
+ std::ofstream csvFile(csvFileName);
+ if (!csvFile.is_open()) {
+ std::cerr << "Error opening CSV file: " << csvFileName << std::endl;
+ return -1;
+ }
+
+ csvFile << "Frame, Pixel Error" << std::endl;
+
+ // �o�͓���̐ݒ�
+ cv::VideoWriter noBranchPointsVideo;
+ cv::VideoWriter branchPointsVideo;
+ cv::VideoWriter claheVideo;
+ cv::VideoWriter gaborVideo;
+
+ noBranchPointsVideo.open(noBranchPointsFileName, cv::VideoWriter::fourcc('M', 'J', 'P', 'G'), fps, cv::Size(frame_width, frame_height), true);
+ branchPointsVideo.open(branchPointsFileName, cv::VideoWriter::fourcc('M', 'J', 'P', 'G'), fps, cv::Size(frame_width, frame_height), true);
+ claheVideo.open(claheVideoFileName, cv::VideoWriter::fourcc('M', 'J', 'P', 'G'), fps, cv::Size(frame_width, frame_height), true);
+ gaborVideo.open(gaborVideoFileName, cv::VideoWriter::fourcc('M', 'J', 'P', 'G'), fps, cv::Size(frame_width, frame_height), true);
+
+ if (!noBranchPointsVideo.isOpened() || !branchPointsVideo.isOpened() || !claheVideo.isOpened() || !gaborVideo.isOpened() ){
+ std::cerr << "����t�@�C���̕ۑ��Ɏ��s���܂����B" << std::endl;
+ return -1;
+ }
+
+ cv::Mat frame, prevFrame, prev;
+ std::vector prevPoints, nextPoints;
+ std::vector currentBranchPoints = nextPoints;
+ std::vector status;
+ std::vector err;
+ int circleSize = 10;
+ int frameNumber = 0;
+ float totalMSE = 0.0f;
+ bool doneBranchPoint = false;
+
+ ImageProcessor processor;
+
+ processor.setCLAHETile(16);
+ processor.setCLAHEClipLimit(10);
+ // ����̃t���[������
+ while (true) {
+ cap >> frame;
+ if (frame.empty())
+ break;
+
+ cv::Mat src = frame.clone();
+ cv::Mat srcResized;
+ cv::resize(src, srcResized, cv::Size(320, 256));
+ // �S�t���[���ŏ���
+ processor.inputProcess(srcResized);
+ processor.applyAllProcess();
+
+ // �擾�����摜���擾
+ cv::Mat originalImage = processor.getOriginalImage();
+ cv::Mat claheImage = processor.getCLAHEImage();
+ cv::Mat gaborImage = processor.getGaborImage();
+ cv::Mat binaryImage = processor.getBinaryImage();
+ cv::Mat smallRegionRemovedImage = processor.getSmallRegionRemovedImage();
+ cv::Mat thinnedImage = processor.getThinnedImage();
+ cv::Mat circleImage = processor.getCircleImage();
+
+ // 8�r�b�g�摜��24�r�b�g�摜�ɕϊ�
+ cv::Mat claheImageRGB, gaborImageRGB, binaryImageRGB, smallRegionRemovedImageRGB, thinnedImageRGB, circleImageRGB;
+ if (claheImage.channels() == 1) {
+ cv::cvtColor(claheImage, claheImageRGB, cv::COLOR_GRAY2BGR);
+ }
+ else {
+ claheImageRGB = claheImage.clone();
+ }
+
+ if (gaborImage.channels() == 1) {
+ cv::cvtColor(gaborImage, gaborImageRGB, cv::COLOR_GRAY2BGR);
+ }
+ else {
+ gaborImageRGB = gaborImage.clone();
+ }
+
+ if (binaryImage.channels() == 1) {
+ cv::cvtColor(binaryImage, binaryImageRGB, cv::COLOR_GRAY2BGR);
+ }
+ else {
+ binaryImageRGB = binaryImage.clone();
+ }
+
+ if (smallRegionRemovedImage.channels() == 1) {
+ cv::cvtColor(smallRegionRemovedImage, smallRegionRemovedImageRGB, cv::COLOR_GRAY2BGR);
+ }
+ else {
+ smallRegionRemovedImageRGB = smallRegionRemovedImage.clone();
+ }
+
+ if (thinnedImage.channels() == 1) {
+ cv::cvtColor(thinnedImage, thinnedImageRGB, cv::COLOR_GRAY2BGR);
+ }
+ else {
+ thinnedImageRGB = thinnedImage.clone();
+ }
+
+ if (circleImage.channels() == 1) {
+ cv::cvtColor(circleImage, circleImageRGB, cv::COLOR_GRAY2BGR);
+ }
+ else {
+ circleImageRGB = circleImage.clone();
+ }
+
+ // �g���b�L���O�p�̉摜
+ cv::Mat trackingImage = claheImage.clone();
+
+ std::vector images = { originalImage, claheImageRGB, gaborImageRGB, binaryImageRGB, smallRegionRemovedImageRGB, thinnedImageRGB };
+ cv::Mat multiImage = createMultiImage(images, 3, 2, cv::Size(frame_width / 3, frame_height / 2), 0);
+ cv::Mat resizedMultiImage, resizedBranchMultiImage;
+ cv::resize(multiImage, resizedMultiImage, cv::Size(frame_width, frame_height));
+
+ // clahe��gabor�̏o��
+ cv::Mat resizedCLAHEImage, resizedGaborImage;
+ cv::resize(claheImageRGB, resizedCLAHEImage, cv::Size(frame_width, frame_height));
+ cv::resize(gaborImageRGB, resizedGaborImage, cv::Size(frame_width, frame_height));
+ claheVideo.write(resizedCLAHEImage);
+ gaborVideo.write(resizedGaborImage);
+
+ // �ۑ��f�B���N�g���̃p�X
+ std::string imageSaveDir = subDir + "/images/";
+ std::filesystem::create_directory(imageSaveDir);
+
+ // �t���[�����Ƃɉ摜��ۑ����鏈��
+ std::string frameNumberStr = std::to_string(frameNumber);
+
+ std::string srcImageFileName = imageSaveDir + "sorce_" + frameNumberStr + ".png";
+ std::string claheImageFileName = imageSaveDir + "clahe_" + frameNumberStr + ".png";
+ std::string gaborImageFileName = imageSaveDir + "gabor_" + frameNumberStr + ".png";
+ std::string binaryImageFileName = imageSaveDir + "binary_" + frameNumberStr + ".png";
+ std::string smallRegionRemovedImageFileName = imageSaveDir + "smallRegionRemoved_" + frameNumberStr + ".png";
+ std::string thinnedImageFileName = imageSaveDir + "thinned_" + frameNumberStr + ".png";
+ std::string circleImageFileName = imageSaveDir + "circle_" + frameNumberStr + ".png";
+
+ // �摜�̕ۑ�����
+
+ cv::imwrite(srcImageFileName, src);
+ cv::imwrite(claheImageFileName, claheImageRGB);
+ cv::imwrite(gaborImageFileName, gaborImageRGB);
+ cv::imwrite(binaryImageFileName, binaryImageRGB);
+ cv::imwrite(smallRegionRemovedImageFileName, smallRegionRemovedImageRGB);
+ cv::imwrite(thinnedImageFileName, thinnedImageRGB);
+ cv::imwrite(circleImageFileName, circleImageRGB);
+
+ vector branchPoints2f_;
+ for (const auto& pt : processor.getBranchPoints()) {
+ branchPoints2f_.push_back(cv::Point2f(static_cast(pt.x), static_cast(pt.y)));
+ }
+
+ // ����_
+ for (const auto& branchPoint : branchPoints2f_) {
+ for (auto& image : images) {
+ cv::circle(image, branchPoint, circleSize, cv::Scalar(223, 121, 0), 5); // �F�ŕ`��
+ }
+ }
+
+ if (frameNumber == 0 || !doneBranchPoint) {
+ prevPoints.clear();
+ vector branchPoints2f;
+ for (const auto& pt : processor.getBranchPoints()) {
+ branchPoints2f.push_back(cv::Point2f(static_cast(pt.x), static_cast(pt.y)));
+ }
+ // ����_�̓�����_�ɍł��߂��_�݂̂�\��
+ /*for (const auto& gt : groundTruthPoints[frameNumber]) {
+ prevPoints.push_back(defineClosePoint(gt, branchPoints2f));
+ }*/
+
+ for (const auto& pt : processor.getBranchPoints()) {
+ prevPoints.push_back(pt);
+ }
+
+ doneBranchPoint = true;
+ // ����_
+ for (const auto& branchPoint : branchPoints2f) {
+ for (auto& image : images) {
+ cv::circle(image, branchPoint, circleSize, cv::Scalar(223, 121, 0), 5); // �F�ŕ`��
+ }
+ }
+ std::cout << "����������_�T��" << std::endl;
+ }
+
+ //else {
+ // cv::calcOpticalFlowPyrLK(prevFrame, trackingImage, prevPoints, nextPoints, status, err);
+ // // status �Ɋ�Â��ĒǐՐ����E���s��
+ // doneBranchPoint = false;
+ // for (size_t i = 0; i < status.size(); i++) {
+ // if (status[i]) {
+ // doneBranchPoint = true; // ���Ȃ��Ƃ�1�̃|�C���g���ǐՐ���
+ // // ���������|�C���g�������i�Ⴆ�Ε`��j
+ // for (auto& image : images) {
+ // cv::circle(image, nextPoints[i], circleSize, cv::Scalar(11, 227, 0), 5); // �ΐF�ŕ`��
+ // }
+
+ // }
+ // }
+ // prevPoints = nextPoints;
+
+ //
+ // // �����S�Ẵ|�C���g�̒ǐՂɎ��s���Ă�����
+ // if(!doneBranchPoint)
+ // {
+ // std::cout << "�S�Ẵ|�C���g���I�v�e�B�J���t���[�ŒǐՂł��܂���ł���" << std::endl;
+ // doneBranchPoint = false;
+ // //frameNumber++;
+ // //continue; // ���̃t���[���̏������X�L�b�v���Ď���
+ // }
+ //
+ //}
+ //else {
+ // cv::calcOpticalFlowPyrLK(prevFrame, trackingImage, prevPoints, nextPoints, status, err);
+ // if (nextPoints.size() == 0) {
+ // doneBranchPoint = false;
+ // std::cout << "�I�v�e�B�J���t���[���s" << std::endl;
+ // continue;
+ // }
+ // for (size_t i = 0; i < nextPoints.size(); i++) {
+ // if (status[i]) {
+ // for (const auto& image : images) {
+ // cv::circle(image, nextPoints[i], circleSize, cv::Scalar(11, 227, 0), 5); // �ΐF�ŕ`��
+ // }
+ // }
+ // }
+ // prevPoints = nextPoints;
+ //}
+
+ // �덷�v�Z
+ const auto& gtPoints = groundTruthPoints[frameNumber];
+ float totalError = 0.0f;
+
+ // �e�_�̍ŏ��덷���L�^���邽�߂̕ϐ�
+ std::vector minErrors;
+ std:vector closePoints;
+
+
+ for (const auto& gt : gtPoints) {
+ float minError = calculateMinError(gt, prevPoints);
+ minErrors.push_back(minError); // �e�_�̍ŏ��덷��ۑ�
+ totalError += minError;
+ }
+ float avgError = totalError / gtPoints.size();
+
+ // csv�t�@�C���ւ̏�������
+ // CSV�t�@�C���Ɋe�_�̍ŏ��덷���L�^
+ csvFile << frameNumber;
+ for (const auto& minError : minErrors) {
+ csvFile << ", " << minError;
+ }
+ csvFile << ", " << avgError << std::endl;
+
+ //// groundTruth�̓_��Ԃŕ`��
+ //for (const auto& pt : gtPoints) {
+ // for (auto& image : images) {
+ // cv::circle(image, pt, circleSize, cv::Scalar(127, 0, 228), 5); // �ԐF�ŕ`��
+ // }
+ //}
+
+ totalMSE += avgError;
+
+ cv::Mat branchPointsMultiImage = createMultiImage(images, 3, 2, cv::Size(frame_width / 3, frame_height / 2), 2);
+ cv::resize(branchPointsMultiImage, resizedBranchMultiImage, cv::Size(frame_width, frame_height));
+
+ prevFrame = trackingImage.clone();
+
+ cv::imshow("multiImage", resizedBranchMultiImage);
+ if (cv::waitKey(5) >= 0) {
+ break;
+ }
+
+ noBranchPointsVideo.write(resizedMultiImage);
+ branchPointsVideo.write(resizedBranchMultiImage);
+
+
+
+ frameNumber++;
+
+ }
+ csvFile << "�S�̂̕���MSE:," << (float)(totalMSE / (float)frameNumber) << std::endl;
+ csvFile.close();
+ noBranchPointsVideo.release();
+ branchPointsVideo.release();
+ claheVideo.release();
+ gaborVideo.release();
+ std::cout << "���揈�����������܂���: i = " << i << std::endl;
+ }
+
+ cap.release();
+ cv::destroyAllWindows();
+ return 0;
+}
+
diff --git a/opticalFlowProcessing/VideoProcesser.cpp b/opticalFlowProcessing/VideoProcesser.cpp
new file mode 100644
index 0000000..b3d2829
--- /dev/null
+++ b/opticalFlowProcessing/VideoProcesser.cpp
@@ -0,0 +1,59 @@
+#include "videoProcesser.h"
+
+VideoProcessor::VideoProcessor(const std::string& outputDir)
+{
+
+}
+
+void VideoProcessor::processFrame(const cv::Mat& frame, int frameNumber)
+{
+}
+
+cv::Mat VideoProcessor::getOriginalImage() const
+{
+ return cv::Mat();
+}
+
+cv::Mat VideoProcessor::getCLAHEImage() const
+{
+ return cv::Mat();
+}
+
+cv::Mat VideoProcessor::getGaborImage() const
+{
+ return cv::Mat();
+}
+
+cv::Mat VideoProcessor::getBinaryImage() const
+{
+ return cv::Mat();
+}
+
+cv::Mat VideoProcessor::getSmallRegionRemovedImage() const
+{
+ return cv::Mat();
+}
+
+cv::Mat VideoProcessor::getThinnedImage() const
+{
+ return cv::Mat();
+}
+
+
+cv::Mat VideoProcessor::applyCLAHE(const cv::Mat& src)
+{
+ return cv::Mat();
+}
+
+
+cv::Mat VideoProcessor::applyGaborProcessing(const cv::Mat& src, int frameNumber)
+{
+ return cv::Mat();
+}
+
+cv::Mat inverseImage(const cv::Mat& src)
+{
+ cv::Mat invertedImage;
+ invertedImage = 255 - src;
+ return invertedImage;
+}
\ No newline at end of file
diff --git a/opticalFlowProcessing/myOpenCV3.h b/opticalFlowProcessing/myOpenCV3.h
new file mode 100644
index 0000000..60ad8df
--- /dev/null
+++ b/opticalFlowProcessing/myOpenCV3.h
@@ -0,0 +1,76 @@
+
+// OpenCV 3�n ���ʃw�b�_�[�t�@�C��
+// T.Nakaguchi
+
+// �w�b�_�[�t�@�C��
+#pragma warning(disable: 4819)
+#include
+#pragma warning(default: 4819)
+
+// �o�[�W�����擾
+#define CV_VERSION_STR CVAUX_STR(CV_MAJOR_VERSION) CVAUX_STR(CV_MINOR_VERSION) CVAUX_STR(CV_SUBMINOR_VERSION)
+
+// �r���h���[�h
+#ifdef _DEBUG
+#define CV_EXT_STR "d.lib"
+#else
+#define CV_EXT_STR ".lib"
+#endif
+
+// ���C�u�����̃����N�i�s�v�ȕ��̓R�����g�A�E�g�j
+#define PRE_COMPILE 0 // �C���X�g�[���łȂ� 1 �ʃ��C�u�����g�p���� 0
+#define PREHEAD "opencv_"
+
+#if PRE_COMPILE
+// OpenCV3.0 �C���X�g�[����
+#pragma comment(lib, PREHEAD "world" CV_VERSION_STR CV_EXT_STR) // �S��
+#pragma comment(lib, PREHEAD "ts" CV_VERSION_STR CV_EXT_STR) // �f���֘A
+
+#else
+// �ʂ̃��C�u�����w�� �iCmake��Static�Ŏg�p���Ȃǁj
+// ��{���W���[��
+#pragma comment(lib, PREHEAD "core" CV_VERSION_STR CV_EXT_STR) // ��{�@�\
+#pragma comment(lib, PREHEAD "imgproc" CV_VERSION_STR CV_EXT_STR) // �摜����
+#pragma comment(lib, PREHEAD "imgcodecs" CV_VERSION_STR CV_EXT_STR) // �摜�t�@�C�����o��
+#pragma comment(lib, PREHEAD "videoio" CV_VERSION_STR CV_EXT_STR) // ����t�@�C�����o��
+#pragma comment(lib, PREHEAD "highgui" CV_VERSION_STR CV_EXT_STR) // ���@�\GUI
+#pragma comment(lib, PREHEAD "video" CV_VERSION_STR CV_EXT_STR) // ���摜���
+#pragma comment(lib, PREHEAD "calib3d" CV_VERSION_STR CV_EXT_STR) // �J�����Z���ƎO�����č\�z
+#pragma comment(lib, PREHEAD "features2d" CV_VERSION_STR CV_EXT_STR) // �摜�������
+#pragma comment(lib, PREHEAD "objdetect" CV_VERSION_STR CV_EXT_STR) // ���̌��o
+#pragma comment(lib, PREHEAD "ml" CV_VERSION_STR CV_EXT_STR) // �@�B�w�K
+#pragma comment(lib, PREHEAD "flann" CV_VERSION_STR CV_EXT_STR) // �������N���X�^�����O�ƌ���
+#pragma comment(lib, PREHEAD "photo" CV_VERSION_STR CV_EXT_STR) // �v�Z�@�ʐ^
+#pragma comment(lib, PREHEAD "stitching" CV_VERSION_STR CV_EXT_STR) // �摜�ڑ�
+//#pragma comment(lib, PREHEAD "hal" CV_VERSION_STR CV_EXT_STR) // �n�[�h�E�F�A������
+#pragma comment(lib, PREHEAD "shape" CV_VERSION_STR CV_EXT_STR) // �`���v���o
+#pragma comment(lib, PREHEAD "superres" CV_VERSION_STR CV_EXT_STR) // ����
+#pragma comment(lib, PREHEAD "videostab" CV_VERSION_STR CV_EXT_STR) // ���摜���艻
+//#pragma comment(lib, PREHEAD "vis" CV_VERSION_STR CV_EXT_STR) // 3��������
+
+// �g�����W���[��
+//#pragma comment(lib, PREHEAD "adas" CV_VERSION_STR CV_EXT_STR) // ��i�I�f�o�C�X�T�|�[�g
+//#pragma comment(lib, PREHEAD "aruco" CV_VERSION_STR CV_EXT_STR) // AR�p�}�[�J�[
+#pragma comment(lib, PREHEAD "bgsegm" CV_VERSION_STR CV_EXT_STR) // ���nj^�w�i�E�O�i����
+#pragma comment(lib, PREHEAD "bioinspired" CV_VERSION_STR CV_EXT_STR) // ���̂Ɋ�Â����o�I����
+#pragma comment(lib, PREHEAD "ccalib" CV_VERSION_STR CV_EXT_STR) // �J�X�^���p�^�[���ɂ��J�����Z���ƎO�����č\��
+//#pragma comment(lib, PREHEAD "cvv" CV_VERSION_STR CV_EXT_STR) // �Θb�I���o�I�f�o�b�OGUI
+#pragma comment(lib, PREHEAD "datasets" CV_VERSION_STR CV_EXT_STR) // ����f�[�^�Z�b�g��舵���t���[�����[�N
+#pragma comment(lib, PREHEAD "face" CV_VERSION_STR CV_EXT_STR) // ��F��
+//#pragma comment(lib, PREHEAD "latentsvm" CV_VERSION_STR CV_EXT_STR) // Latent-SVM
+#pragma comment(lib, PREHEAD "line_descriptor" CV_VERSION_STR CV_EXT_STR) // �����o�̃o�C�i���\��
+//#pragma comment(lib, PREHEAD "matlab" CV_VERSION_STR CV_EXT_STR) // MATLAB�u���b�W
+#pragma comment(lib, PREHEAD "optflow" CV_VERSION_STR CV_EXT_STR) // �I�v�e�B�J���t���[
+#pragma comment(lib, PREHEAD "reg" CV_VERSION_STR CV_EXT_STR) // �摜�ʒu���킹
+#pragma comment(lib, PREHEAD "rgbd" CV_VERSION_STR CV_EXT_STR) // RGB-�[�x�J����
+#pragma comment(lib, PREHEAD "saliency" CV_VERSION_STR CV_EXT_STR) // �摜 ������ API
+#pragma comment(lib, PREHEAD "surface_matching" CV_VERSION_STR CV_EXT_STR) // �\�ʃ��f����v���o
+#pragma comment(lib, PREHEAD "text" CV_VERSION_STR CV_EXT_STR) // �V�[���������o�ƔF��
+#pragma comment(lib, PREHEAD "tracking" CV_VERSION_STR CV_EXT_STR) // �ǐ�
+#pragma comment(lib, PREHEAD "xfeatures2d" CV_VERSION_STR CV_EXT_STR) // �g���� �摜�������
+#pragma comment(lib, PREHEAD "ximgproc" CV_VERSION_STR CV_EXT_STR) // �g���� �摜����
+#pragma comment(lib, PREHEAD "xobjdetect" CV_VERSION_STR CV_EXT_STR) // �g���� ���̌��o
+#pragma comment(lib, PREHEAD "xphoto" CV_VERSION_STR CV_EXT_STR) // �g���� �v�Z�@�ʐ^
+#endif
+
+using namespace cv;
diff --git a/opticalFlowProcessing/opticalFlowProcessing.vcxproj b/opticalFlowProcessing/opticalFlowProcessing.vcxproj
new file mode 100644
index 0000000..5ce3159
--- /dev/null
+++ b/opticalFlowProcessing/opticalFlowProcessing.vcxproj
@@ -0,0 +1,138 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Release
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ x64
+
+
+
+ 15.0
+ {D48B5F5F-E967-4A6D-A6FE-EFE946014037}
+ RemoveArea
+ 10.0
+ opticalFlowProcessing
+
+
+
+ Application
+ true
+ v143
+ MultiByte
+
+
+ Application
+ false
+ v143
+ true
+ MultiByte
+
+
+ Application
+ true
+ v143
+ MultiByte
+
+
+ Application
+ false
+ v143
+ true
+ MultiByte
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ D:\SDK\opencv-4.0.0\build\install\include;$(IncludePath)
+ D:\SDK\opencv-4.0.0\build\install\x64\vc15\lib;$(LibraryPath)
+
+
+ D:\SDK\opencv-4.0.0\build\install\include;$(IncludePath)
+ D:\SDK\opencv-4.0.0\build\install\x64\vc15\lib;$(LibraryPath)
+
+
+
+ Level3
+ Disabled
+ true
+ true
+
+
+
+
+ Level3
+ Disabled
+ true
+ true
+ stdcpp17
+
+
+
+
+ Level3
+ MaxSpeed
+ true
+ true
+ true
+ true
+
+
+ true
+ true
+
+
+
+
+ Level3
+ MaxSpeed
+ true
+ true
+ true
+ true
+ stdcpp17
+
+
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/opticalFlowProcessing/videoProcesser.h b/opticalFlowProcessing/videoProcesser.h
new file mode 100644
index 0000000..c4469f5
--- /dev/null
+++ b/opticalFlowProcessing/videoProcesser.h
@@ -0,0 +1,37 @@
+#pragma once
+#include
+#include
+#include
+
+
+class VideoProcessor {
+public:
+ // �R���X�g���N�^
+ VideoProcessor(const std::string& outputDir);
+
+ // �摜���������s���郁�\�b�h
+ void processFrame(const cv::Mat& frame, int frameNumber);
+
+ // �e������̉摜���擾���邽�߂�getter���\�b�h
+ cv::Mat getOriginalImage() const;
+ cv::Mat getCLAHEImage() const;
+ cv::Mat getGaborImage() const;
+ cv::Mat getBinaryImage() const;
+ cv::Mat getSmallRegionRemovedImage() const;
+ cv::Mat getThinnedImage() const;
+
+private:
+ cv::Mat originalImage;
+ cv::Mat claheImage;
+ cv::Mat gaborImage;
+ cv::Mat binaryImage;
+ cv::Mat smallRegionRemovedImage;
+ cv::Mat thinnedImage;
+
+ std::string outputDir;
+
+ // �e��摜������
+ cv::Mat applyGaborProcessing(const cv::Mat& src, int frameNumber);
+ cv::Mat applyCLAHE(const cv::Mat& src);
+ // ���̑��̉摜������
+};
\ No newline at end of file