I have an image of type Mat that I am trying to separate into its individual bands so I can then adjust the pixel values in each band separately. When I write the code this error pops up "No matching function for call to 'cvSplit'".
Mat image = imread(file,1);
Mat rBand, gBand,bBand;
cvSplit(image, bBand, gBand, rBand, NULL);
imshow("red", rBand);
imshow("blue", bBand);
imshow("green",gBand);
A mat does not allow a subscript operator if not stated when created. Therefore most create a Mat denoting number of bands within so it can then be split. this means that Bands[0],Bands[1],Bands[2] are each of a single channel and are grayscale. Not get original image must then merge the channels using merge function.
Mat image = imread(file,1);
Mat Bands[3],merged;
split(image, Bands);
vector<Mat> channels = {Bands[0],Bands[1],Bands[2]};
merge(channels,merged);
imshow("red", Bands[2]);
imshow("blue", Bands[0]);
imshow("green",Bands[1]);
imshow("merged",merged);
Try this function instead if cvSplit:
cv::split
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With