| filterYUVimage(yuv, rgbIn, yMin, yMax, uMin, uMax, vMin, vMax)
|
% filter supplied YUV image according to the specified ranges and return
% the filtered rgb image
function rgbFILT = filterYUVimage(yuv, rgbIn, yMin, yMax, uMin, uMax, vMin, vMax)
% create filtered output...
[obj_r,obj_c] = find(...
yuv(:,:,1)>=yMin & yuv(:,:,1)<=yMax & ...
yuv(:,:,2)>=uMin & yuv(:,:,2)<=uMax & ...
yuv(:,:,3)>=vMin & yuv(:,:,3)<=vMax);
% re-display RGB image indicating selected colour
rgbFILT = rgbIn;
% % redisplay original image with selected colour changed to black
% for(i = 1:length(obj_r))
% rgbFILT(obj_r(i),obj_c(i),:) = uint8(0);
% end
% % redisplay original image with selected colours changed to the complement of the average
% for(i = 1:length(obj_r))
% %rgbFILT(obj_r(i),obj_c(i),:) = [255 255 255] - [rAve gAve bAve];
% end
% split vector into even and odd elements... (shaded display)
idx = 1:length(obj_r);
oddx = find(mod(idx,2));
evex = setdiff(idx, oddx);
% redisplay original image with selected colours replaced by shades of black and white
for(i = 1:length(evex))
rgbFILT(obj_r(evex(i)),obj_c(evex(i)),:) = uint8(255);
end
% redisplay original image without selected colours
for(i = 1:length(oddx))
rgbFILT(obj_r(oddx(i)),obj_c(oddx(i)),:) = uint8(0);
end
|
|