Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detecting bright/dark points on iPhone screen

Tags:

iphone

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?

like image 548
NSRover Avatar asked Dec 28 '11 08:12

NSRover


People also ask

How do I turn off light sensor thing on iPhone?

You can turn auto-brightness on or off in Settings > Accessibility > Display & Text Size. To reset the auto-brightness settings, turn off auto-brightness and then turn it back on.

How do I find true tones on my iPhone?

Turn True Tone on or offOpen Control Center, touch and hold. , then tap. to turn True Tone on or off. Go to Settings > Display & Brightness, then turn True Tone on or off.


1 Answers

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).

like image 85
SentineL Avatar answered Oct 01 '22 11:10

SentineL