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

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -