-1

I want help about frequency distribution in matlab , How to get the average and standard deviation of the frequency distribution for gray scale pixels , how to do that in matlab... please any ideas to help me

sara
  • 9
  • 2

1 Answers1

0

Your question is somewhat confusing - maybe this will help though. I created an example image, found the unique "pixel" values in that image, found the frequency of each of the unique values (ie. the number of times that value occurred in the image), calculated an average pixel value, and found the standard deviation of the pixel frequencies.

img = randi(20, 20); % example grayscale image
uniq = unique(img); % all the unique pixel values in the image

for i = 1:length(uniq)
    freq(i) = length(find(img == uniq(i))); % find the frequency of the unique pixels in the image
end

printf("Value\tFrequency\n");
for i = 1:length(uniq)
    printf("%d\t%d\n", uniq(i), freq(i));
end

average = sum(freq)/length(freq) % average pixel frequency
stddev = std(freq) % standard deviation of pixel frequency

Output:

Value   Frequency
1       24
2       17
3       19
4       15
5       19
6       23
7       21
8       21
9       16
10      16
11      15
12      20
13      21
14      16
15      23
16      29
17      20
18      29
19      21
20      15
average =  20 
stddev =  4.1927
user3716193
  • 476
  • 5
  • 21