Papers/Machine learning

[lecture][second day] Image processing

tomato13 2015. 1. 20. 17:31

1/20(Tuesday)

today, there will be improving resolution. 

enhancement is not recovering the original image. but interpolation and image restoration are for recovering the original image. 


08:30~


<Canny Edge detector>


가우스안 필터링(low pass filtering )


despite of gausian filtering, 변곡적(두번미분지점) is 0. 

(한번미분 최대절대값을 찾는것과 같다.)


so, first apply gausian filtering for removing noise.

second, apply two tresholds which make weak and strong edges.

(nonmaximal suppression is applied by which edge line can be narrow. maximum gradient 절대값 찾는다.)


third, you can make the final version from strong edge. In that time, weak edge is used for connectivity edge. 



변곡점 찾기

+, - 바뀌는 지점이 0과 동일한 것으로 간주

-> zero crossing 이라고 함


이미지를 산으로 생각하고 등고선을 찾는다고 생각



<Image Interpolation>

1. way 1

sampling -> apply ideal low pass filter and make analog signal ( suden high frequency is removed by LPF) -> convert to digital signal again. 


2. way 2

linear interpolation


3. way 3

cubic convolution

3차 방정식 가정하고 sampling data기반으로 완성(??)



inpainting: if object is removed in the image, the removed area will be filled with background. 

( it may be similar to interpolation but different approach. )

https://www.google.co.kr/search?q=inpainting&newwindow=1&biw=1297&bih=826&source=lnms&tbm=isch&sa=X&ei=f7e9VPeXApbh8AXonYHgDA&ved=0CAYQ_AUoAQ



<Image Restoration>

Median filtering: it's for removing noise. you can use various filters. Using small size filter serveral times will be better than using large size filter. 

( keeping the shape, it removes unnecessary noise. )

주변의 중간값으로 대체.


Bilateral filtering: Domain + Range

edge가 상대적으로 보존됨

가중치가 적용된다. Domain은 거리에 비례해서 가중치 계산됨

Range는 Color 또한 적용되어 가중치 계산됨. 즉, color가 크게 다르면 가중치 작아짐????

if the center pixel is close to neighbor pixels, 가중치 is higher. 



가우시안.. x, y, 거리에 따라 가중치 반비례됨


edge방향과 같게 sample 영역을 잡아서 평균값 구하는 것이 좋다. 

(sample영역이 마냥 커지면 역효과 발생할수도.)


texture가 복잡할 경우에는 일반적으로 noise없음. 괜하게 노력할필요 없음. 


<deblurring>

High pass filter(high frequency 영역에서 처리): enhancement. 이것만으로 안되기에 deblurring 필요

it's kind of searching for blur kernel. 


초점이 맞지 않을때: aussian blur kernel 사용

카메라 손떨림등 있을때: motion blur kernel 사용


deblurring할때 초점이슈가 아닌 motion blurring일때 restoration이 더 쉽다. 


interse filtering

=>

g = H * f + n (*는 2차원의 convolution 연산의미함)

n(noise)는 요즘 카메라에서 무시할 수 있음

이것을 선형신호??? 로 변환하면

G(w) = H x f

f = (1/H) x G(w)

아날로그 환경에서 1/H적용하여 f를 얻을 수 있다???

(noise가 없다는 가정이 깨지면 error발생)



즉, 요지는 blur kernel 을 가지고 있고 blurred image를 가지고 있으면 restoration이 가능하다.


<OpenCV exercise>



1. unsigned char : 0 ~ 255까지 사용

srcImg의 가로변은 4의 배수이기에 아래처럼 widthStep사용해서 y만큼 내려온다. srcImg는 R, G, B각각의 unsigned char로 저장

B = (unsigned char)srcImg->imageData[srcImg->widthStep*y + 3 * x + 0];


H는 색상정보

V는 밝기

S는 채도


2.


IplImage *srcImg = cvLoadImage("lena.bmp", 1);

IplImage *hsvImg = cvCreateImage(cvGetSize(srcImg), 8, 3); // RGB 3색 사용

IplImage *onechImg = cvCreateImage(cvGetSize(srcImg), 8, 1); // 한가지 색만 사용

IplImage *equalImg = cvCreateImage(cvGetSize(srcImg), 8, 1);

IplImage *dstImg = cvCreateImage(cvGetSize(srcImg), 8, 3);