How can i vectorize rgb2gray function ?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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.
0 comentarios
Respuestas (0)
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!