Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9170201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:59:03+00:00 2026-06-17T15:59:03+00:00

I would like to perform a smart blur to a UIImage, where the contents

  • 0

I would like to perform a “smart” blur to a UIImage, where the contents are blurred, but the edges remain sharp.

For example, here is my original image:

Sharp original image

and here is what I would like to see after this blur is applied:

Blurred image

How can I do a “smart” blur like this on a UIImage?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T15:59:03+00:00Added an answer on June 17, 2026 at 3:59 pm

    The blur you’re looking for here is called a bilateral blur. Unlike a standard Gaussian blur, surrounding pixel colors are averaged with the center pixel color based on how similar they are to the central pixel. This blurs interior regions of objects, but preserves a sharp outline.

    In my open source GPUImage framework, I have a filter that does this, called a GPUImageBilateralFilter. This is the output of that when applied to your image (using a blurSize of 1.0 and a distanceNormalizationFactor of 1.6):

    Filtered orange using a bilateral blur

    There are some slight differences between my result and your target, but that’s probably due to the specific weightings I use. By tweaking the parameters here, you should be able to get this closer to the above.

    OpenCV also has bilateral blur filters, and you could take the source code to my fragment shader and use this to construct your own OpenGL ES implementation if you’d like to use it outside of this framework:

     uniform sampler2D inputImageTexture;
    
     const lowp int GAUSSIAN_SAMPLES = 9;
    
     varying highp vec2 textureCoordinate;
     varying highp vec2 blurCoordinates[GAUSSIAN_SAMPLES];
    
     uniform mediump float distanceNormalizationFactor;
    
     void main()
     {
         lowp vec4 centralColor;
         lowp float gaussianWeightTotal;
         lowp vec4 sum;
         lowp vec4 sampleColor;
         lowp float distanceFromCentralColor;
         lowp float gaussianWeight;
    
         centralColor = texture2D(inputImageTexture, blurCoordinates[4]);
         gaussianWeightTotal = 0.18;
         sum = centralColor * 0.18;
    
         sampleColor = texture2D(inputImageTexture, blurCoordinates[0]);
         distanceFromCentralColor = min(distance(centralColor, sampleColor) * distanceNormalizationFactor, 1.0);
         gaussianWeight = 0.05 * (1.0 - distanceFromCentralColor);
         gaussianWeightTotal += gaussianWeight;
         sum += sampleColor * gaussianWeight;
    
         sampleColor = texture2D(inputImageTexture, blurCoordinates[1]);
         distanceFromCentralColor = min(distance(centralColor, sampleColor) * distanceNormalizationFactor, 1.0);
         gaussianWeight = 0.09 * (1.0 - distanceFromCentralColor);
         gaussianWeightTotal += gaussianWeight;
         sum += sampleColor * gaussianWeight;
    
         sampleColor = texture2D(inputImageTexture, blurCoordinates[2]);
         distanceFromCentralColor = min(distance(centralColor, sampleColor) * distanceNormalizationFactor, 1.0);
         gaussianWeight = 0.12 * (1.0 - distanceFromCentralColor);
         gaussianWeightTotal += gaussianWeight;
         sum += sampleColor * gaussianWeight;
    
         sampleColor = texture2D(inputImageTexture, blurCoordinates[3]);
         distanceFromCentralColor = min(distance(centralColor, sampleColor) * distanceNormalizationFactor, 1.0);
         gaussianWeight = 0.15 * (1.0 - distanceFromCentralColor);
         gaussianWeightTotal += gaussianWeight;
         sum += sampleColor * gaussianWeight;
    
         sampleColor = texture2D(inputImageTexture, blurCoordinates[5]);
         distanceFromCentralColor = min(distance(centralColor, sampleColor) * distanceNormalizationFactor, 1.0);
         gaussianWeight = 0.15 * (1.0 - distanceFromCentralColor);
         gaussianWeightTotal += gaussianWeight;
         sum += sampleColor * gaussianWeight;
    
         sampleColor = texture2D(inputImageTexture, blurCoordinates[6]);
         distanceFromCentralColor = min(distance(centralColor, sampleColor) * distanceNormalizationFactor, 1.0);
         gaussianWeight = 0.12 * (1.0 - distanceFromCentralColor);
         gaussianWeightTotal += gaussianWeight;
         sum += sampleColor * gaussianWeight;
    
         sampleColor = texture2D(inputImageTexture, blurCoordinates[7]);
         distanceFromCentralColor = min(distance(centralColor, sampleColor) * distanceNormalizationFactor, 1.0);
         gaussianWeight = 0.09 * (1.0 - distanceFromCentralColor);
         gaussianWeightTotal += gaussianWeight;
         sum += sampleColor * gaussianWeight;
    
         sampleColor = texture2D(inputImageTexture, blurCoordinates[8]);
         distanceFromCentralColor = min(distance(centralColor, sampleColor) * distanceNormalizationFactor, 1.0);
         gaussianWeight = 0.05 * (1.0 - distanceFromCentralColor);
         gaussianWeightTotal += gaussianWeight;
         sum += sampleColor * gaussianWeight;
    
         gl_FragColor = sum / gaussianWeightTotal;
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to perform a different action when my app moves to the
I would like to perform a small operation on all entities of a specific
I would like to perform a regular expression in jQuery to find all the
I would like to perform a progress indicator during request. I have try function
I would like to perform a key event detection in textbox. The keys should
I would like to perform something similar to this (ie get the sum of
I would like to perform a bitwise exclusive or of two strings in python,
I would like to perform a measurement and plot a graph while the measurement
I would like to perform 5 consecutive reads to a slave devices and check
I would like to perform a certain selection which (as I tested in sqldeveloper)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.