WHY ARE SPLIT MATS NOT CONTINOUS [closed]

asked 2016-05-24 13:32:30 -0600

willoughby gravatar image

so I split an into is seperate colors (using split on the matrix). When I then try to reshape one of the resulting matrix I get the following error:

OpenCV Error: Image step is wrong (The matrix is not continuous, thus its number of rows can not be changed) in reshape, file /tmp/opencv3-20160429-9997-hdwo4d/opencv-3.1.0/modules/core/src/matrix.cpp, line 997

so then I quickly wrote the following code:

cv::Mat image = cv::imread(inputImageName,CV_LOAD_IMAGE_COLOR);
cv::Mat colorMats[3];
cv::split(image,colorMats);
for (int i=0;i < 3;++i)
{
    std::cout<<colorMats[i].isContinuous()<<std::endl;
}

and got the following result

1
1
0

why is the last one not continuous ?

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by sturkmen
close date 2020-10-07 16:35:40.798054

Comments

What is your platforms? Can you give image size -width and height)?

PS with lower case in title it is better

LBerger gravatar imageLBerger ( 2016-05-24 13:35:58 -0600 )edit

The image is 1138 x 912. I'm trying to run it on Mac OSX here is the image Test Image

willoughby gravatar imagewilloughby ( 2016-05-24 15:23:47 -0600 )edit

no problem with windows 10 and opencv 3.1. can you check if image isContinuous just after imread.

LBerger gravatar imageLBerger ( 2016-05-24 16:21:34 -0600 )edit

image is continuous

willoughby gravatar imagewilloughby ( 2016-05-25 08:54:36 -0600 )edit