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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:14:16+00:00 2026-06-11T01:14:16+00:00

I want to do two RGB video frames subtraction with GPU processing power. i.e.,

  • 0

I want to do two RGB video frames subtraction with GPU processing power.
i.e., The R,G,B value of each pixels of the first image subtract with the second image.
Also, the result want to have negative RGB value and store in NSMutableArray.
I use AVCaptureSession to help me get the raw video frame in CMSampleBufferRef format.

1) Any image format support negative RGB value?
Or I need to make a matrix-like class to store the image?

(Seems like some image format use float to store the RGB value…)

(I have heard of Image Different Blend Mode, it is similar to what I want but will absolute the RGB value, I want the result to have negative value)

2) How can I do the subtraction with GPU processing power?

(I can do it with CPU, but the FPS is too slow, around 5-6 FPS, but I want it to be 30 FPS)

(Are OpenGL or Quartz Composer helpful?)

Thanks.

  • 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-11T01:14:18+00:00Added an answer on June 11, 2026 at 1:14 am

    As Hammer points out, the GPUImageDifferenceBlendFilter in my open source GPUImage framework does just this. It uses the following fragment shader to obtain the absolute difference of the red, green, and blue channels:

     varying highp vec2 textureCoordinate;
     varying highp vec2 textureCoordinate2;
    
     uniform sampler2D inputImageTexture;
     uniform sampler2D inputImageTexture2;
    
     void main()
     {
         mediump vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
         mediump vec4 textureColor2 = texture2D(inputImageTexture2, textureCoordinate2);
         gl_FragColor = vec4(abs(textureColor2.rgb - textureColor.rgb), textureColor.a);
     }
    

    If you need to compare consecutive video frames, you can also use a GPUImageBuffer to delay an older frame to be processed along with the current video frame. I have an example of this in the FilterShowcase sample application within the framework.

    I’m not quite sure what you mean by “the result want to have negative RGB value.” The only texture format supported on current iOS devices for texture-backed framebuffers (your render targets) is 32-bit BGRA. This means that each color channel ranges from 0-255, with no negative values allowed. You could use the bottom half of that color range for negative values, and the top for positive, though.

    You could modify my GPUImageSubtractBlendFilter to do that, using a fragment shader like the following:

     varying highp vec2 textureCoordinate;
     varying highp vec2 textureCoordinate2;
    
     uniform sampler2D inputImageTexture;
     uniform sampler2D inputImageTexture2;
    
     void main()
     {
         lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
         lowp vec4 textureColor2 = texture2D(inputImageTexture2, textureCoordinate2);
    
         gl_FragColor = vec4((textureColor.rgb - textureColor2.rgb + 1.0) * 0.5, textureColor.a);
     }
    

    You’d then need to convert the 0-255 output to -128 – 128 (or whatever your range is) after you read the pixels back out.

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

Sidebar

Related Questions

I am making a bar chart and I want two separate gradients for each
I'm using two custom push filters to inject audio and video (uncompressed RGB) into
I have a 16 bit luminance value stored in two bytes, and I want
I want two rows and first row has two columns. But I do not
I want two generic classes to be able to reference each other. I can't
I want two special methods: one that runs for all URLs one that runs
Suppose we want two constructors for a class representing complex numbers: Complex (double re,
I have an action inside my controller class and I want two different routes
I want these two print functions to do the same thing: unsigned int Arraye[]
I have a UITextView and I want have two buttons. When the user taps

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.