How to get entropy values of different images to a graph?

1 回表示 (過去 30 日間)
Ishara Nipuni
Ishara Nipuni 2018 年 11 月 25 日
コメント済み: KALYAN ACHARJYA 2018 年 11 月 25 日
Hi,
I have calculated the entropy values of different images using the code I have shown below. Now I need to get the entropy values o several images to a graph. Can you please help me on that?
%read te image
I = imread('152.bmp');
subplot(2,2,1),imshow(I,map1)
I2 = imread('006.bmp');
subplot(2,2,3),imshow(I2,map2)
x = entropy(I);
x2 = entropy(I2);
[Height,Width] = size(I);
[m,Binsx] = imhist(I);
%normalize the counts
m = m/(Height*Width);
%get the sum of the histogram values
sprintf('the sum of the histogram value is = %g',sum(m));
subplot(2,2,2),plot(Binsx,m,'k')
xlabel('pixel value'),ylabel('relative count')
H = sum(-m.*log2(m));
sprintf('the entropy of the image is = %g',H)
%calculate height & width of the image
[Height,Width] = size(I2);
%get the histogram of the image in 256 bins
[n,Binsx] = imhist(I2);
%normalize the counts
n = n/(Height*Width);
%get the sum of the histogram values
sprintf('the sum of the histogram value is = %g',sum(n));
%
subplot(2,2,4),plot(Binsx,n,'k')
xlabel('pixel value'),ylabel('relative count')
H2 = sum(-n.*log2(n));
sprintf('the entropy of the image is = %g',H2)
%get the graph of the entropy values
figure(),plot(H,H2);
xlabel('image number'),ylabel('entropy value')
  1 件のコメント
Image Analyst
Image Analyst 2018 年 11 月 25 日
Do you want both entropy values on one graph? Why not use bar() instead of plot()?

サインインしてコメントする。

採用された回答

KALYAN ACHARJYA
KALYAN ACHARJYA 2018 年 11 月 25 日
I=imread('test.png');
I2=imread('test.jpg');
x=entropy(I);
x2=entropy(I2);
bar([x x2]);
set(gca,'xticklabel');
title('Entropy of Two Images');
rrr.png
Another Way:
I=imread('test.png');
I2=imread('test.jpg');
x=entropy(I);
x2=entropy(I2);
bar(1,x);
hold on;
bar(2, x2,'r');
bar_name={'Image 1' 'Image 2'};
legend(bar_name,'location','northwest');
title('Entropy of Two Images');
yy.png
  2 件のコメント
Ishara Nipuni
Ishara Nipuni 2018 年 11 月 25 日
Thank you so much for the help. It will be very helpfull for me. :-) :-)
KALYAN ACHARJYA
KALYAN ACHARJYA 2018 年 11 月 25 日
Welcome @Ishara
I'm glad, it helped.
Good Wishes
Regards,
Kalyan Acharjya

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImage Processing and Computer Vision についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by