Import color video as grayscale?
Hi,
I am using the image processing toolbox and wonder if there is a smarter way to import color video as grayscale rather than looping over the color frames with the RGB2GRAY function (see below).
colorVidFrames = read(videoObj, [startFrame endFrame]);
for f = startFrame:endFrame
J = rgb2gray(colorVidFrames(:,:,:,f)); % CONVERT COLOR TO GRAY
gFrames(:,f) = J(:); % GRAY FRAMES
end
clear colorVidFrames
While the RGB2GRAY loop method does provide the desired end result, it is quite computationally expensive for my application. I understand that the computational rigor could be alleviated via parallel computing, but I’m really looking to avoid the conversion loop altogether if possible.
Thanks,
-JeffHi,
I am using the image processing toolbox and wonder if there is a smarter way to import color video as grayscale rather than looping over the color frames with the RGB2GRAY function (see below).
colorVidFrames = read(videoObj, [startFrame endFrame]);
for f = startFrame:endFrame
J = rgb2gray(colorVidFrames(:,:,:,f)); % CONVERT COLOR TO GRAY
gFrames(:,f) = J(:); % GRAY FRAMES
end
clear colorVidFrames
While the RGB2GRAY loop method does provide the desired end result, it is quite computationally expensive for my application. I understand that the computational rigor could be alleviated via parallel computing, but I’m really looking to avoid the conversion loop altogether if possible.
Thanks,
-Jeff Hi,
I am using the image processing toolbox and wonder if there is a smarter way to import color video as grayscale rather than looping over the color frames with the RGB2GRAY function (see below).
colorVidFrames = read(videoObj, [startFrame endFrame]);
for f = startFrame:endFrame
J = rgb2gray(colorVidFrames(:,:,:,f)); % CONVERT COLOR TO GRAY
gFrames(:,f) = J(:); % GRAY FRAMES
end
clear colorVidFrames
While the RGB2GRAY loop method does provide the desired end result, it is quite computationally expensive for my application. I understand that the computational rigor could be alleviated via parallel computing, but I’m really looking to avoid the conversion loop altogether if possible.
Thanks,
-Jeff rgb2gray import video read videoreader color grayscale MATLAB Answers — New Questions