출처: http://yeobi27.tistory.com/entry/DIP-%EC%98%81%EC%83%81%EC%B2%98%EB%A6%AC-%EA%B4%80%EB%A0%A8-%EC%82%AC%EC%9D%B4%ED%8A%B8-%EC%A0%95%EB%A6%AC

아래는 영상처리 공부하면서 자료를 찾게된 사이트 주소들입니다.
혹시 링크에 무언가... 문제 있으면 연락주세요. 
※ [X] 는 추후 확인된 링크가 깨진 주소입니다.


인공지능에 나오는 수학 (last: 2013-12-19)

유사계수

 


대수학 기초

 


 

리틀엔디안,빅엔디안

Digital Image Processing 3/E [Gonzalez]:
2장 Digital Image Fundamentals

3장 Intensity Transformations and Spatial Filtering

4장 Filtering in the Frequency Domain

5장 Image Restoration and Reconstruction

6장 Color Image Processing

7장 Wavelets and Multiresolution Processing

8장 Image Compression
DCT
JPEG개요
JPEG개요 [ppt]
신라대멀티미디어강의 [ppt]
영상압축표준 [pdf]
MPEG B-frame
Inter frame [wiki]
영상압축의 원리-spatial redundancy
DPCM과 DM 설명
Lloyd-Max 양자화 [강원대, ppt]
손실압축기술 [한밭대, pdf]
RMSE(Root Mean Square Error)

9장 Morphological Image Processing

Convex Hull, Concave Hull 

Convex Hull - 그레이엄 scan 알고리즘

Convex Hull - Gift wrapping 

Hit or Miss Transform

Hit or Miss Transform [pdf]

Thining 

문자 인식을 위한 Thining 알고리즘 

세선화[ppt] 

Morphological Reconstruction

 

10장 Image Segmentation

Edge Detection

The Marr-Hildreth edge detector [pdf]

Theory of Edge Detection - Marr-Hildreth 논문 [pdf]

비극대 억제(nonmaxima suppression) [pdf, 41 page]

Edge Normal

Canny Edge detect - nonmaxima suppression [★★★]

Canny Edge Detector

hysteresis thresholding

Local Edge Linking Methods

Local Processing Methods [pdf]

Open and Closed Curves 

Boundary Detection [ppt] 

최소제곱법이해하기 [★★★★★]

Otsu 이진화

Otsu 이진화 [★★★]

Bayes' formula [★★★★★]

Bayesian theorem [★★]

Moving Averages 

군집분석

마할라노비스의 거리

Region Splitting and Merging

Watershed (Image processing) [wikipedia]

영상 분할을 위한 효과적인 영역 병합 방법

객체 투영을 이용한 비디오객체 추적 알고리즘

Accumulative Difference Image [dip]

 

11장 Representation and Description 

Freeman Chain Codes

자동차 번호 인식을 위한 freeman code 응용

determinant 개념 [지식인, ★★★] 

Medial axis transformation

Moments [pdf]

Region Descriptor [ppt]

동시발생매트릭스(Co-Occurrence matrix)

Hu의 불변 모멘트

Mean vector and Covariance matrices [★★★]

주성분분석(Principal Component Analysis) [wiki]

Principal Components Analysis tutorial - 1 [pdf, ★★★★★]

PCA using R - 라면맛 분석[★★★]

Principal Components Analysis tutorial - 2 [pdf, ★★]

layman's PCA [youtube, ★★]

기대값, Expectation [wiki]

pca 참고 [cafe]

pca 수업

pca 한글 예제 [★]

푸딩 이야기 - 4(얼굴인식)

 

12장 Object Recognition

