//////////////////////////////////////////////////////////////////////////
// init
void CImageProcess::LoadBitmapImage1()
{
char *FileName1 = "cam1.jpg";
m_LoadImage1 = cvLoadImage( FileName1, CV_LOAD_IMAGE_UNCHANGED );
m_cvvImage1.CopyOf(m_LoadImage1, 8);
}
void CImageProcess::LoadBitmapImage2()
{
/*
char *FileName2 = "cam2.jpg";
m_LoadImage2 = cvLoadImage( FileName2, CV_LOAD_IMAGE_UNCHANGED );
m_cvvImage2.CopyOf(m_LoadImage2,8);
*/
}
//////////////////////////////////////////////////////////////////////////
int CImageProcess::OnDraw( CDC *pDC )
{
int h1, w1;
int h2, w2;
if( m_cvvImage1.GetImage() || m_cvvImage2.GetImage() )
{
// image1
h1 = m_cvvImage1.Height();
w1 = m_cvvImage1.Width();
CRect rect = CRect(0,0, w1, h1 );
m_cvvImage1.DrawToHDC( pDC->GetSafeHdc(), &rect );
// image2
h2 = m_cvvImage2.Height();
w2 = m_cvvImage2.Width();
CRect rect2 = CRect(0,0, w2, h2);
m_cvvImage2.DrawToHDC( pDC->GetSafeHdc(), &rect );
// 창크키에 맞춘다
//ResizeParentToFit(FALSE);
return TRUE;
}
return FALSE;
}
//////////////////////////////////////////////////////////////////////////
// Image Process
void CImageProcess::Thredhold()
{
m_iThreshold =180;
IplImage *color_image = m_cvvImage1.GetImage();
IplImage *gray_image = cvCreateImage( cvGetSize(color_image), IPL_DEPTH_8U, 1);
IplImage *output_img = cvCreateImage( cvGetSize(color_image), IPL_DEPTH_8U, 1); // 영상초기화 - 이진화를 위한 변수
cvCvtColor(color_image, gray_image, CV_RGB2GRAY);
cvThreshold( gray_image, output_img, m_iThreshold, 255, CV_THRESH_BINARY );
cvCvtPlaneToPix(output_img, output_img, output_img, NULL, color_image);
cvReleaseImage(&gray_image);
cvReleaseImage(&output_img);
/*
IplImage *output_img = cvCreateImage( cvGetSize(m_LoadImage1), IPL_DEPTH_8U, 1); // 영상초기화 - 이진화를 위한 변수
IplImage *input_img = cvCreateImage( cvGetSize(m_LoadImage1), IPL_DEPTH_8U, 1); // 영상초기화 - 영상에서 흑백으로 변환
cvCvtColor(color_image, output_img, CV_RGB2GRAY); // 컬러->흑백
cvThreshold( output_img, input_img, m_iThreshold, 255, CV_THRESH_BINARY ); // 이진화( 입력영상 -> 출력영상)
cvCvtPlaneToPix( input_img, input_img, input_img, NULL, m_LoadImage1 ); // 여러개의 단일 채널을 다채널 배열로 조합! ( image 에 직접적으로 영향을 주는부분(?))
m_cvvImage1.CopyOf( input_img, 8 );
m_cvvImage1.CopyOf(m_LoadImage1, m_LoadImage1->nChannels/3);
cvReleaseImage( &input_img ); // 메모리 해제
cvReleaseImage( &output_img ); // 메모리 해제
*/
}