diff --git a/IRImageProcessing/Source.cpp b/IRImageProcessing/Source.cpp index ff910b9..1e20275 100644 --- a/IRImageProcessing/Source.cpp +++ b/IRImageProcessing/Source.cpp @@ -2,6 +2,8 @@ #include #include #include +#include +#include #include void thinningIteration(cv::Mat& img, int iteration) { @@ -49,6 +51,7 @@ } while (cv::countNonZero(diff) > 0); dst *= 255; } + std::vector findBranchPoints(cv::Mat& img) { std::vector branchPoints; @@ -96,18 +99,18 @@ 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]; + //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 (thinnedImage.at(nextX, nextY) == 0) + // transitions++; } } - if (transitions == 1 && neighborCount == 3) + if (neighborCount >= 3) bifurcationPoints.push_back(cv::Point(j, i)); // OpenCV�ł́Ax���W����ԍ��Ay���W���s�ԍ��ɑΉ����܂��B } } @@ -122,13 +125,16 @@ 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 // ����_�ɉ~��`�� @@ -296,15 +317,12 @@ double margeMinVal, margeMaxVal; cv::minMaxLoc(margeImage, &margeMinVal, &margeMaxVal); // �ŏ��l�ƍő�l���擾 cv::normalize(margeImage, margeNormImage, 0, 255, cv::NORM_MINMAX, CV_8U); - cv::Mat margeBinaryImage, removedMargeOtsuBinaryImage; - cv::threshold(margeNormImage, margeBinaryImage, 60, 255, cv::THRESH_BINARY); - double areaThreshold = 1000.0; - removedMargeOtsuBinaryImage = removeSmallAreaImage(margeBinaryImage, areaThreshold); - cv::imwrite(dirName + "/MargeTH60BinaryImage.png", margeBinaryImage); - cv::imwrite(dirName + "/RemovedMargeSmallAreaBinaryImage_" + std::to_string((int)areaThreshold) + ".png", removedMargeOtsuBinaryImage); + + //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, margeImage, dirName); + BinaryProcessing(ori, margeNormImage, dirName); } @@ -313,11 +331,11 @@ int main() { - std::string inputFileName = "experiment_0412_trimmed/hattori.tif"; + std::string inputFileName = "trimmed.tif"; // �o�͏��� - std::string baseDir = "experiment_0412_result/"; - std::string dirBaseName = "subject0_0_degree_"; + std::string baseDir = "result_output/"; + std::string dirBaseName = "th50_border30_kernel5_ite2_area1000"; std::string dirName = baseDir + dirBaseName; @@ -342,9 +360,7 @@ cv::Mat windowedImage; WindowProcessing(image, windowedImage, 255.0, dirName); - // �m�C�Y���� - cv::Mat gaussinaBlurImage; - cv::GaussianBlur(windowedImage, gaussinaBlurImage, cv::Size(3, 3), 9, 0); + // CLAHE��p�����q�X�g�O�������R�� cv::Ptr clahe = cv::createCLAHE(10.0, cv::Size(16, 16)); @@ -356,9 +372,12 @@ 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(claheImage); + inversedClaheImage = inverseImage(gaussianBlurImage); // �K�{�[���t�B���^ GaborProcessing(windowedImage, inversedClaheImage, dirName); @@ -367,9 +386,9 @@ cv::imwrite(dirName + "/Original.tif", image); cv::imwrite(dirName + "/WindowedImage.png", windowedImage); - cv::imwrite(dirName + "/Gaussian.png", gaussinaBlurImage); + cv::imwrite(dirName + "/CLAHEGaussian.png", gaussianBlurImage); cv::imwrite(dirName + "/CLAHE.png", claheImage); - cv::imwrite(dirName + "/CLAHEInversion.png", inversedClaheImage); + cv::imwrite(dirName + "/CLAHEGaussianInversion.png", inversedClaheImage); cv::imwrite(dirName + "/CLAHEOtsu.png", claheOtsuBinaryImage); return 0;