How can i vectorize rgb2gray function ?
조회 수: 3 (최근 30일)
이전 댓글 표시
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
답변 (0개)
참고 항목
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!