MLP(Multi-Layer Perceptron [★★★]


Posted by 모과이IT
,

논문 쓸때 주의할점

2010/01/23 04:32 Develop

논문을 쓰다가. 한번씩 생각한다.
선배들은 과연 어떻게 쓰는 것일까 하고...
나름대로의 생각을 정리해볼까 한다. 그리고 업데이트 되는 내용들은 계속 추가 하도록 한다.


논문을 쓸 때 주의할점

1. 용어에 대한 설명이 있어야 한다.

새로운 용어를 만들지말자.

기존에 사용하는 용어를 사용하자.

(인터랙션바(interaction Bar) -> 적외선 LED바(IR-LED Bar) )

 

2. 외래어의 사용을 줄이고 한글로 순화 시켜라.

한글논문에 외래어를 자주 사용하지 말자.

(인터랙션 -> 상호작용)

 

3. 서론/결론 주장하고자하는 내용에 대해서 명확히 하자.

초/중/결을 확실하게 하도록 하자

논문에서 주장하고자 하는 내용 ‘포커스’를 결정하고 맞추도록 하자.

 

4. 제목은 !

본문의 내용을 줄인, 서론의 내용을 줄인, 요약의 내용을 줄인 함축적인 문장이다.

 

5. 참조논문과 인용번호

참조한 본문의 내용을 적되, 인용부호를 삽입하여 신뢰성을 올리도록 하자.

 

6. 최근동향 논문

최근에 만들어진 프로젝트를 찾아, 기존논문과 현재논문의 차이를 적어라.

 

7. 말투

과거형, 높임말 사용금지

 

8. 논문의 여백

- 이미지의 배치로 인한 공백 문제는 곧 돈낭비이다.

이미지의 배치를 달리하여서 최대한 여백이 없도록 하자.

 

9. 카테고리

대단원은 1~5, 소단원은 1~3 까지만 가도록 하자

 

10. 이미지 & 표

그림과, 표에 각각 숫자를 표시하고 설명을 적자.

 

11. 요약

요약은 서론의 내용을 축약하고 축약해서 작성한다.

서론의 내용을 그대로 작성하지 않는다.

 

12. 여러 가지 개념을 사용하지말고, 통일된 단어를 사용하자.

 

13. 글의 내용이 매끄럽게 이어지도록 작성한다.


14. 수식

1. 수식에 대한 의미, 본 논문에서 어떤 부분을 설명하는지 체크한다.
2. 레퍼런스를 찾아가서 본래의 듯을 살펴 보자.


'전공지식창고 > 논문' 카테고리의 다른 글

석사 학위 논문에 대한 교수님 조언  (0) 2014.02.18
논문 일지 #2(논문 주제 선정 초안)  (0) 2014.02.18
논문 일지 #1  (0) 2013.12.29
논문 작성법  (0) 2013.12.29
학윈논문 작성법  (0) 2013.11.27
Posted by 모과이IT
,

출처 : http://www.aishack.in/2010/03/the-hough-transform/

(허프 번환에 대해서 제일 정리가 잘된거 같아 링크함)


The Hough transform is an incredible tool that lets you identify lines. Not just lines, but other shapes as well. In this article, I’ll talk about the mechanics behind the Hough transform. It will involve a bit of math, but just elementary concepts you learned in school.

In this article, we’ll work with lines only, though the technique can be easily extended to other shapes.

Why the Hough Transform?

Lets say you take the snapshot of pole. You figure out edge pixels (using the Canny edge detector, the Sobel edge detector, or any other thing). Now you want a geometrical representation of the pole’s edge.You want to know its slope, its intercept, etc. But right now the “edge” is just a sequence of pixels.

You can loop through all pixels, and some how figure out the slope and intercept. But that is one difficult task. Images are never perfect.

So you want some mechanism that give more weightage to pixels that are already in a line. This is exactly what the Hough Transform does.

It lets each point on the image “vote”. And because of the mathematical properties of the transform, this “voting” allows us to figure out prominent lines in the image.

From lines to points

A lines is a collection of points. And managing a collection of points is tougher than managing a single point. Obviously. So the first thing we learn is how to represent a line as a single point, without losing any information about it.

This is done through the m-c space.




As shown in the above picture, every line has two quantities associated with it, the slope and the intercept. With these two numbers, you can describe a line completely.

So the parameter space, or the mc space was devised. Every line in the xy space is equivalent to a single point in the mc space. Neat eh?

From points to lines

Now onto the next step. Consider a point (say, (xa, ya) )in the xy space. What would its representation in the mc space be?

For starters, you could guess that infinite lines pass through a point. So, for every line passing through (xa, ya), there would be a point in the mc space.

And you’re correct there, because of the following:

  1. Any line passing through (xa, ya): ya = mxa + c
  2. Rearranging: c = – xam + ya
  3. The above is the equation of a line in the mc space.

So, a point in the xy space is equivalent to a line in the mc space.




How does this help us?

The Hough transform is all about doing what we just learned: converting points in the xy space to lines in the mc space.

You taken an edge detected image, and for every point that is non black, you draw lines in the mc place. Obviously, some lines will intersect. These intersections mark are the parameters of the line.

The following picture will clarify the idea:




The points 1, 2, 3, and 4 are represented as various lines in the mc space. And the intersection of these lines is equivalent to the original line.

Great!

Now you know the basic idea of how the Hough transform works. But there’s one big flaw in the We’ll discuss how to resolve this issue in the next article.

Posted by 모과이IT
,

// moguwai1. 부분스크린샷//

Rect rect(248,373,40,60);

Mat subimage=undistortedThreshed(rect);


// reSize

resize(subimage,subimage,Size(200,200));

// (src,dst,size)


// FileSave

imwrite("pic0.png", subimage);; //Show image

Posted by 모과이IT
,

출처 : http://kimhj8574.egloos.com/4734597


*** IplImage 관련,  생성과 해제 등
//생성
IplImage *srcimg_R  = NULL;
srcimg_R  = cvCreateImage(cvSize(m_width,m_height), 8, 3);   //cvSize(640,480) 같은 것도 됨
srcimg_R  = cvCreateImage(cvGetSize(src_color), 8,3);  //요것도 됨.  다른 IplImage 사이즈 받아와서

//요런것도 됨
CvSize img_size;   
img_size.height = ImageHeight;
img_size.width  = ImageWidth;

IplImage* BGR_image = cvCreateImage(img_size, IPL_DEPTH_8U, 3); 

//이미지 복사하기
src = cvCloneImage(src_img);  //src가 비어있어야 함.  아니면 메모리 계속 쌓인다
cvCopy(src_img, src_img2);

//컬러 이미지 각 소스별로 분리하거나 합치거나 할 때
cvCvtPixToPlane( src_hlsimg, Hue, Intensity, Saturation, NULL );  //HLS 이미지 각 속성별로 나눔
cvCvtPlaneToPix( Hue, Intensity, Saturation, NULL, Equ_hls );  //다시 합친다

//0으로 초기화
cvZero(src_img);

//해제
if(srcimg_R)
  cvReleaseImage(&srcimg_R);




*** IplImage의 ROI 설정하기
//설정한 ROI 부분을 전체 이미지 인 것처럼 다룬다
//cvSetImageROI( IplImage* img, CvRect rect )
//rect는 순서대로 ROI의 왼쪽 위점의 좌표(offset), ROI의 width, height이다.

cvSetImageROI(src, cvRect(CenterX-ROI_width/2, CenterY-ROI_height/2, ROI_width, ROI_height));

//설정한 ROI 해제하기
cvResetImageROI( IplImage* img );

if(inputimg->roi != 0x00)  //ROI가 설정되어 있다면

inputimg->roi->width  //ROI의 속성 접근하기
inputimg->roi->height...

//특징
// - Haar 등에 ROI 지정해서 넣으면 그 안쪽에서만 연산(마치 ROI가 전체이미지인듯)
// - cvSvaeImage 등을 수행하면 ROI 안쪽만 저장된다.  cvResize 등도 마찬가지





*** IplImage 안의 이미지 화소 조절하기

...
cvGetReal2D(srcimg, i, j);             //높이가 i, 폭이 j
cvSetReal2D(srcimg, i, j, value);    //value는 설정할 값
...




*** 이미지 불러오기, 저장하기
//불러오기
TmpLImg = cvLoadImage("img_InElevator_1_L.bmp");    //간단하게, TmpLImg는 IplImage
//복잡하게
if ((TmpLImg = cvLoadImage("img_InElevator_1_L.bmp")) == 0)  // load left image
{
   printf("%s", "left image file read has failed!! \n");
   return 0;
}

//저장하기
char file_name[20];
sprintf(file_name,"img_R.bmp");            //파일이름 맹글기
cvSaveImage(file_name,srcimg_R);   //srcimg_R 이라는 IplImage를 저장 




***이미지 위아래나 좌우 뒤집기, 반전
cvFlip(src, dst, 0);   //0은 수직방향 반전, 1은 수평방향 반전, -1은 양방향 다 반전




*** 캠 입력받기

IplImage *src;       //source 이미지니까 src로 이름지음
//capture for cam
 CvCapture* capture = cvCaptureFromCAM(0);

 //get init scene
 cvGrabFrame(capture);
 src=cvRetrieveFrame(capture);

......
cvGrabFrame(capture);
src=cvRetrieveFrame(capture);
......

cvReleaseCapture( &capture );

//다른 방법
IplImage *src;
CvCapture* capture = cvCaptureFromCAM(0);
cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH,640);    //잘 안됨
cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT,480); 

