Remove Shadow from Black and White filter using GPUImage


I am trying to apply black and white filter and i have succeded in same but after filter i am having shadow which disturbs whole filter , so i wanted to remove or lighten shadow ,so is anyone having ideawhat should i do.?

attaching the code i have implemented and Output at of same

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];

Show source
| ios   | iphone   | opencv   | gpuimage   | imagefilter   2016-11-24 11:11 1 Answers

Answers to Remove Shadow from Black and White filter using GPUImage ( 1 )

  1. 2016-12-01 16:12

    You are applying a constant threshold on the image using a GPUImageAverageLuminanceThresholdFilter. If illumination varies across your piece of paper, the darker areas will fall below the threshold and the brighter ones pass above it.

    What you want is a threshold that adapts to local conditions. That's what the GPUImageAdaptiveThresholdFilter does. It performs a box blur on the area around each pixel, determines the average luminance from that, and if the pixel is above this luminance it is marked as white. Otherwise, black.

    Most people who do the kind of business card scan enhancement you're attempting here apply a filter like that instead of an image-wide threshold.

Leave a reply to - Remove Shadow from Black and White filter using GPUImage

◀ Go back