2013-03-19 6 views
0

안녕하세요. 텍스트 파일에 33x33 크기의 대형 행렬이 있습니다. 나는 기본적으로 프레임을 읽고 유사점을 계산하는 opencv 프로젝트에서 작업 해왔다. 그래서 기본적으로, 나는이 큰 텍스트 파일을 숫자로 채웠습니다. 2D 그레이 스케일 이미지에서이 행렬을 어떻게 시각화합니까?큰 행렬을 이미지로 변환

+0

하여 TXT 파일의 형식은 무엇입니까? yml/xml? 그때 그것은 평범한 이력서입니다 :: FileStorage – berak

답변

1

행렬은 cv::Mat 개체입니까?

그렇다면이 수행

cv::Mat matrix; 

//Load the matrix from the file 
matrix = ... 

//show the matrix 
imshow("window name", matrix); 

//save the image 
imwrite("image.png", matrix); 

하지 않으면, 다음을 수행하십시오

cv::Mat matrix = cv::Mat.create(33, 33, CV_32FC1); 
float* floatPtr = matrix.ptr<float>(); 

for (int i=0;i<33*33;i++) 
    //read data from file here 
    *floatPtr++ = data[i] //if it's in an array 
    //If you have a file stream then do: file>>*floatPtr++; 

//show the image 
imshow("window name", matrix); 

//save the image 
imwrite("image.png", matrix);