简体   繁体   English

iOS Objective-C中的自动白平衡

[英]Automatic white balance in iOS Objective-C

I'm trying to fix the white balance of a picture on iOS. 我正在尝试修复iOS上图片的白平衡。 In my app, people can take a picture and get 2 things : an OCR and an "improved" version of the image. 在我的应用程序中,人们可以拍照并获得两件事:OCR和图像的“改进”版本。

To do the OCR, I improve the image with GPUImage (using GPUImageAdaptiveThresholdFilter ). 为了进行OCR,我使用GPUImageAdaptiveThresholdFilter改进了图像(使用GPUImageAdaptiveThresholdFilter )。 But that image is made only of black and white pixels. 但是该图像仅由黑白像素组成。 For my "improved" version, I want to have : - the right color balance (meaning my white is really white and not yellow when I take the picture inside) - good contrast. 对于我的“改进”版本,我想要:-正确的色彩平衡(意味着当我在里面拍照时,我的白色是白色,而不是黄色)-良好的对比度。

I tried with GPUImageContrastFilter and GPUImageWhiteBalanceFilter . 我尝试使用GPUImageContrastFilterGPUImageWhiteBalanceFilter GPUImageWhiteBalanceFilter works well but GPUImageWhiteBalanceFilter takes parameters (like temperature ) and that really depends on the image input. GPUImageWhiteBalanceFilter可以很好地工作,但是GPUImageWhiteBalanceFilter可以接受参数(例如temperature ),而这实际上取决于图像输入。

So is there a way to "calculate" these parameters or are there objective c algorithms to fix white balance ? 那么有没有办法“计算”这些参数,或者有客观的c算法来解决白平衡问题? Either ready to use, or simple using GPUImage ? 准备使用还是简单使用GPUImage?

Thanks ! 谢谢 !

You can use CoreImage to auto enhance images. 您可以使用CoreImage自动增强图像。 It will do the analysis for you. 它将为您进行分析。

This is done by acquiring a set of CIFilter with the necessary modifications that you can just apply to your image. 这是通过获取一组具有必要修改的CIFilter来完成的,您只需将其应用于图像即可。

See more info here . 在此处查看更多信息。

It may take time, but you can use your OCR function as a kind of scoring algorithm for a hill-climbing (or other) optimization algorithm. 这可能会花费一些时间,但是您可以将OCR函数用作爬坡(或其他)优化算法的一种评分算法。

  1. Take a portion of the image (to speed it up) 拍摄一部分图像(加快速度)
  2. Pick some parameters and improve the image 选择一些参数并改善图像
  3. Run it through OCR -- hopefully your OCR can give some confidence or you have some way of scoring the output (number of words?) 通过OCR运行它-希望您的OCR可以给您一定的信心,或者您可以通过某种方式对输出进行评分(字数?)
  4. Change the parameters -- use an optimization algorithm to decide how to do this. 更改参数-使用优化算法来决定如何执行此操作。
  5. Go to 3 -- stop when you run out of time or it's good enough 转到3-时间用完或足够好时停止

If OCR is too slow -- you may have to pick something else to score with. 如果OCR太慢-您可能必须选择其他东西才能得分。 Perhaps there's a way to compare your output images with known good ones and get a diff. 也许有一种方法可以将您的输出图像与已知的好图像进行比较,并获得差异。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM