使用GPUImage从黑白过滤器中删除阴影

时间:2016-11-24 10:08:22

标签: ios iphone opencv gpuimage imagefilter

我正在尝试应用黑白过滤器并且我已经成功但是在过滤器之后我有阴影干扰整个过滤器,所以我想要移除或减轻阴影,所以有任何人有想法我应该做什么。?< / p>

附加我已经实现的代码和输出at相同的

enter image description here

GPUImagePicture *stillImageSource = [[GPUImagePicture alloc] initWithImage:image];


GPUImageContrastFilter * stillImageContrastFilter = [[GPUImageContrastFilter alloc]init];
stillImageContrastFilter.contrast = 1.0;

GPUImageSharpenFilter * stillImageSharpenFilter = [[GPUImageSharpenFilter alloc]init];
stillImageSharpenFilter.sharpness = 4.0;

GPUImageGaussianBlurFilter * stillImageBlurFilter = [[GPUImageGaussianBlurFilter alloc]init];
stillImageBlurFilter.blurRadiusInPixels = 1.0;

GPUImageAverageLuminanceThresholdFilter * stillImageThresFilter = [[GPUImageAverageLuminanceThresholdFilter alloc]init];
stillImageThresFilter.thresholdMultiplier = 0.88;

GPUImageChromaKeyFilter * stillImageSmoothFilter = [[GPUImageChromaKeyFilter alloc]init];
stillImageSmoothFilter.smoothing = 0.1f;

[stillImageSource addTarget:stillImageContrastFilter];
[stillImageContrastFilter addTarget:stillImageSharpenFilter];
[stillImageSharpenFilter addTarget:stillImageBlurFilter];
[stillImageBlurFilter addTarget:stillImageThresFilter];
[stillImageThresFilter addTarget:stillImageSmoothFilter];



[stillImageSmoothFilter useNextFrameForImageCapture];

[stillImageSource processImage];

UIImage *imgTmp1 = [stillImageSmoothFilter imageFromCurrentFramebuffer];

1 个答案:

答案 0 :(得分:0)

您正在使用GPUImageAverageLuminanceThresholdFilter在图像上应用恒定阈值。如果您的纸张上的照明发生变化,则较暗的区域将低于阈值,较亮的区域将从其上方通过。

您想要的是适应当地条件的阈值。这就是GPUImageAdaptiveThresholdFilter的作用。它在每个像素周围的区域执行盒子模糊,从中确定平均亮度,如果像素高于此亮度则标记为白色。否则,黑色。

大多数执行此类名片扫描增强功能的用户都会尝试使用此类过滤器而不是图片范围的阈值。