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.
Would i have to read Image pixel data? If so, how can i do that?
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.
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.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With