How can I delete Red channel from image and use only Green merged to blue?

asked 2020-05-18 13:07:40 -0600

FelipeBasilio gravatar image

updated 2020-05-18 14:17:55 -0600

berak gravatar image

I need to get an image and extract the color channels(RGB) and then merge Green and Blue ones, what am I doing wrong(Using OpenCV.js)

<button type="button" onclick="filter('Aneritra')">Aneritra</button>


<script>
    function filter(filter_name){
        if(filter_name == 'Aneritra'){
            let src = cv.imread('Selected_Image');
            let dst = new cv.Mat();
            let rgbaPlanes = new cv.MatVector();
            // Split the src
            cv.split(src, rgbaPlanes);
            // Get G channel
            let G = rgbaPlanes.get(1);
            // Get B channel
            let B = rgbaPlanes.get(2);
            // Merge G & B channels
            cv.merge((G,B), dst);
            cv.imshow('canvasOutput', dst);
            src.delete();
            dst.delete();
            rgbaPlanes.delete();
        }
    }
</script>
edit retag flag offensive close merge delete

Comments

It would be easier to see what you do wrong if you tell what happens wrong...

mvuori gravatar imagemvuori ( 2020-05-19 06:14:31 -0600 )edit

Uncaught BindingErrormessage: "Expected null or instance of MatVector, got an instance of Mat"name: "BindingError"stack: "BindingError: Expected null or instance of MatVector, got an instance of Mat↵ at BindingError.<anonymous> (http://localhost:81/admin/opencv.js:2... at new BindingError (eval at createNamedFunction (http://localhost:81/admin/opencv.js:2...), <anonymous>:4:34)↵ at throwBindingError (http://localhost:81/admin/opencv.js:2... at upcastPointer (http://localhost:81/admin/opencv.js:2... at RegisteredPointer.nonConstNoSmartPtrRawPointerToWireType [as toWireType] (http://localhost:81/admin/opencv.js:2... at Object.merge (eval at new_ (http://localhost:81/admin/opencv.js:2...), <anonymous>:7:26)↵ at filtro (http://lo</anonymous></anonymous></anonymous>

FelipeBasilio gravatar imageFelipeBasilio ( 2020-05-20 13:20:21 -0600 )edit