박민혀기
CELLON I 시료 걸쇠 Sobel 추출 본문
CELLON I 시료 걸쇠 Soble 추출
Sobel 필터는 미분을 통해 엣지(외곽선)를 추출하는 필터이다.
강점은 미분 방향에 따라 원하는 특정 부분을 검출 할 수 있다는 것이다.
ex) x 방향 미분, y 방향 미분
아래 필터링 결과들은 x방향 미분을 통해 가로 방향 엣지만 추출된 걸 확인할 수 있다!
가우시안 블러 : Size(5, 5)
샤프링 : 원본 이미지 비중 6, 블러링 이미지 비중 -5
원본 이미지에 샤프링(이미지를 날카롭게 표현)하여 외각선 부각!
Canny 알고리즘 활용에서 샤프링을 하지 않은 이유는 잡음이 매우 많이 증가됨..
-> 분류 불가수준의 잡음
추출 & 저장 소스 코드
#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);
cv::Mat scharr_x, scharr_y, scharr_x_result, scharr_y_result;
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);
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번
Sobel_Result.zip
2.40MB
위에 결과 이미지 다운
결과 : x축 미분을 통해 세로 방향 엣지에 있는 잡음을 제거하고 걸쇠의 가로 부분 추출하여 판단 가능해 보임!
-> 판단이 힘들거나 결과가 예민하게 반응하는 경우 x, y축 둘다 추출하여 해보는 방법도 고려중
'CELLON Vision > Test Result' 카테고리의 다른 글
CELLON I 뒷판 Sobel 필터링 양품, 불량품 결과 (0) | 2023.03.23 |
---|---|
CELLON I 시료 걸쇠 Canny 추출 (3) | 2023.03.18 |
CELLON 광량, 진동의 따른 HSV 값 변화, Yellow Color (0) | 2023.01.02 |
히스토그램 컴페어 테스트 파일 (0) | 2022.12.19 |
비전 검사기 Model CELLON 시간 측정(2022년 11월 06일) (0) | 2022.11.06 |