0

In OpenCV, it's possible to create a cv::Mat representing a sub-rectangle of an existing cv::Mat, with cv::Mat::operator() functions. This is made possible by the Mat step parameter which enables non contiguous data, allowing padding bytes in each axis.

Is it possible to have a single channel shallow copy selected in an RGB image, the same way? I can't find whether cv::split is a shallow or deep copy.

What I need to do is applying gaussian blur on the G channel of a RGB image. Do I necessarily have to deep copy the G channel to a single channel image first?

2
  • 1
    I don't think that's possible, at least not for the regular 2D Mats that are broadly used in OpenCV. Notice in the constructors, that the number of possible "step" parameters is 1 less than the number of dimensions (and channels are not considered a dimension). You could probably make a 3D Mat of 8UC1 (rows x cols x 1), to have a step between columns as well... but I'm not so sure how most OpenCV functions will like that. Commented Mar 21, 2024 at 15:18
  • With cv::Mat GreenCH = SrcImg.reshape( 1, SrcImg.rows * SrcImg.cols ).col(1);, you can obtain Mat to access only green ch, but shape is not good... So, very simple process likes "fill green ch whole with same value" can be perfomed, but blurring is... Commented Mar 22, 2024 at 9:38

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.