Sir, I'm facing a problem that matlab are very slow against for loop and i found vectorization will solve this problem.
I readed the "Vectorization document" already and got those example but in my case, i cann't vectorize my code.
the code is very simple. just try to convert RGB video to grayscale video without for loop.
vid = VideoReader('dataset\video\terrace1-c3.avi'); %some video
no = 50;
frames = read(vid, [1 no]); % 4-dimension matrix RGB color [R G B frame]
for i = 1:no;
grayFrames(:,:,i) = rgb2gray(frames(:,:,:,i));
end
I know multiplying 299 587 114 to matrix will make the same result but for longrun, i have to know how to vectorize any matlab function.
please give me some example.

Réponses (0)

Catégories

En savoir plus sur Get Started with MATLAB dans Centre d'aide et File Exchange

Produits

Modifié(e) :

le 29 Nov 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by