HSV = randn(10, 10, 3); light = zeros(size(HSV)); copyIndex = repmat(HSV(:, :, 1) > 0, 1, 1, size(HSV, 3)); light(copyIndex) = HSV(copyIndex);