...
src = cvQueryFrame( capture );.
...




***AVI등 동영상 파일에서 불러오기

//동영상파일로부터받아오기
CvCapture* input_video = 0;
input_video = cvCreateFileCapture( "z4m.avi");

//받아온 프레임 사이즈
CvSize frame_size;
int height =(int) cvGetCaptureProperty( input_video, CV_CAP_PROP_FRAME_HEIGHT );
int width  =(int) cvGetCaptureProperty( input_video, CV_CAP_PROP_FRAME_WIDTH );
int fps     =(int) cvGetCaptureProperty(input_video, CV_CAP_PROP_FPS);
printf("width : %d, height : %d, fps : %d\n", width, height, fps);  

//연산에 사용될 IplImage 구조체
IplImage *src;

if( (src=cvQueryFrame(input_video)) != 0)
{
    printf("file read success!!\n");
}

while(1)
{
    src=cvQueryFrame(input_video); 
}

cvReleaseCapture( &input_video );  //IplImage 메모리 제거는 하지 않는다.(생성도 안했으니)





*** 창 만들고 닫기 등등
//생성
cvNamedWindow("Right Original", CV_WINDOW_AUTOSIZE);

//창 움직이기 - uv 좌표로 배치함
cvMoveWindow("source_color",610,0);

//보이기
cvShowImage( "Right Original", srcimg_R );

//창 닫기
cvDestroyAllWindows();  //모든 OpenCV 윈도우 닫기

//특정 윈도우만 닫기
cvDestroyWindow("Right Original");




*** canny edge detect 사용하기
...
IplImage *canny_R   = NULL;
canny_R    = cvCreateImage(cvSize(m_width,m_height), 8, 1);
...
cvCvtColor(srcimg_R, grayimg_R, CV_BGR2GRAY);   //원본 컬러이미지를 흑백으로 변환하고

cvCanny( grayimg_R, canny_R, 40, 130, 3 );  //그 흑백이미지를 캐니로 변환




*** Harris edge detector
IplImage *harris = cvCreateImage(cvSize(WIDTH,HEIGHT), IPL_DEPTH_32F, 1);
cvCornerHarris(src_gray, harris, 3, 9, 0.07); 


***Smoothing 연산
//Gaussian filtering
cvSmooth(src, Gaussed_image, CV_GAUSSIAN, 3);  //src는 gray영상, 두번째 매개변수도 IplImage임, 3은 마스크 크기

//DoG(Difference of Gaussian)
cvSmooth(src_gray, GaussImg1, CV_GAUSSIAN, 3);
cvSmooth(src_gray, GaussImg2, CV_GAUSSIAN, 27);
cvSub(GaussImg1, GaussImg2, dst);






*** HLS 이미지로 변환하기
...
IplImage* src_hlsimg = cvCreateImage(cvSize(m_width,m_height), 8, 3);  //HLS 저장할 곳
//각 속성들 저장할 곳 선언
IplImage* Hue         = cvCreateImage(cvSize(m_width,m_height), 8, 1);
IplImage* Intensity   = cvCreateImage(cvSize(m_width,m_height), 8, 1);
IplImage* Saturation = cvCreateImage(cvSize(m_width,m_height), 8, 1);

cvCvtColor(srcimg, src_hlsimg, CV_BGR2HLS);   //src_hlsimg IplImage 구조체에 HLS 이미지 담긴다
cvCvtPixToPlane( src_hlsimg, Hue, Intensity, Saturation, NULL );  //HLS 이미지 각 속성별로 나눔
cvCvtPlaneToPix( Hue, Intensity, Saturation, NULL, hsvVideo2 );  //도로 합치기




*** 모폴로지 연산 Morphology

IplConvKernel* kernel;

kernel= cvCreateStructuringElementEx( 3, 3, 0, 0, CV_SHAPE_RECT, NULL );

cvMorphologyEx( temp_eyeimg, temp_eyeimg, NULL,kernel, CV_MOP_CLOSE , 1 );







