2019-06-23(day008)——- cv.split(numpy) - cv.merge()

python

import cv2 as cv
def function():
    img = cv.imread("../images/flower.jpg")
    cv.imshow("input", img)
    
    img_splited = cv.split(img) 
    img_splited[0][:, :] = 0
    dst1 = cv.merge(img_splited)
    cv.imshow("blue_0", dst1)
    
    img_splited = cv.split(img) 
    img_splited[1][:, :] = 0
    dst2 = cv.merge(img_splited)
    cv.imshow("green_0", dst2)
    
    img_splited = cv.split(img) 
    img_splited[2][:, :] = 0
    dst3 = cv.merge(img_splited)
    cv.imshow("red_0", dst3)
    
    cv.mixChannels(img, dst3, [2, 0])
    cv.imshow("mix_2,0(input and red_0)", dst3)
function()
cv.waitKey(0)
cv.destroyAllWindows()

python中的新知识点

  • cv.split(numpy)
  • cv.merge()

c++

#include "all.h"
using namespace std;
using namespace cv;

void MyClass::day008() {
    Mat img = read(PATH + "\\images\\flower.jpg");
    imshow("input", img);

    vector mv;
    split(img, mv);
    Mat dst1, dst2, dst3;
    mv[0] = Scalar(0);
    merge(mv, dst1);
    imshow("blue=0", dst1);
    split(img, mv);
    mv[1] = Scalar(0);
    merge(mv, dst2);
    imshow("green=0", dst2);
    split(img, mv);
    mv[2] = Scalar(0);
    merge(mv, dst3);
    imshow("red=0", dst3);

    waitKey(0);
}

c++中的新知识点

  • std::vector
  • split();
  • merge();

你可能感兴趣的:(2019-06-23(day008)——- cv.split(numpy) - cv.merge())