6

I would like to detect and mark the brightest and the darkest spot on an image.

For example I am creating an AVCaptureSession and showing the video frames on screen using AVCaptureVideoPreviewLayer. Now on this camera output view I would like to be able to mark the current darkest and lightest points.

An Example

Would i have to read Image pixel data? If so, how can i do that?

NSRover
  • 932
  • 1
  • 12
  • 29

1 Answers1

3

In any case, you must to read pixels to detect this. But if you whant to make it fast, dont read EVERY pixel: read only 1 of 100:

for (int x = 0; x < widgh-10; x+=10) {
   for (int y = 0; y < height-10; y+=10) {
      //Detect bright/dark points here
   }
} 

Then, you may read pixels around the ones you find, to make results more correct


here is the way to get pixel data: stackoverflow.com/questions/448125/… ... at the most bright point, red+green+blue must be maximum (225+225+225 = 675 = 100% white). At the most dark point red+green+blue must bo minimum (0 = 100% black).

SentineL
  • 4,682
  • 5
  • 19
  • 38
  • 1
    - here is the way to gat pixel data: http://stackoverflow.com/questions/448125/how-to-get-pixel-data-from-a-uiimage-cocoa-touch-or-cgimage-core-graphics ... at the most bright point, `red+green+blue` must be maximum (225+225+225 = 675 = 100% white). At the most dark point `red+green+blue` must bo minimum (0 = 100% black). – SentineL Jan 03 '12 at 19:29