*** 창으로 부터 키 입력 받기
...
pressed_key=cvWaitKey(0) ;
  if(pressed_key=='q')    //q 키가 누르면 빠져나가기
    break;
  else if(pressed_key=='c')  //캡쳐 키 누르면 캡쳐
  {
    timer=time(NULL);  //현재시간저장
    t=localtime(&timer); //지역시간
    sprintf(file_name,"img_%4d%02d%02d%02d%02d%2d.bmp",t->tm_year + 1900, t->tm_mon +1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec); //파일이름 맹글기

    cvSaveImage(file_name, src_color);

    //확인메시지출력
    printf("%s file saved is success!!\n",file_name);
  }




*** 이미지 크기 줄이기

//생성
pEviMonitor = cvCreateImage(cvSize(m_pImgWidth, m_pImgHeight), IPL_DEPTH_8U, 1);
pEviMonitor2 = cvCreateImage(cvSize(m_pImgWidth/2, m_pImgHeight/2), IPL_DEPTH_8U, 1);  //  1/2 크기로 생성

//크기 줄이기
cvResize(pEviMonitor, pEviMonitor2, CV_INTER_LINEAR);  // For Resize




*** 화면에 글자 쓰기

char s_output_result[50];
CvFont font;
...
sprintf(s_output_result,"sum vector x:%1.3f  y:%1.3f",sumvector_x,sumvector_y );    //우선 sprintf로 문자열 생성
cvInitFont(&font, CV_FONT_HERSHEY_SIMPLEX|CV_FONT_ITALIC, 0.5, 0.5, 0, 1);  //이런 저런 설정.
cvPutText(src_color, s_output_result ,cvPoint(15,20),&font,cvScalar(0,255,0));   //cvPoint로 글자 시작 위치 설정(uv)
//void cvInitFont(CvFont* font, int font_face, double hscale, double vscale, double italic_scale, int thickness)




*** 트랙바 생성

int hue_threshold=139;  //Hue 값의 피부색 threshold

cvNamedWindow( "HLS_image", CV_WINDOW_AUTOSIZE );
cvCreateTrackbar("Hue","HLS_image",&hue_threshold,255, NULL );  //중요한 부분은 요거




*** 마우스 입력

void on_mouse( int event, int x, int y, int flags, void* param );
......

cvSetMouseCallback( "LKTracker", on_mouse, NULL );
......

void on_mouse( int event, int x, int y, int flags, void* param )
{
    if( !image )
        return;

    if( image->origin )
        y = image->height - y;

    if( event == CV_EVENT_LBUTTONDOWN )
    {
        pt = cvPoint(x,y);
        add_remove_pt = 1;
    }
}




*** 인클루드 하는 것들

#include <cv.h>          //영상처리를 위한 헤더
#include <highgui.h>   //카메라로 영상을 입력받거나 이미지를 읽어들이고 화면에 보여주기 위한 헤더




*** good feature to track

IplImage *eig_image = NULL; 
IplImage *temp_image = NULL; 
eig_image  = cvCreateImage(cvSize(width,height), 32, 1);
temp_image = cvCreateImage(cvSize(width,height), 32, 1);

CvPoint2D32f frame1_features[4000];  //추출된 점들 저장하는 장소

int number_of_features; 
number_of_features = 400;  //추출되는 점의 개수를 제한

//안됨.  버전마다 매개변수 다른듯
//cvGoodFeaturesToTrack(src_gray, eig_image, temp_image, frame1_features, &number_of_features, .01, .01, NULL);

cvGoodFeaturesToTrack(src_gray, eig_image, temp_image, frame1_features, &number_of_features, 0.01, 5, 0, 3, 0, 0.04 );
//&number_of_features 로 추출된 점의 개수 나온다.  추출되는 점의 개수를 입력으로 제한함과 동시에 출력도...

//draw
for(int i=0; i<number_of_features; ++i) 
    cvCircle( result_img, cvPointFrom32f(frame1_features[i]), 1, CV_RGB(255,0,0), 3, 8, 0);





*** Line Fitting  (polar 코디네이트가 아니라 단점 있음)

int count = 0;        // total number of points   
float *line;     
 
CvPoint  left, right;    

//CvMat point_mat = cvMat( 1, count, CV_32SC2, mid_points );     
//cvFitLine( &point_mat, CV_DIST_L2 , 0, // line[0]:vector_x, line[1]:vector_y                
// 0.01, 0.01,  line );        // line[2]:x_n, line[3]:y_n     
//
long double a, b, c, d, e, f; 
////b가 기울기, a가 절편 
//b = line[1]/ line[0];        
//a = line[3]- b*line[2];        
b=((float)right.y-(float)left.y)/((float)right.x-(float)right.y);

//left.x=mid_points[0].x;
//left.y=b*left.x+a;

//right.x=mid_points[count-1].x;
//right.y=b*right.x+a;

//CvPoint center;     
//center.x = line[2];     
//center.y = line[3];     // can draw from left to right directly     
//cvLine( processed_image, center, left, CV_RGB(255,255,255), 1, 8 );     
cvLine( Draw_results, left, right, CV_RGB(255,0,0), 1, 8 );     




*** Mean-Shift Segmentation

//입출력 IplImage, spatial과 color radius 매개변수, level of scale pyramid(2 또는 3 적당) 
cvPyrMeanShiftFiltering(src_color, src_result, 2, 40, 3);




*** 체스보드 마크 탐지하기

int i;
int nCornerNum = 3 * 3; // number of corners in the chessboard (3 * 3)
int MAX_COUNT = nCornerNum;   // 5000

