05-10 05:10
Notice
Recent Posts
Recent Comments
관리 메뉴

Scientific Computing & Data Science

[OpenCV] reshape 메써드를 이용하여 픽셀 Dimension 변경 본문

Programming/OpenCV

[OpenCV] reshape 메써드를 이용하여 픽셀 Dimension 변경

cinema4dr12 2015. 3. 3. 01:01

reshape 메써드는 메모리 복사 또는 픽셀의 위치 변경 없이 Matrix의 Dimension을 변경합니다.

Example Code

1
2
3
4
5
6
7
8
9
// open the image
cv::Mat image = cv::imread( YOUR_IMAGE_PATH );
 
if( image.isContinuous() )
    image.reshape( 1, image.cols * image.rows );
 
// display image
cv::namedWindow( "Image" );
cv::imshow( "Image", image );
cs

 

reshape 메써드의 첫번째 파라미터는 채널의 새로운 개수이고 두번째 파라미터는 행(rows)의 새로운 개수입니다. 열(columns)의 개수는 자동으로 계산됩니다.

Comments