how to split channels of a video

how to split channels of a video for example in rgb, we show video in these channel r, g, and b separately? and show video in each channel individually.

Answers (1)

If you have a RGB frame F os size m*n*3...
R = F(:,:,1) ;
G = F(:,:,2) ;
B = F(:,:,3) ;

3 Comments

in below code which you commented in response of first question, please tell me how can i split hsv channel in to h, s, and v channels and show it video separately.
vidObj = VideoReader('C:\Users\Public\Videos\Sample Videos\Wildlife.wmv'); % video file
%% Read the video frame by frame
numFrames = 0;
iwant = cell([],1) ;
while hasFrame(vidObj)
F = readFrame(vidObj);
numFrames = numFrames + 1;
imagesc(F)
drawnow
iwant{numFrames} = F ;
end
%% Write to video
v = VideoWriter('myFile','Archival');
v.VideoCompressionMethod
open(v)
for i = 1:numFrames
writeVideo(v,rgb2hsv(iwant{i}))
end
close(v)
vidObj = VideoReader('C:\Users\Public\Videos\Sample Videos\Wildlife.wmv'); % video file
%% Read the video frame by frame
numFrames = 0;
iwant = cell([],1) ;
while hasFrame(vidObj)
F = readFrame(vidObj);
numFrames = numFrames + 1;
imagesc(F)
drawnow
iwant{numFrames} = F ;
end
%% Write to video
v = VideoWriter('myFile','Archival');
v.VideoCompressionMethod
open(v)
for i = 1:numFrames
I = rgb2hsv(iwant{i}) ;
% Get h,s,v
h = I(:,:,1) ;
s = I(:,:,2) ;
v = I(:,:,3) ;
writeVideo(v,I)
end
close(v)
KSSV, above code show error at writeVideo(v,I), if i replace I with rgb2hsv(iwant{i}), code runs successfully but object of spliting channels are not achieved, so kindly review it if you have find an error.

Sign in to comment.

Asked:

on 24 Apr 2019

Commented:

on 24 Apr 2019

Community Treasure Hunt

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

Start Hunting!