How can i vectorize rgb2gray function ?
이전 댓글 표시
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개)
카테고리
도움말 센터 및 File Exchange에서 Video Formats and Interfaces에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!