MATLAB Answers


how to calculate intensity

Asked by Elysi Cochin on 6 Feb 2013

I really appreciate your help and I would be so grateful if you help me with this?,

how to calculate, the difference between the number of pixels in a block and the ratio of the sum of pixel intensities in the block to the maximum in the block

i wanted to substitute the values in the equation in the link below.....

please do reply.....




No products are associated with this question.

1 Answer

Answer by Walter Roberson
on 6 Feb 2013
 Accepted answer

I = rgb2gray( im2double( YourImage) );
T = M(x : x+M-1, y : y+M-1);

and I'll leave you to work out the ratio.


If your blocks are to slide G pixels at a time, e.g., G = 1

for x = 1 : G : size(I,1) - M + 1
  for y = 1 : G : size(I,2) - M + 1
    B = M(x : x+M-1, y : y+M-1);
    P = sum(B(:));
    Q = max(B(:));
    ratio = .... a function of P and Q

thank u sir...

Of course you could do this all in one to three lines with a vectorized approach using conv2() and imdilate(), like this (untested):

blurredImage = -conv2(yourImage, ones(M)/M^2, 'same') + M^2;
maxImage = imdilate(yourImage, true(M));
BDIP = blurredImage ./ maxImage;

Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!