2013-03-14 11 views
0

Matrix 클래스가 있고 두 개의 루프를 사용하여이 클래스에 액세스하여 원하는 모든 값을 저장했습니다.Matrix 클래스를 IplImage로 변환 *

Matrix MatriceJ(width, height); 
for (int i=0;i<width;i++) 
{ 
    for (int j=0;j<height;j++) 
    { 
     MatriceJ.at(i,j)=.... 
    } 
} 

그러나 지금, 나는 다른 IplImages와 그 다른 요소 하나 하나를 곱 수에 대한 IplImage *에 MatriceJ를 저장하고 싶습니다.

도와 주실 수 있습니까?

+0

왜 '매트릭스 매트릭스'를 작성했는지 이해하지 못합니다. 'Mat MatriceJ '가 아닌가? – Chani

+0

그러나 쉽게 조작하고 값을 저장하기 위해 Matrix라는 클래스를 만들었습니다. –

+0

답하십시오. –

답변

1

시작해야합니다. 나는 데이터를 unsigned char 및 하나의 채널로 가정하고 적절하게 조정하십시오.

// Create the image 
int depth = IPL_DEPTH_8U; // please adjust 
int channels = 1;   // please adjust 
IplImage* img = cvCreateImage(cvSize(width,height), depth, channels); 

// Now assume there is a matrix MatriceJ 
// Copy the data to our newly created IplImage* 
for (int i=0;i<height;i++) 
{ 
    uchar* ptr = (uchar*)(img->imageData + i*img->widthStep); 
    for (int j=0;j<width;j++) 
    { 
     ptr[j] = MatriceJ(i,j); 
    } 
} 
+0

정말 고마워요 !! –

관련 문제