Ios 使用GPUImage从黑白滤镜中移除阴影
我正在尝试应用黑白滤镜,我也成功了,但滤镜后我的阴影干扰了整个滤镜,所以我想移除或照亮阴影,有人有想法吗?我该怎么办 附加我已经实现的代码,并在同一时间输出Ios 使用GPUImage从黑白滤镜中移除阴影,ios,iphone,opencv,gpuimage,imagefilter,Ios,Iphone,Opencv,Gpuimage,Imagefilter,我正在尝试应用黑白滤镜,我也成功了,但滤镜后我的阴影干扰了整个滤镜,所以我想移除或照亮阴影,有人有想法吗?我该怎么办 附加我已经实现的代码,并在同一时间输出 您正在使用GPUImageAverageLuminanceThresholdFilter对图像应用恒定阈值。如果纸张上的照明不同,则较暗的区域将低于阈值,较亮的区域将超过阈值 您需要的是一个适应当地条件的阈值。这就是GPUImageAdaptiveThresholdFilter的作用。它对每个像素周围的区域执行框模糊,从中确定平均亮度,如
您正在使用
GPUImageAverageLuminanceThresholdFilter
对图像应用恒定阈值。如果纸张上的照明不同,则较暗的区域将低于阈值,较亮的区域将超过阈值
您需要的是一个适应当地条件的阈值。这就是GPUImageAdaptiveThresholdFilter
的作用。它对每个像素周围的区域执行框模糊,从中确定平均亮度,如果像素高于此亮度,则标记为白色。否则,黑色
大多数进行您在这里尝试的名片扫描增强的人都会应用这样的过滤器,而不是图像范围的阈值。您正在使用
GPUImageAverageLuminanceThresholdFilter对图像应用恒定阈值。如果纸张上的照明不同,则较暗的区域将低于阈值,较亮的区域将超过阈值
您需要的是一个适应当地条件的阈值。这就是GPUImageAdaptiveThresholdFilter
的作用。它对每个像素周围的区域执行框模糊,从中确定平均亮度,如果像素高于此亮度,则标记为白色。否则,黑色
大多数进行您尝试的名片扫描增强的人都会应用这样的过滤器,而不是图像范围内的阈值。嘿,Brad,你能帮我一些代码吗?因为我不熟悉这个过滤器。嘿,Brad,你能帮我一些代码吗,如果你解决了它,请分享代码。@ChanWarde请检查我使用了它,但我想从图像中删除那个阴影。在我的例子中,我只想用相同颜色的背景显示颜色。嗨,如果你解决了这个问题,请分享代码。@ChanWarde请检查我用过它,但我想从图像中删除那个阴影。在我的例子中,我只想用相同颜色的背景显示颜色。
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];