i trying print values of matrix taken input image file, of type cv_8uc4. code written below. problem getting values of 48 , 255 whereas expecting values in 2 , 1 or something.does knows why? think printing values in wrong way. there other way print values of cv_8uc4. code is:
cvmat* m1 = cvloadimagem(argv[1], cv_load_image_unchanged); // load matrix image file cv::mat m1cpp(m1); int type = m1cpp.type(); printf( " type %d ", type ); switch( type ) { case 24: printf("\n --> matrix type cv_8u \n"); for( size_t = 0; < m1cpp.rows; i++ ) { for( size_t j = 0; j < m1cpp.cols; j++ ) { printf( " %d ", m1cpp.at<uchar>(i,j) ); } printf("\n"); } break; case 25: printf("\n --> matrix type cv_8s \n"); for( size_t = 0; < m1cpp.rows; i++ ) { for( size_t j = 0; j < m1cpp.cols; j++ ) { printf( " %d ", m1cpp.at<schar>(i,j) ); } printf("\n"); } break; case 18: printf("\n --> matrix type cv_16u \n"); for( size_t = 0; < m1cpp.rows; i++ ) { for( size_t j = 0; j < m1cpp.cols; j++ ) { printf( " %d ", m1cpp.at<ushort>(i,j) ); } printf("\n"); } break; case 27: printf("\n --> matrix type cv_16s \n"); for( size_t = 0; < m1cpp.rows; i++ ) { for( size_t j = 0; j < m1cpp.cols; j++ ) { printf( " %d ", m1cpp.at<short>(i,j) ); } printf("\n"); } break; case 28: printf("\n --> matrix type cv_32s \n"); for( size_t = 0; < m1cpp.rows; i++ ) { for( size_t j = 0; j < m1cpp.cols; j++ ) { printf( " %d ", m1cpp.at<int>(i,j) ); } printf("\n"); } break; case 29: printf("\n --> matrix type cv_32f \n"); for( size_t = 0; < m1cpp.rows; i++ ) { for( size_t j = 0; j < m1cpp.cols; j++ ) { printf( " %.3f ", m1cpp.at<float>(i,j) ); } printf("\n"); } break; case 30: printf("\n --> matrix type cv_64f \n"); for( size_t = 0; < m1cpp.rows; i++ ) { for( size_t j = 0; j < m1cpp.cols; j++ ) { printf( " %.3f ", m1cpp.at<double>(i,j) ); } printf("\n"); } break; default: printf("\n --> matrix type not found \n"); } my case coming 24 , getting wired values 48 , 255. there other way print cv_8uc4 values?
access cv_8uc4 matrix properly:
image.at<cv::vec4b>(j,i)[0]; image.at<cv::vec4b>(j,i)[1]; image.at<cv::vec4b>(j,i)[2]; image.at<cv::vec4b>(j,i)[3];
Comments
Post a Comment