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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:26:08+00:00 2026-05-17T02:26:08+00:00

There are two formulae which I am finding it difficult to represent in MATLAB

  • 0

There are two formulae which I am finding it difficult to represent in MATLAB. Let there be two RGB images, A and B, of the same size with m,n representing rows and column and the third dimension d=3. Formula1 basically calculates the rate of change of pixels if A is the original image and B is the distorted version. Formula2 calculates the average rate of change of pixels.

1.
Formula1= { sum(C(m,n,d)) / (m * n)} * 100

  where `C(m,n) = 0`, if `A(m,n) = B(m,n)`
                `=1`, if `A(m,n) != B(m,n)`

Sum over all rows and column including the third dimension.

I have tried something like this:

Formula1 = sum(sum(abs(double(A)-double(B))./(m*n), 1), 2);

But this does not give any error. However, this is not the correct way to represent it, since the if conditions are not incorporated. The problem area is how to incorporate the condition by checking if A == B or not and if A != B.

2.
Formula2 ={ 1/ (m*n)} * sum { norm (A - B) / 255} * 100
Again, here also it will be summation over all the dimensions. I don’t know how to form the norm of a matrix.

  1. Formula3 is ={ 1/ (m*n)} * sum {(A - B) / 255} * 100
    I tried out like this

    C = double(sum(A-B,3));
    r = reshape(100*(C/255)/(m*n),[1 3])

But there is an error saying dimension should be same and reshape does not work.

  • 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-05-17T02:26:09+00:00Added an answer on May 17, 2026 at 2:26 am

    For Formula1:

    function r = Formula1(A,B)
    [m,n,d] = size(A); %# A and B must have the same dimension
    C = A ~= B; %# C has a 1 in every pixel that's different
    r = double(sum(C(:)))/(m*n);
    r = r/d; %# normalize by number of color planes
    

    The ~= operator checks for inequality. (:) vectorizes the matrix, allowing us to calculate the sum over all dimensions.

    For Formula2:

    function r = Formula2(A,B)
    [m,n,d] = size(A);
    C = double(sum(A-B, 3)); %# sum over the color planes
    C = C/d; %# normalize by number of color planes
    K = norm(C); %# or norm(C,1), norm(C,inf) etc.
    r = 100*(K/255)/(m*n);
    

    Here, sum(A-B, 3) sums over the color planes, leaving a 2D matrix with the dimensions of the original image. There are several matrix norms, your choices are available in the documentation for NORM.

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

Sidebar

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.