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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:21:21+00:00 2026-06-05T22:21:21+00:00

I have two images which i would like to compare and do different operations

  • 0

I have two images which i would like to compare and do different operations depending on what value the specific pixel has. The problem is that is is really slow and i need to speed the operations up alot, what could be done with the code?

currentFrame = rgbimage; %rgbimage is an 800x450x3 matrix

for i = 1:size(currentFrame, 1)

   for j = 1 : size(currentFrame,2) 

       if currentFrame(i,j) > backgroundImage(i,j) %backgroundimage is an equally sized image which i would like to compare with
          backgroundImage(i,j, :) = double(backgroundImage(i,j, :) +1); 

       elseif currentFrame(i,j) < backgroundImage(i,j)
          backgroundImage(i,j, :) = double(backgroundImage(i,j, :) -1);          
       end


   end

end

diff = abs(double(currentFrame) - double(backgroundImage)); %difference between my backgroundimage and my current frame
fusion = zeros(size(currentFrame)); % A fusion image

for i=1:size(backgroundImage,1)
    for j = 1:size(backgroundImage,2)

           if diff(i,j) > 20

            fusion(i,j, :) = double(currentFrame(i,j, :));

           else
             fusion(i,j, :) = 0;  

           end
    end 
end

Thanks for any help!

  • 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-05T22:21:23+00:00Added an answer on June 5, 2026 at 10:21 pm

    You don’t need to loop – you can do stuff like:

    indexes = currentFrame > backgroundImage;
    backgroundImage(indexes) = backgroundImage(indexes) + 1;
    

    btw. in your code using currentFrame(i,j) > backgroundImage(i,j) you are just comparing the first of the three color dimensions. Is this intended?

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

Sidebar

Related Questions

I am trying to compare two images to assess their registration. I would like
I have made one screen with two images and I would like to add
We have two websites which only difference is in the design (different images, styles,
I have two images with which I am using in an anchor tag. I
I have an .exe file which takes two jpg images as arguments and makes
I have a table which has two text boxes and an image beside it
I have two resize functions that I would like to perform one after the
I'm trying to implement a 'fade into' script which would affect two images :
Right now, I have a layout that looks like one of the two images
I have two categories listed in my DB. I would like to change the

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.