RGB Image re-interlacing missing output colors.
6 views (last 30 days)
I want to start by stating I am a pretty advanced coder, but I am fairly new to the Matlab world and am still grasping the more fundamental pieces of image proccesing.
I have an imput image that I sperate into two "interlaced frames". This is easy, I use the following code to seperate the image row by row.
function [A, B] = deinterlace(inImage)
A = inImage(1:2:end,:,:);
B = inImage(2:2:end,:,:);
I realize this might not be the "best" method of doing this, but for my experiments this will sufice. That being said, if there is a more "Matlab/correct" way of doing this it would be much apricaited, mainly because I want to learn the proper way of doing things (outside of the tutorials, nothing is as good as an experinced coder).
My issue is when I try to re-interlace the image. Since the image is RGB, it is stored in a (W x H x 3) matrix and when I try to stich the image back together I seem to be loosing some formating of the data. As such some of the color is leftout of the output image (see image bellow).
The code below is what I have tried...commented out section produces the exact same result, but is "not the Matlab" solution, or so I'm told. Any advice on what I am doing wrong would be much apriciated.
function [outImage] = interlace(A, B)
w = size(A);
outImage = zeros(w(1)*2, w(2), w(3));
outImage(1:2:end,:,:) = A;
outImage(2:2:end,:,:) = B;
% outImage = zeros(w(1)*2, w(2), w(3));
% for i = 1:2:w*2
% index = ceil(i/2);
% outImage(i,:,:) = A(index,:,:);
% outImage(i+1,:,:) = B(index,:,:);
(Top: Input Image, Middle: Two halfs of interlaced image, Bottom: Result of re-interlacing)