필터 지우기
필터 지우기

How to calculate the entropy of a grayscale image.

조회 수: 5 (최근 30일)
Ishara Nipuni
Ishara Nipuni 2018년 11월 23일
댓글: Walter Roberson 2018년 12월 28일
Hi can you help me to calculate the entropy of a grayscale image using Matlab? Here I've shown below the code that I tried. The code was working but I got the value of the entropy of my image as 'NaN'. So, please help me to find the entropy value of a grayscale image correctly.
I = imread('152.bmp');
x = entropy(I);
%functionH = MyEntropy(x);
imshow(x);
figure()
[Height,Width] = size(x);
[m,Binsx]=imhist(x);
m = m/(Height*Width);
sprintf('the sum of the histogram value is = %g',sum(m));
figure,plot(Binsx,m,'k')
xlabel('pixel value'),ylabel('relative count')
H = sum(-m.*log2(m));
sprintf('the entropy of the image is = %g',H)
  댓글 수: 7
Anurag ch
Anurag ch 2018년 12월 28일
sir,can you give me the correct definition of normalization
Walter Roberson
Walter Roberson 2018년 12월 28일
1. Statistics: Standardization of data obtained from different sources at different periods, through peer review or comparison against the objectives of data collection.

댓글을 달려면 로그인하십시오.

채택된 답변

Miriam
Miriam 2018년 11월 23일
Hi Ishara,
It looks like you are trying to find the height, width, and histogram using the entropy value you found. Maybe try:
[Height,Width] = size(I);
[m,Binsx] = imhist(I);
  댓글 수: 3
Miriam
Miriam 2018년 11월 25일
I'm not sure I understand. The entropy of your image is a single number, what do you want to plot?
Image Analyst
Image Analyst 2018년 11월 25일
There is an entropyfilt() that finds the entropy in a sliding window. Why do you think you want entropy anyway? What's the use case?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by