Ramkumar Paulraj
Ramkumar Paulraj

Reputation: 1943

GPUImageGaussianSelectiveBlurFilter selective area issue

I have using GPUImageGaussianSelectiveBlurFilter

    imagePic = [[GPUImagePicture alloc] initWithImage:captureImage];// given a input in gpuimagepicture for process a image
filter = [[GPUImageGaussianSelectiveBlurFilter alloc] init];
[imagePic addTarget:filter];// add a filter for image

// create  a view for set a image in that view
imageViewGpu=[[GPUImageView alloc] initWithFrame:CGRectMake((self.view.frame.size.width-OutputImageView.frame.size.width)/2.0, (biManager.displayImageHeight-OutputImageView.frame.size.height)/2.0, OutputImageView.frame.size.width, OutputImageView.frame.size.height)];
imageViewGpu.userInteractionEnabled = YES;

imageViewGpu.frame=OutputImageView.frame;
imageViewGpu.multipleTouchEnabled= YES;
imageViewGpu.backgroundColor = [UIColor clearColor];
imageViewGpu.userInteractionEnabled = YES;
imageViewGpu.fillMode=kGPUImageFillModePreserveAspectRatio;
[self.view addSubview:imageViewGpu];
[(GPUImageGaussianSelectiveBlurFilter *) filter setExcludeCircleRadius:0.3f];

[(GPUImageGaussianSelectiveBlurFilter *) filter setExcludeCirclePoint:CGPointMake(0,0)];
[filter addTarget:imageViewGpu];
[filter prepareForImageCapture];
[imagePic processImage];// get a filter apply image

My output is

enter image description here

But I need this output

enter image description here

I think this filter greatly working with a square image. But it's not correctly working with Rectangle image. Please Help Me.

Upvotes: 0

Views: 518

Answers (3)

Ramkumar Paulraj
Ramkumar Paulraj

Reputation: 1943

    if (imageViewGpu.frame.size.height>imageViewGpu.frame.size.width) {

        [(GPUImageGaussianSelectiveBlurFilter *) filter setAspectRatio:imageViewGpu.frame.size.height/imageViewGpu.frame.size.width];
}
else
{

    [(GPUImageGaussianSelectiveBlurFilter *) filter setAspectRatio:imageViewGpu.frame.size.width/imageViewGpu.frame.size.height];

}

Above Code is working well

Upvotes: 0

Jack
Jack

Reputation: 16855

Set the aspectRatio property of the filter to the aspect ratio of your image.

filter.aspectRatio = imagePix.size.width/imagePix.size.height

If that doesn't work swap width/height :]

Upvotes: 1

Wil Shipley
Wil Shipley

Reputation: 9533

Draw your image into a square buffer that’s taller but the same width. Blur it. Copy it back out into your smaller, rectangular buffer.

Upvotes: 0

Related Questions