250x250
꾸준희
Enough is not enough
꾸준희
전체 방문자
2,319,279
오늘
213
어제
774

공지사항

  • 꾸준희 블로그
  • 분류 전체보기 (580)
    • 생각 (14)
    • Book Review (38)
    • Paper Review (18)
    • Research Topic (126)
      • Deep Learning (24)
      • Pose Estimation (29)
      • Object Detection (22)
      • Object Segmentation (3)
      • Object Tracking (11)
      • Video Surveillance (4)
      • Action Recognition (6)
      • Stereo Vision (6)
      • 3D Reconstruction (4)
      • Machine Vision (2)
      • Image Processing (11)
      • Dataset (4)
    • Development (76)
      • NVIDIA DeepStream (3)
      • NVIDIA TensorRT (30)
      • NVIDIA TAO Toolkit (2)
      • ONNX (8)
      • PyTorch (5)
      • TensorFlow (15)
      • TensorFlow Lite (1)
      • GPU | CUDA | PyCUDA (12)
    • Programming (147)
      • GStreamer | FFmpeg (6)
      • Python (27)
      • C | C++ (15)
      • OpenCV (34)
      • Linux (36)
      • Embedded linux (7)
      • Etc. (22)
    • Computer Science (62)
      • 학부 및 대학원 과목 (22)
      • 선형대수학 및 기타 수학 (7)
      • SQL-D (33)
    • 삽질 기록 (49)
    • 기타 (50)
      • 참고자료 (30)
      • 좋은 글 (5)
      • 티스토리 (2)
      • 논문 작성 관련 참고 (10)
      • 메모 (0)

블로그 메뉴

  • 👀 CV
  • 🌸 GitHub
  • 💌 LinkedIn
  • 📚 방명록

최근 댓글

  • python으로 만든 코드를 이제 a⋯
    android 초보
  • cannot resolve symbol 'type'⋯
    android 초보
  • 정확히 뭐라고 뜨나요?
    꾸준희
  • 앗 ㅠ 제가 오랜만에 스킨을 바⋯
    꾸준희
  • 선생님 ㅜㅠ 각도 계산하는 부⋯
    android 초보
07-04 08:58

티스토리

hELLO · Designed By 정상우.
꾸준희

Enough is not enough

[OpenCV] Bilateral Filter 적용하기
Programming/OpenCV

[OpenCV] Bilateral Filter 적용하기

2017. 2. 15. 20:06
반응형


Bilateral Filter


OpenCV에서 대표적인 필터로는 blur, GaussianBlur, medianBlur 그리고 BilateralFilter 가 있다. 이 필터는 선형으로 처리되지 않고, 엣지와 노이즈를 줄여주어 부드러운 영상이 만들어지게 된다. 변수의 값이 크면 클수록 픽셀에 미치는 영향이 많아져 가중치가 커지게 된다.


bilateralFilter(src, dst, d, sigmaColor, sigmaSpace);


src : 입력 이미지

dst : 출력 이미지

d : 필터링에 이용하는 이웃한 픽셀의 지름을 정의 불가능한경우 sigmaspace 를 사용

sigmaColor : 컬러공간의 시그마공간 정의, 클수록 이웃한 픽셀과 기준색상의 영향이 커진다

sigmaSpace : 시그마 필터를 조정한다. 값이 클수록 긴밀하게 주변 픽셀에 영향을 미친다. d>0 이면 영향을 받지 않고, 그 외에는 d 값에 비례한다. 



opencv reference 에 있는 함수 원형은 다음과 같다.


Applies the bilateral filter to an image.

C++: void bilateralFilter(InputArray src, OutputArray dst, int d, double sigmaColor, double sigmaSpace, int borderType=BORDER_DEFAULT )
Python: cv2.bilateralFilter(src, d, sigmaColor, sigmaSpace[, dst[, borderType]]) → dst
Parameters:
  • src – Source 8-bit or floating-point, 1-channel or 3-channel image.
  • dst – Destination image of the same size and type as src .
  • d – Diameter of each pixel neighborhood that is used during filtering. If it is non-positive, it is computed from sigmaSpace .
  • sigmaColor – Filter sigma in the color space. A larger value of the parameter means that farther colors within the pixel neighborhood (see sigmaSpace ) will be mixed together, resulting in larger areas of semi-equal color.
  • sigmaSpace – Filter sigma in the coordinate space. A larger value of the parameter means that farther pixels will influence each other as long as their colors are close enough (see sigmaColor ). When d>0 , it specifies the neighborhood size regardless of sigmaSpace . Otherwise, d is proportional to sigmaSpace .




블러 소스 코드 (변수 값을 임의로 주었다)


 
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/opencv.hpp>

using namespace std;
using namespace cv;

int main(int argc, char** argv){
	Mat bilateral = imread("image/face.png", 1);
	Mat b = bilateral.clone();
	Mat gaussian = bilateral.clone();
	Mat median = bilateral.clone();
	Mat result;
	imshow("original image", bilateral);


	blur(b, result, Size(5, 5));
	imshow("blur result", result);

	GaussianBlur(gaussian, result, Size(5, 5), 1.5, 1.5);
	imshow("GaussianBlur result",result);

	medianBlur(median, result, 7);
	imshow("medianBlur result", result);

	bilateralFilter(bilateral, result, 10, 50, 50);
	imshow("bilateralFilter result", result);

	/*
	bilateralFilter (1, 2, 3, 4, 5);

	argument 1 : Source image
	argument 2 : Destination image
	argument 3 : the diameter of each pixel neighborhood
	argument 4 : Standard deviation in the color space
	argument 5 : Standard deviation in the coordinate space 
	*/

	
	waitKey(0);
	return 0;
}



실행결과













반응형
저작자표시
  • 카카오스토리
  • 트위터
  • 페이스북

'Programming > OpenCV' 카테고리의 다른 글

[OpenCV] 동영상 저장 및 파일명 지정 (to_string)  (0) 2017.08.17
[OpenCV] Image Denoising  (0) 2017.02.16
[OpenCV] Bilateral Filter 적용하기  (0) 2017.02.15
[OpenCV] SimpleBlobDetector 을 이용한 Blob Detection  (0) 2017.02.08
[OpenCV] pyrMeanShiftFiltering 적용하여 영상분할  (0) 2017.01.17
[OpenCV] MOG2 함수를 이용한 배경추출  (0) 2017.01.17
    'Programming/OpenCV' 카테고리의 다른 글
    • [OpenCV] 동영상 저장 및 파일명 지정 (to_string)
    • [OpenCV] Image Denoising
    • [OpenCV] SimpleBlobDetector 을 이용한 Blob Detection
    • [OpenCV] pyrMeanShiftFiltering 적용하여 영상분할
    꾸준희
    꾸준희
    생각과 기록 그리고 발전
    댓글쓰기
    다음 글
    [OpenCV] Image Denoising
    이전 글
    [OpenCV] SimpleBlobDetector 을 이용한 Blob Detection
    • 이전
    • 1
    • ···
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • ···
    • 34
    • 다음

    티스토리툴바