I'd like to optimise the following code, which is just a matrix multiplication - I'm sure this can be done without the use of loops - but I can't quite seem to get it right.
k = [ 76 150 29; ...
-44 -85 128; ...
128 -108 -21];
for i = 1:size(rgb,1)
for j = 1:size(rgb,2)
triplet(1:3) = rgb(i,j,:);
yuv(i,j,:) = single(triplet) * single(k');
yuv(i,j,:) = fix(yuv(i,j,:) ./ 256);
end
end
Any thoughts or suggestions?
By the way for those with an image processing background, you'll realise the above code is just simply an RGB to YUV conversion - and you might ask why don't I use the builtin rgb2ycbcr
function - However on this occasion I want to use the 8bit conversion coefficients as outlined above.