matlab - Extraction of RoI in a Video -


i working on simulink develop algorithm. have video stream dimensions 640x360. trying extract region of interest (roi) each frame. however, video turns grayscale when use following code:

matlab function block using roi extraction:

function y = fcn(u)  %some more code  width = 639; height = 210; top = 150; left = 1; y = u(top:top+height, left:left+width); 

solution

change last line follows:

y = u(top:top+height, left:left+width,:); 

explanation

the dimensions of rgb image mxnx3. m , n image height , width, , there 3 channels: red, green , blue.

when perform cropping of rgb image, should performed on each channel separately. can achieve using code example above.


Comments

Popular posts from this blog

ios - Is 'init' forbidden as *part* of a variable name? -

angular - Angular2 Router: Cannot find primary outlet to load 'HomeComponent' -

javascript - Why Selenium can't find an element that is graphically visible -