CvSize pattern_size = cvSize( COL_CHESS_CORNER_NUM, ROW_CHESS_CORNER_NUM );

 
CvPoint2D32f *left_corners = new CvPoint2D32f[nCornerNum];
CvPoint2D32f *right_corners = new CvPoint2D32f[nCornerNum];

int iLeft_corner_count, iRight_corner_count;
 
// Get the number of left and right corners
int iFoundLeft  = cvFindChessboardCorners(pLeftImg, pattern_size, left_corners, &iLeft_corner_count, CV_CALIB_CB_ADAPTIVE_THRESH);
int iFoundRight = cvFindChessboardCorners(pRightImg, pattern_size, right_corners, &iRight_corner_count, CV_CALIB_CB_ADAPTIVE_THRESH);
//////////////////////////////////////////////////////////////////////////

//printf("\n--------------  Marker Results -----------------------------\n");
//printf("Number of Left Corners: %d\n", iLeft_corner_count);

cvDrawChessboardCorners(pLeftImg, pattern_size, left_corners, iLeft_corner_count, iFoundLeft);
cvDrawChessboardCorners(pRightImg, pattern_size, right_corners, iRight_corner_count, iFoundRight);
 /-
 for (i = 0; i < iLeft_corner_count; i++)
 {   
  DrawCorner(pLeftImg, cvPointFrom32f(left_corners[i]));
  //printf("(%d,%d)\t", cvPointFrom32f(left_corners[i]).x, cvPointFrom32f(left_corners[i]).y);
 }
 *-

 //printf("\nNumber of right Corners: %d\n", iRight_corner_count);
 //for(i=0; i<iRight_corner_count; i++)
 //{
 // DrawCorner(pRightImg, cvPointFrom32f(right_corners[i]));
 // //printf("(%d,%d)\t", cvPointFrom32f(right_corners[i]).x, cvPointFrom32f(right_corners[i]).y);
 //}

float *plane = new float[4]; // return value
for (i=0; i<4; i++)    // Initialization, even though the plane equation is wrong 
{
    plane[i] = 1;  
}
 
// Calculate the plane equation based on the chessboard
if( iLeft_corner_count == iRight_corner_count && iLeft_corner_count == nCornerNum) // Left Corners and right corners should be same
{
    CvPoint *leftPoints = new CvPoint[nCornerNum];
    CvPoint *rightPoints = new CvPoint[nCornerNum];
    for(i=0; i<nCornerNum; i++)
    {
        leftPoints[i] = cvPointFrom32f(left_corners[i]);
        rightPoints[i] = cvPointFrom32f(right_corners[i]);
    }
  
    plane = planeEquationfrom2DPoints(leftPoints, rightPoints, nCornerNum, baseLine, focal, u0, v0);

    // output the plane equation result
    printf("\n-------------------------  Plane Equation ------------------------\n");
    for(i=0; i<4; i++)
    {
        printf("%.4f\t", plane[i]);
    }
    printf("\n");
    //----------------------------------------------------------

    delete [] leftPoints;
    delete [] rightPoints;
}
else
    printf("No Enough Corners For Marker \n");  // should modify

//if (left_corners)
// cvFree(&left_corners);
//if (right_corners)
// cvFree(&right_corners);
 
if (left_corners)
    delete [] left_corners;
if (right_corners)
    delete [] right_corners;
return plane;





*** 히스토그램 관련
CvHistogram* hist;
float min_value, max_value;  //히스토그램 최대값 최소값 저장용
int hist_size = 255;  //히스토그램 축들 개수

 

hist = cvCreateHist( 1, &hist_size, CV_HIST_UNIFORM); //1차원의, 각 속성 크기 hist_size인 히스토그램생성
cvCalcHist( &Hue, hist, 0, 0);                                       //Hue가 1차원 IplImage -> 실질적 입력
cvGetMinMaxHistValue(hist, &min_value, &max_value, 0, 0);   //히스토그램 최소최대값 얻기, 최대최소값의 위치
printf("hist min max:%f  %f\n",min_value, max_value);
cvZero(Hue_hist);


int axis_base = 210;  //그릴 때, 아래 축이 어느정도에 위치하는가
CvFont font;  //축에 글자 쓰기용
cvInitFont(&font, CV_FONT_HERSHEY_SIMPLEX|CV_FONT_ITALIC, 0.3, 0.3, 0, 1);
char text[50];


for ( int i = 0; i < 255; ++i)
{
    int hist_value = cvRoundcvQueryHistValue_1D(hist,i)*255/max_value);  //히스토그램 값 normalization
    cvLine(Hue_hist, cvPoint(i+20, axis_base), cvPoint(i+20, abs(axis_base - hist_value) ), CV_RGB(255,255,255), 1);

    if ( (i % 20) == 0 )
    {
        sprintf( text, "%d", i);
        cvPutText( Hue_hist, text, cvPoint(i+20, axis_base+10), &font, CV_RGB(255,255,255));    
    }
}
if(hist)   //히스토그램 제거
    
cvReleaseHist(&hist);






*** 히스토그램 평활화 (histogram equalization)

IplImage* Src          = cvCreateImage(cvSize(width,height), 8, 1);   //원본 이미지
IplImage* Equalized = cvCreateImage(cvSize(width,height), 8, 1);   //평활화 된 이미지
cvEqualizeHist( Src, Equalized );





*** 이미지 회전시키기
CvPoint2D32f rot_center = cvPoint2D32f(ROI_width/2 , ROI_height/2);//회전중심설정// 그에 따른 매트릭스 만들기
CvMat *rot_mat = cvCreateMat( 2, 3, CV_32FC1);
//매트릭스 계산 
cv2DRotationMatrix( 
    rot_center, // Source Image의 센터를 정한다.
    Rotation_Angle,  // 이것은 각도 + 값은 시계 반대 반대 방향을 의미한다.
    1,  // 이미지 크기(scale)... 
    rot_mat); // 결과를 저장하는 매트릭스 이다.
   
