How to calculate the mean value of the 3rd dimension of YUV so as to filter the differences between consecutive frames ?
조회 수: 1 (최근 30일)
이전 댓글 표시
I was trying to resolve the issue of non-consecutive frames which extracted from a video. I want to go through each pixel and each frame.
Currently I have converted the RGB images to YUV and extracted each component. I want to calculate the mean value of the 3rd dimension of YUV so as to filter the difference between consecutive frames. . What should I do next ?
Thank you.
Below are the code that I have done so far: =================================================
caffe.reset_all();
caffe.set_mode_gpu();
caffe.set_device(0);
clear; close all;
close all;
clear;
%%Display RGB
Dir = 'C:\Users\Image\';
im_list = dir(fullfile(Dir, '*.bmp'));
% loop for all test images
for i = 1:length(im_list)
im_path = [Dir im_list(1).name];
x = imread(im_path);
R=x(:,:,1);
G=x(:,:,2);
B=x(:,:,3);
RGB = cat(3,R,G,B);
YUV = rgb2ycbcr(RGB);
%%Display each component
compY = YUV(:,:,1); %%extract Y component
compU = YUV(:,:,2); %%extract U component
compV = YUV(:,:,3); %%extract V component
댓글 수: 1
Joss Knight
2016년 7월 6일
편집: Joss Knight
2016년 7월 6일
I don't understand the question. The channels are the third dimension, so the mean in the third dimension is the mean of all channels (which you get from rgb2gray), not just the Y channel.
답변 (2개)
Image Analyst
2016년 7월 7일
It's still ambiguous what you mean by "third dimension". Thorsten gave you one way. The third channel/slice/plane of your 3D color space image is compV, and mean2() will take the mean of that color channel (the value channel).
meanV = mean2(compV); % A single scalar value.
Whereas
meanImage = mean(YUV, 2); % A 2-D image.
will give you an image where each pixel is the mean along the third dimension. So, the result is an image that is (compY+compU+compV)/3.
Which concept is what you're thinking of?
댓글 수: 5
Image Analyst
2016년 7월 7일
You can d_do_ that - it will work - but won't do anything useful at all. Use the debugger to step through it and find out why.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!