let canvas = document.getElementById('canvas_input');
load_image_to_canvas('https://upload.wikimedia.org/wikipedia/commons/thumb/0/02/Nelson_Mandela_1994.jpg/463px-Nelson_Mandela_1994.jpg', 'canvas_input');
let src = cv.imread('canvas_input');
let dst = new cv.Mat();
cv.cvtColor(src, src, cv.COLOR_RGBA2RGB, 0);
let ksize = new cv.Size(3, 3);
cv.GaussianBlur(src, dst, ksize, 3, 3, cv.BORDER_DEFAULT);
cv.imshow('canvas_output', dst);
let src_copy = src.clone();
let sample = new cv.Mat();
let rect = new cv.Rect(0, 0, 100, 100);
sample = dst.roi(rect);
console.log('about to copy')
sample.copyTo(src_copy, rect);
console.log('copied')
cv.imshow('canvas_output_rect', src_copy);
Is there a better way of copying a Rect to a matrix of a certain dimension, without having to write two for loops and setting the pixel values manually?
Ie in Python you can use the slicing syntax to do it in one line, like this.