//원본 이미지에 ROI 적용하기
cvSetImageROI(src, cvRect(CenterX-ROI_width/2, CenterY-ROI_height/2, CenterX+ROI_width/2, CenterY+ROI_height/2));
//변환하기
cvWarpAffine(src, 
                dst, 
                rot_mat, 
                CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS,
                cvScalarAll(0)); // 선형보간




*** OpenCV 외 유용한 코드들

//파일에서 불러오기
char buffer[BUFFERSIZE], * temp, * label, ct [] = " ,\t\n";    //BUFFERSIZE = 1024
static int filenum = 0;

FILE *fp = fopen(".\img.txt", "r");

if(fp == NULL) 
    return false;
while (fgets(buffer,BUFFERSIZE,fp))
{
    label = strtok(buffer,ct);
    if(label == NULL) 
        continue;
    pDPT[p_index*NUMOFDIMESION] =  (float)atof(label);
    pDPT[p_index*NUMOFDIMESION + 1] = (float)atof(strtok(NULL,ct));
    pDPT[p_index*NUMOFDIMESION + 2] = (float)atof(strtok(NULL,ct));
    pBGR[c_index*NUMOFDIMESION] = (unsigned char)atoi(strtok(NULL,ct));
    pBGR[c_index*NUMOFDIMESION +1] = (unsigned char)atoi(strtok(NULL,ct));
    pBGR[c_index*NUMOFDIMESION +2] = (unsigned char)atoi(strtok(NULL,ct));
    pGray[c_index] = pBGR[c_index*NUMOFDIMESION];
    strtok(NULL,ct);
    strtok(NULL,ct);
    temp = strtok(NULL,ct);
    if(atoi(&temp[1]) <= 0)
    {
        // zero disparity or invalid 3D point
        pDPT[p_index*NUMOFDIMESION] =  INVALID_DEPTH_INFO;
        pDPT[p_index*NUMOFDIMESION + 1] = INVALID_DEPTH_INFO;
        pDPT[p_index*NUMOFDIMESION + 2] = INVALID_DEPTH_INFO;
    }
    p_index++;
    c_index++;
}fclose(fp);

//조금 다른 예, 다른 문자로 어떤 정보인지 표시된거
//3DM 파일 읽어들이기

while (fgets(buffer,2000,fp))
{
    label = strtok(buffer,ct);
    if(label == NULL) continue;
    if(!strcmp("ImageWidth",label))
    {
        m_imagewidth = atoi(strtok(NULL,ct));///samplingratio;
    }
    else if(!strcmp("ImageHeight",label))
    {
        m_imageheight = atoi(strtok(NULL,ct));///samplingratio;
    }  
    else if(!strcmp("F",label))
    {
        double x,y;
        double x3,y3,z3;
        x  = atof(strtok(NULL,ct));
        y  = atof(strtok(NULL,ct));
        idx3DSIFT.push_back(m_imagewidth * (int)y + (int)x);
        x3  = (double)atof(strtok(NULL,ct));
        y3  = (double)atof(strtok(NULL,ct)); 
        z3  = (double)atof(strtok(NULL,ct));
        x3DPoints.push_back((float)x3);
        y3DPoints.push_back((float)y3);
        z3DPoints.push_back((float)z3);
    } 
}
fclose(fp);

//또 조금 다른 예
while (fgets(buffer,2000,fp))
{
    label = strtok(buffer,ct);
    if(label == NULL) continue;
    if(!strcmp("ImageWidth",label))
    {
        m_imagewidth = atoi(strtok(NULL,ct));///samplingratio;
    }
    else if(!strcmp("ImageHeight",label))
    {
        m_imageheight = atoi(strtok(NULL,ct));///samplingratio;
    } 
    else if(!strcmp("F",label))
    {
        double x,y;
        double x3,y3,z3;
        x  = atof(strtok(NULL,ct));
        y  = atof(strtok(NULL,ct));
        idx3DSIFT.push_back(m_imagewidth * (int)y + (int)x);
        x3  = (double)atof(strtok(NULL,ct));
        y3  = (double)atof(strtok(NULL,ct)); 
        z3  = (double)atof(strtok(NULL,ct));
        x3DPoints.push_back((float)x3);
        y3DPoints.push_back((float)y3);
        z3DPoints.push_back((float)z3);
    } 
}
fclose(fp);



//3D만 가져올 때
char buffer[1024];
char *label;
char ct [] = " ,\t\n";
int index=0;
FILE *fp = fopen(".\img.txt", "r");

if(fp == NULL) 
    return;

while (fgets(buffer,1024,fp))
 {
  label = strtok(buffer,ct);
  if(label == NULL) 
   continue;
  p_3Dpt[index*3    ] = (float)atof(label);
  p_3Dpt[index*3 + 1] = (float)atof(strtok(NULL,ct));
  p_3Dpt[index*3 + 2] = (float)atof(strtok(NULL,ct));
  index++;
  if(index>=307200)
   break;
 }

fclose(fp);



//메모리, 용량 절약형 가져올 때
FILE *fp;
fp = fopen(file_name,"rt");

if(!fp)
{
  printf("\ncan not open 3dmfile\n");
  return false;
}

