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 9195431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:37:34+00:00 2026-06-17T21:37:34+00:00

I have used the GPUImage framework for a blur effect similar to that of

  • 0

I have used the GPUImage framework for a blur effect similar to that of the Instagram application, where I have made a view for getting a picture from the photo library and then I put an effect on it.

One of the effects is a selective blur effect in which only a small part of the image is clear the rest is blurred. The GPUImageGaussianSelectiveBlurFilter chooses the circular part of the image to not be blurred.

How can I alter this to make the sharp region be rectangular in shape instead?

  • 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-17T21:37:35+00:00Added an answer on June 17, 2026 at 9:37 pm

    Because Gill’s answer isn’t exactly correct, and since this seems to be getting asked over and over, I’ll clarify my comment above.

    The fragment shader for the selective blur by default has the following code:

     varying highp vec2 textureCoordinate;
     varying highp vec2 textureCoordinate2;
    
     uniform sampler2D inputImageTexture;
     uniform sampler2D inputImageTexture2; 
    
     uniform lowp float excludeCircleRadius;
     uniform lowp vec2 excludeCirclePoint;
     uniform lowp float excludeBlurSize;
     uniform highp float aspectRatio;
    
     void main()
     {
         lowp vec4 sharpImageColor = texture2D(inputImageTexture, textureCoordinate);
         lowp vec4 blurredImageColor = texture2D(inputImageTexture2, textureCoordinate2);
    
         highp vec2 textureCoordinateToUse = vec2(textureCoordinate2.x, (textureCoordinate2.y * aspectRatio + 0.5 - 0.5 * aspectRatio));
         highp float distanceFromCenter = distance(excludeCirclePoint, textureCoordinateToUse);
    
         gl_FragColor = mix(sharpImageColor, blurredImageColor, smoothstep(excludeCircleRadius - excludeBlurSize, excludeCircleRadius, distanceFromCenter));
     }
    

    This fragment shader takes in a pixel color value from both the original sharp image and a Gaussian blurred version of the image. It then blends between these based on the logic of the last three lines.

    The first and second of these lines calculate the distance from the center coordinate that you specify ((0.5, 0.5) in normalized coordinates by default for the dead center of the image) to the current pixel’s coordinate. The last line uses the smoothstep() GLSL function to smoothly interpolate between 0 and 1 when the distance from the center point travels between two thresholds, the inner clear circle, and the outer fully blurred circle. The mix() operator then takes the output from the smoothstep() and fades between the blurred and sharp color pixel colors to produce the appropriate output.

    If you just want to modify this to produce a square shape instead of the circular one, you need to adjust the two center lines in the fragment shader to base the distance on linear X or Y coordinates, not a Pythagorean distance from the center point. To do this, change the shader to read:

     varying highp vec2 textureCoordinate;
     varying highp vec2 textureCoordinate2;
    
     uniform sampler2D inputImageTexture;
     uniform sampler2D inputImageTexture2; 
    
     uniform lowp float excludeCircleRadius;
     uniform lowp vec2 excludeCirclePoint;
     uniform lowp float excludeBlurSize;
     uniform highp float aspectRatio;
    
     void main()
     {
         lowp vec4 sharpImageColor = texture2D(inputImageTexture, textureCoordinate);
         lowp vec4 blurredImageColor = texture2D(inputImageTexture2, textureCoordinate2);
    
         highp vec2 textureCoordinateToUse = vec2(textureCoordinate2.x, (textureCoordinate2.y * aspectRatio + 0.5 - 0.5 * aspectRatio));
    
         textureCoordinateToUse = abs(excludeCirclePoint - textureCoordinateToUse);
         highp float distanceFromCenter = max(textureCoordinateToUse.x, textureCoordinateToUse.y);
    
         gl_FragColor = mix(sharpImageColor, blurredImageColor, smoothstep(excludeCircleRadius - excludeBlurSize, excludeCircleRadius, distanceFromCenter));
     }
    

    The lines that Gill mentions are just input parameters for the filter, and don’t control its circularity at all.

    I leave modifying this further to produce a generic rectangular shape as an exercise for the reader, but this should provide a basis for how you could do this and a bit more explanation of what the lines in this shader do.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have used Quartz.Net for queuing and sending emails from my application. I don't
i have used GPUImage framework, while run example code for SimplePhotoFilter (i have used
I have used storyboard in my application in my detail view for UITableView i
I have used the jquery ajax for getting the values from the server.when the
We have used Shibboleth to authenticate users. It works great. The issue is that
I have used some jquery components in my web site, Suddenly i'm getting an
I have used a plugin that uses prototype js, it's working fine but the
I have used auto complete textbox previously. That auto complete works only when i
I have used geocoder in my ruby on rails application for a while but
i have used c# vs2010 winform i made a basic chart, and added points

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.