Can the doctor tell if polyps are cancerous just by viewing them?

No. 2 types of. Polyps: stalked and sessile. The stalked once are easier to excise as biopsy and treatment, the sessile needs to be looped snared, and the trick is to get all of the polyp without leaving a hole in the gut. Size, color, shape descriptions do not tell malignant or not.
Sometimes. Some polyps are obviously cancerous, especially if they are ulcerated and have heaped up edges and typically are larger than normal polyps. But some relatively innocuous-looking polyps can have cancerous changes in them which surprise even an experienced observer (colonoscopist?), so no one wants to commit to labelling you with cancer till we are sure, patholgy confirmed.