why do you need `if`? `image0.convertTo(source, imdepth);` covers all these cases.