title: Why is there so much converting between image formats needed? (UIImage, CGImage, CIImage)
body: <p>I'm confused as to why so much converting between image formats is needed in iOS. For example, if I load a jpg into a UIImage and then want to do face detection on it, I need to create a CIImage to pass to the CIDetector. Doesn't this represent a hit in both memory and performance?</p>
  
  <p>Is this some legacy thing between Core Graphics, Core Image and UIKit (and probably openGL ES but I don't work with that)? Is the hit trivial overall? </p>
  
  <p>I'll do what I need to do but I'd like to understand more about this is needed. Also, I've run into issues sometimes doing conversions and get tangled in the differences between the formats.</p>
  
  <hr>
  
  <p><strong>Update</strong></p>
  
  <p>Ok - so I just got dinged again by my confusion over these formats (or the confusion OF these formats...). Wasted a half hour. Here is what I was doing:</p>
  
  <p>Testing for faces in a local image, I created the needed CIImage with:</p>
  
  <pre><code>CIImage *ciImage = [image CIImage];
  </code></pre>
  
  <p>and was not getting any features back no matter what orientation I passed in. I <em>know</em> this particular image has worked with the <code>CIDetectorTypeFace</code> before <em>and</em> that I have run into trouble with the <code>CIImage</code> format. The tried creating the CCImage like this:</p>
  
  <pre><code> CIImage *ciImage = [CIImage imageWithCGImage:image.CGImage];
  </code></pre>
  
  <p>and Face Detection works fine. Arrgh! I made sure with <code>[image CIImage]</code> that the resulting CIImage was not nil. So I'm confused. The first approach just gets a pointer while the second creates a new CIImage. Does that make the difference?</p>
  
  <p>Digging into the UIImage.h file I see the following:</p>
  
  <pre><code>// returns underlying CGImageRef or nil if CIImage based
  @property(nonatomic,readonly) CGImageRef  CGImage; 
  
  // returns underlying CIImage or nil if CGImageRef based
  @property(nonatomic,readonly) CIImage     *CIImage;  
  </code></pre>
  
  <p>So I guess that is the key - <strong>Developer Beware</strong>: test for nil...</p>