while (fgets(buffer,2000,fp))
{
  label = strtok(buffer,ct

  if(label == NULL) continue

  if(!strcmp("ImageWidth",label))
  {
    //m_imagewidth = atoi(strtok(NULL,ct));///samplingratio;
  }
  else if(!strcmp("ImageHeight",label))
  {
    //m_imageheight = atoi(strtok(NULL,ct));///samplingratio;
  } 
  else if(!strcmp("F",label))
  {
    double x,y;
    double x3,y3,z3;
    x  = atof(strtok(NULL,ct));
    y  = atof(strtok(NULL,ct));
    
    x3  = (double)atof(strtok(NULL,ct));
    y3  =  (double)atof(strtok(NULL,ct)); 
    z3  = (double)atof(strtok(NULL,ct));
    m_p3Dpt[3*(GetWidth() * (int)y + (int)x)  ] = x3;
    m_p3Dpt[3*(GetWidth() * (int)y + (int)x)+1] = y3;
    m_p3Dpt[3*(GetWidth() * (int)y + (int)x)+2] = z3;
    //y3  = -(double)atof(strtok(NULL,ct));
    // SVS ver 3.2 used mm scale
    //x3DPoints.push_back((float)x3*scale);
    //y3DPoints.push_back((float)y3*scale);
    //z3DPoints.push_back((float)z3*scale);
    // SVS ver 4.4 use m scale (model is saved by using m scale)
    //x3DPoints.push_back((float)x3);
    //y3DPoints.push_back((float)y3);
    //z3DPoints.push_back((float)z3);
    //if(idxDB == WCCup) printf("\nx=%f,\ty=%f,\tz=%f",x3,y3,z3);
  } 
}
fclose(fp);



//파일로 저장하기
FILE *fp = fopen("@@_FilterResult.txt", "at+");
fprintf(fp, "%d %f\n", nFrameNum, pEstimatedObjectPose[11]);
fclose(fp);

//메모리 카피
memcpy(src_color->imageData, m_pColorImage, sizeof(unsigned char)*width*height*3); 

//3D를 2D로 그리기 (대충)
for(int i=0;i<width;++i)
{
    for(int j=0;j<height;++j)
    {
        if((m_p3Dpt[3*(i+width*j)+2]>0.5)&(m_p3Dpt[3*(i+width*j)+2]<2.0))
            view_3D->imageData[i+width*j]=((m_p3Dpt[3*(i+width*j)+2]-0.5)/1.5)*255;
        else
            view_3D->imageData[i+width*j]=0;
    }}


//디버그 못하는 상황에서 파일로 쓰기, mfc나 wxwidgets 써서 printf 못쓸때 유용
{
  FILE *fp = fopen("#print.txt", "at+");
  fprintf(fp, "%d, a:%2.2f\n", i,spPlanes[i].planeparameter[0]);
  fclose(fp);
}





*** GUI 그리는거 관련
cvRectangle( temp_eyeimg, cvPoint(minX1,minY1), cvPoint(maxX1,maxY1), brightness ,1,8,0);
cvLine( Draw_results, left, right, CV_RGB(255,0,0), 1, 8 );     //8은 8connected, 4는 4connected
cvCircle( forDisplay, pt1, 1, CV_RGB(255,0,0), 1, 8, 0);

Posted by 모과이IT
,

IPL 아키텍처의 중요한 개념으로 ROI( region of interest ) 가 있습니다. 모든 것의 영상 처리함수는 영상 전체뿐 아니라 영상의 일부를 대상으로 해서 실행 시킬 수도 있습니다.

  실행하고 싶은 처리에 따라서, 아래의 영역설정을 할 수 있습니다.

 

COI( Channel of interest )

COI로서 영상으로 주어질 수 있는 1개, 또는 모든 채널을 설정할 수 있습니다. 디폴트에서는 영상의 모든 채널이 처리 대상이다.

 

IplROI 구조체

 

typedef struct _IplROI{

  unsigned int coi;

  int xOffset;

  int yOffset;

  int width;

  int height;

}IplROI;

 

인수

coi : channel of interest

      0이라면 모든 채널이 처리대상이 된다.

xOffset,yOffset : ROI를 나타내는 장방형의 위치를 표시하는 offset

width, height : ROI를 나타내는 장방형의 크기

Posted by 모과이IT
,

출처 : http://devmonster.tistory.com/12


1. OpenCV 다운로드

http://sourceforge.net/projects/opencvlibrary/

위의 URL로 접속하여 Download 받는다.

(현재 최신버전은 OpenCV 2.4.8이다.)

경로는 편리한 곳으로 설정하고 Extract


설치가 종료되면 아래와 같은 다운로드 창이 사라진다.


원하는 경로에 [opencv]라는 폴더가 생성된 것을 알 수 있다.


2. [컴퓨터][속성]→[고급 시스템 설정]→[환경 변수]→[새로만들기]


3. 새 시스템 변수 등록

변수 이름(N):  OPENCV_BUILD

변수 값(V):     C:\opencv\build


4. Path 등록

변수 값(V):     ;%OPENCV_BUILD%\x86\vc10\bin;


5. Visual Studio 2010 프로젝트 생성


6. [프로젝트 속성][VC++ 디렉터리]→[포함 디렉터리]→[편집]

C:\opencv\build\include 입력



7. [프로젝트 속성][VC++ 디렉터리]→[라이브러리 디렉터리]→[편집]  

C:\opencv\build\x86\vc10\lib 입력



8. [링커]→[입력]→[추가 종속성]→[편집]

opencv_calib3d248d.lib

opencv_contrib248d.lib

opencv_core248d.lib

opencv_features2d248d.lib

opencv_flann248d.lib

opencv_gpu248d.lib

opencv_highgui248d.lib

opencv_imgproc248d.lib

opencv_legacy248d.lib

opencv_ml248d.lib

opencv_objdetect248d.lib

opencv_ts248d.lib

opencv_video248d.lib

(※ 목록  Ctrl+C,V해서 사용하자!)




Posted by 모과이IT
,

[KNN(K-nearest neighbor) Algorithm]

KKN Algorithm은 기존에 가지고 있는 데이터를 바탕으로 새로운 점을 분류하는 

알고리즘입니다.


예를 통해서 KNN Algorithm 대해서 알아보도록 하겠습니다.


 분류하기





초록색 점을 파란 점이라고 분류 해야 할까요

아니면 빨간 점으로 분류해야 할까요?

KKN 알고리즘은  점을 중심으로 동그라미를 그리고 

 안에 파란 점이 많은지 빨간 점이 많은지 세보는 것입니다.

만약 실선까지 센다고 하면 초록색 점은 빨간색으로 인식될 것이고

점선까지 센다면 파란색으로 인식될 것입니다.


K-nearest neighbor Algorithm에서 K 의미하는 것은  예에서 

점선과 실선의 원주와 같습니다.

즉, K는 범위를 말한다고 할 수 있습니다.

 K 의해 초록색 점이 분류되므로 K 값을 어떻게 정의하느냐는 문제는 중요합니다.

 

 방법이 회귀분석(regression analysis) 에도 이용될  있습니다 

첨부한 엑셀 시트를 보시면 됩니다.


출처 : http://gmpjs.blog.me/110093125375


Posted by 모과이IT
,

비록 구글에서 조금만 검색하면 바로 나오지만, 간단히 메모해 놓습니다. 


OpenCV를 PC에서 개발 환경을 설치해보니까, 비주얼 스튜디오 9, 10 혹은 다른 방법(MinGW)으로 설정해야 하는데, 우분투에서 설치(build)하는 과정에 비해 조금 더 험난(?)하더군요. http://docs.opencv.org/doc/tutorials/introduction/windows_install/windows_install.html 

OpenCV를 그냥 테스트해보는 목적이므로 파이썬으로 해보아도 될 것 같고, 험난한 build과정 없이 바로 쓴다는 것이 장점이네요. 
  • 물론, 파이썬을 모른다면 그거 배우는 시간도 필요하긴 하겠지만... 한번 알아두면 좋을 법한 괜찮은 언어라고 생각하므로^^, 그리고, 헤드퍼스트 파이썬도 있고 괜찮은 책들이 있습니다. 공공 도서관에 가서 비교해보며 찾아보는 것이 좋겠지요.) 
