How to find energy of the image

Please help me to find energy of the image given by equation,
E(x) = for i=1 to x (p(x))

Answers (1)

What is p? The units of images are gray levels, and gray levels are units of energy (joules). Why? Well because you have radiation falling on a sensor. That's watts per square meter or joules per second per square meter. But the sensor has an area and it collects photons for a limited time so you multiply by the area of the pixel and the integration time of the pixel and you get joules. So to get the energy in an image you have to sum up all the gray levels.
totalEnergy = sum(imageArray(:));
What is x and p in your equation? Why is E a function of x (whatever x is)?

7 Comments

E(x) is gray level energy and p(i) is probability distribution function.
What are x and i? What is the energy dependent on? Distance? Location? What?????
You can get the PDF (Probability Density (not distribution) Function) from imhist:
[pixelCounts, grayLevels] = imhist(imageArray);
i got probability density function but my problem is how to sum all those???
The p will sum to 1, by definition. If it doesn't, it's not a PDF.
[pixelCounts, grayLevels] = imhist(imageArray);
pdf = pixelCounts / sum(pixelCounts); % Sum of all pdf elements = 1.
cdf = sumsum(pdf); % Cumulative Distribution Function, if needed.
Why won't you answer my question about what x is? This is the third time I'm asking.
clc;clear all;close all; a=imread('e:\IMAGES\mona.jpg');
[row col]=size(a); h=zeros(512,512); for n=1:1:row for m=1:1:col if a(n,m)==0 a(n,m)=1; end end end
for n=1:1:row for m=1:1:col t=a(n,m); h(t)=h(t)+1; end end
figure(1) imshow((a)) figure(2) bar(h)
h(h==0) = [ ];
h = h ./ numel(a);
E = sum((h));
i have implemented this code but its showing answer one for any image.
h you calculated above in turn comes out to be PDF, it's quite obvious that you will get 1 as answer by summing up h. As mentioned earlier by Image analyst you can simply add up all the pixel values in image to get the energy, why complicate it
Plus those for loops aren't needed and nullifying zeros in h isn't needed. You could do this:
zeroPixelLocations = (a == 0); % Find all zeros.
a(zeroPixelLocations ) = 1; % Set to 1 instead of 0.
h = imhist(a, 256);
h = h / numel(a); % a must be grayscale if you use numel.
E = sum(h(:))

Sign in to comment.

Categories

Asked:

on 3 Feb 2014

Edited:

on 3 Feb 2014

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!