박민혀기

CELLON I 시료 걸쇠 Canny 추출 본문

CELLON Vision/Test Result

CELLON I 시료 걸쇠 Canny 추출

박민혀기 2023. 3. 18. 18:15

CELLON I 시료 걸쇠 Canny 추출

최적 Threshold

Low Threshold = 10

High Threshold = 50

블러링 X

샤프링 X

GrayScale 원본에서 추출

 

추출 & 저장 소스 코드

#pragma comment(lib, "opencv_world453.lib")
#pragma comment(lib, "opencv_world453d.lib")

#include <iostream>
#include "opencv2/opencv.hpp"

using namespace std;
using namespace cv;

int main(){
	for (int i = 8; i < 23; i++) {
		char file_name[80];
		sprintf_s(file_name, "C:\\Users\\MinHyeok\\Downloads\\capture_%d.png", i);
		Mat img = imread(file_name, IMREAD_GRAYSCALE);
		if (img.empty()) {
			cout << "can't find Image" << endl;
			continue;
		}

		//Mat Gaussian_img, result;
		//GaussianBlur(img, Gaussian_img, Size(5, 5), 1);
		//addWeighted(img, 6, Gaussian_img, -5, 0, result);


		//int kernel_size = 3;
		//int scale = 1;
		//int delta = 0;

		//int ddepth = CV_32F;
		//cv::Mat scharr_x, scharr_y, scharr_x_result, scharr_y_result;
		////cv::Sobel(result, sobel_x, ddepth, 1, 0);
		////cv::Sobel(result, sobel_y, ddepth, 0, 1);

		//// Scharr Filter
		//cv::Sobel(img, scharr_x, cv::FILTER_SCHARR, 1, 0);
		//cv::Sobel(img, scharr_y, cv::FILTER_SCHARR, 0, 1);
		//cv::Sobel(result, scharr_x_result, cv::FILTER_SCHARR, 1, 0);
		//cv::Sobel(result, scharr_y_result, cv::FILTER_SCHARR, 0, 1);


		//Mat add_result;
		//addWeighted(scharr_x_result, 0.5, scharr_y_result, 0.5, 0, add_result);

		//imshow("scharr_x", scharr_x);
		//imshow("scharr_y", scharr_y);
		//imshow("scharr_x_result", scharr_x_result);
		//hconcat(img, scharr_y_result, img);

		Mat canny_img;
		Canny(img, canny_img, 10, 50);
		hconcat(img, canny_img, img);


		sprintf_s(file_name, "C:\\Users\\MinHyeok\\Desktop\\Canny_Result\\Canny_%d.jpg", i);
		imwrite(file_name, img);
	}

 

추출 이미지 왼쪽 상단 : 1번

                    오른쪽 상단 : 2번

                    왼쪽 하단 : 3번

                    오른쪽 하단 : 4번

1
1, 2

 

3
4
3, 4
2, 4
2, 4
1, 3
1, 3
1, 2, 3
1, 3, 4
2, 3, 4
1, 2, 3, 4
Canny_Result.zip
1.82MB

위에 이미지 원본 다운 

 

결과 : 2, 4번은 환연하게 판단 가능 하지만 1, 3번은  기본적으로 추출자체가 쉽지 않고, 추출이 되더라도 잡음이 많아 프로그램 처리 과정에서 판단 하는게 쉽지 않아 보인다!

 

해결법 : Sobel 필더링으로 해결 가능해 보임

※ 다음 포스팅에 비교사진, 결과 업로드!