[미리 준비할 사항]
[OpenCV 설치 및 테스트]
  • OpenCV 홈페이지에서 윈도우 버전을 설치(실제로는 그냥 압축 해제더군요.) 합니다. 저는 C:\opencv2.4.2에 위치시켰습니다. 
  • C:\opencv2.4.2\build\python\2.7에 있는 cv2.pyd를 C:\Python27\Lib\site-packages로 복사합니다. 
  • C:\opencv2.4.2\samples\python로 이동해 보면, drawing.py가 있습니다.  
  • 파이썬이 제대로 설치되어 있다면, 마우스로 우측 버튼을 누르면 Edit with IDLE이 있습니다. 
  • 아래 화면과 같이 실행하면 OpenCV를 이용하여 랜덤하게 그림, 글씨 들이 실행됩니다. 
[OpenCV와 Python관련 도서]
  • OpenCV2를 활용한 컴퓨터 비전 프로그래밍 - 관련 책들 중 조금 더 읽기 편하고 내용도 좋은 듯합니다. 
  • Programming Computer Vision with Python, Oreilly - 번역판은 아직 없는 듯하며, 파이썬을 쓴다는 점이 장점. 초보자도 쉽게 따라 할 수 있는 구조로 되어 있으나, 위 책보다 이론적인 설명은 부족합니다. 
  • Learning OpenCV 제대로 배우기 - 읽어볼만합니다.
  •  파이썬 3 프로그래밍 - Head First Python의 번역판과 함께 읽어보면 좋을 듯하네요. 
개인적으로는 글자 인식과 라인 인식, 영상 내 목적물의 이동 등에 관심을 갖고 있습니다. Raspberry PI에 OpenCV를 설치해서 Python으로 돌려보았을 때에는 그렇지 않아도 느린 것을 USB 모니터로 보냈더니 더 느렸는데, 윈도우7(코어2듀오 2.4)에서 실행했더니 꽤 빠른 예제였군요^^ 

조금 더 흥미로운 예제는 얼굴 인식입니다. 우선 python이 실행 path에 들어가 있으면 편할 거 같네요. 명령은 다음과 같이 하면 됩니다. 물론, 노트북 PC에 카메라가 내장되어 있어서, 0 을 넘겼을 때 바로 나오는 것입니다. 

  • 제어판 - 시스템 및 보안 - 시스템 - 고급 시스템 설정 - "환경 변수" - 시스템 변수 - Path의 변수 값에 c:\python27 추가 후,
  • C:\opencv2.4.2\samples\python>python facedetect.py -c c:\opencv2.4.2\data\haarcascades\haarcascade_frontalface_alt.xml 0


Posted by 모과이IT
,


1. Survery가 제일 중요함


2. 구글 스칼라 같은곳에서 인용도(cite)가 많은것 좋은 Reference 이다


3. 논문을 보면 저저가 인용한 참고 문헌에 대한 추적 조사도 중요함

   - 저자, 제목, 출처, Vol.No, Page, Year 의 정보로 검색

   - 어떤 내용인지 요약 정리가 필요함




'전공지식창고 > 논문' 카테고리의 다른 글

논문쓸때 주의할점  (0) 2014.07.04
논문 일지 #2(논문 주제 선정 초안)  (0) 2014.02.18
논문 일지 #1  (0) 2013.12.29
논문 작성법  (0) 2013.12.29
학윈논문 작성법  (0) 2013.11.27
Posted by 모과이IT
,