Replace Page Title with Image
To answer your specific question; clearly $TitleImage is not empty, views_embed_view is returning wrapper elements or a space. in the view settings make sure "no results" returns nothing using the no results behavior of the field and the view (under advanced).

Why use a view? If that image is on that piece of content then there is no need for a view at all, just use the field:

&lt;?php hide($content['field_title_image']); // So it does not render elsewhere ?&gt;
&lt;?php if (!empty($content['field_title_image'])): ?&gt;
  &lt;h1 class="title" id="page-title"&gt;
      &lt;?php print render($content['field_title_image']); ?&gt;
  &lt;/h1&gt;
&lt;?php else: //Display regular title ?&gt;
  &lt;?php print render($title_prefix); ?&gt;
  &lt;?php if ($title): ?&gt;
    &lt;h1 class="title" id="page-title"&gt;&lt;?php print $title; ?&gt;&lt;/h1&gt;
  &lt;?php endif; ?&gt;
  &lt;?php print render($title_suffix); ?&gt;
&lt;?php endif; ?&gt;


(if you are on node.tpl.php the filed will be as above, if you are on page.tpl.php it will be inside $page['content'] array)