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.....

http://img89.imageshack.us/img89/1788/bdipt.png

please do reply.....

*No products are associated with this question.*

Answer by Walter Roberson
on 6 Feb 2013

Accepted answer

I = rgb2gray( im2double( YourImage) );

T = M(x : x+M-1, y : y+M-1); sum(T(:)) max(T(:))

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

Show 6 older comments

Walter Roberson
on 7 Feb 2013

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 end end

Image Analyst
on 9 Feb 2013

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;

Opportunities for recent engineering grads.

## 0 Comments