Is there an equivalent to "cv::Mat gray" in python?

i am trying to convert some C++ code that is useful for what i am doing (watermark removal)
there is the lines

cv::Mat gray
cv::cvtColor(mask, gray ,cv.COLOR_BGR2GRAY)
cv::threshold(gray, mask, 180, 255, cv.THRESH_BINARY)

what does the “cv::Mat gray” do and is there an equivalent for python?

It declares an object of type cv::Mat called gray.

Yes (ish) and no. Yes because in python OpenCV uses numpy arrays as the main container format instead of cv::Mat, so you could do

gray = np.empty(0,dtype=np.uint8)

if you realy wanted to and no because there is no cv::Mat object in OpenCV python.

That said I think what your really asking is how to convert implement the code in python. For this I would recommend examining

  1. the OpenCV python test code for examples, e.g.
    opencv/ at 17234f82d025e3bbfbf611089637e5aa2038e7b8 · opencv/opencv · GitHub
  2. the OpenCV tutorials
    OpenCV: Changing Colorspaces
  3. the python help for the functin you want to use
    >>> help(cv.cvtColor)

Help on built-in function cvtColor:

.   transformation, an input RGB image should be normalized to the proper value range to get the correct
.   results, for example, for RGB \f$\rightarrow\f$ L\*u\*v\* transformation. For example, if you have a
.   32-bit floating-point image directly converted from an 8-bit image without any scaling, then it will
.   have the 0..255 value range instead of 0..1 assumed by the function. So, before calling #cvtColor ,
.   you need first to scale the image down:
.   @code
.       img *= 1./255;
.       cvtColor(img, img, COLOR_BGR2Luv);
.   @endcode
.   If you use #cvtColor with 8-bit images, the conversion will have some information lost. For many
.   applications, this will not be noticeable but it is recommended to use 32-bit images in applications
.   that need the full range of colors or that convert an image before an operation and then convert
.   back.
.   If conversion adds the alpha channel, its value will set to the maximum of corresponding channel
.   range: 255 for CV_8U, 65535 for CV_16U, 1 for CV_32F.
.   @param src input image: 8-bit unsigned, 16-bit unsigned ( CV_16UC... ), or single-precision
.   floating-point.
.   @param dst output image of the same size and depth as src.
.   @param code color space conversion code (see #ColorConversionCodes).
.   @param dstCn number of channels in the destination image; if the parameter is 0, the number of the
.   channels is derived automatically from src and code.
.   @see @ref imgproc_color_conversions