1

I need to know if there are any non-white points in a CGImage and I can′t think of a light method for doing it.

Can anyone suggest a method?

jscs
  • 63,694
  • 13
  • 151
  • 195
  • What have you tried so far? Can you be a bit more specific about your desired result? Do you need to simply know _if any_ such pixels exist, or do you want a list of their locations and values? – jscs Mar 04 '12 at 21:14
  • i just needed to know if there were more than 0 pixels non white in my image, and I found this old answer with a method that gives me an array of uicolor objects:http://stackoverflow.com/questions/448125/how-to-get-pixel-data-from-a-uiimage-cocoa-touch-or-cgimage-core-graphics. – InvalidReferenceException Mar 06 '12 at 23:28

1 Answers1

1

Is this for iPhone et al or for Mac OSX? If the former then you have to do it manually. If its the latter then you can use the Core Image Filter CIAreaHistogram.

Peter M
  • 7,309
  • 3
  • 50
  • 91
  • @Aglaia Then you should tag your question as being ios – Peter M Mar 04 '12 at 23:00
  • I'll take the blame for it being untagged with platform (I edited the question), though it shouldn't make too much difference: as of iOS 5, [Core Image is available there](https://developer.apple.com/library/ios/#documentation/GraphicsImaging/Reference/CoreImagingRef/_index.html%23//apple_ref/doc/uid/TP40001171). /cc @Aglaia – jscs Mar 05 '12 at 00:10
  • thank you. I found this example where the average color of the CGImage is computed without looping through the image pixels: http://www.bobbygeorgescu.com/2011/08/finding-average-color-of-uiimage/ – InvalidReferenceException Mar 05 '12 at 01:05