How to calculate the entropy of a portion of image as in the following formula?

1 回表示 (過去 30 日間)
Simone
Simone 2023 年 1 月 19 日
コメント済み: Simone 2023 年 1 月 23 日
Hello everyone, I am new here on matlab. I should calculate the subset entropy of portion of image, defined as in the formula (4). Could someone please tell me how to write a routine that calculates the subset entropy using matlab please.
Thank you very much in advance.
  2 件のコメント
Simone
Simone 2023 年 1 月 20 日
@Walter Roberson How can I use "nifilter" to implement the formula (4)?

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

採用された回答

Bruno Luong
Bruno Luong 2023 年 1 月 20 日
Please try this
A=imread('ngc6543a.jpg');;
A=double(A(1:500,:,:));
A=sum(A,3);
M = 11; N = 11;
% Build 8-neighbor
[di,dj] = ndgrid(-1:1);
di = di(:);
dj = dj(:);
di(5,:) = []; dj(5,:) = []; % remove (0,0) shift
A8 = zeros([size(A),8]);
for i=1:8
A8(:,:,i) = A(min(max(di(i)+(1:end),1),end), ...
min(max(dj(i)+(1:end),1),end));
end
dA = sum(abs(A8-A),3);
depth = 24+zeros(size(A));
K = ones(M,N);
delta = conv2(dA,K,'same')./(2.^depth.*conv2(ones(size(dA)),K,'same'));
subplot(2,1,1);
imagesc(A)
colormap gray
subplot(2,1,2);
imagesc(delta);
  7 件のコメント
Bruno Luong
Bruno Luong 2023 年 1 月 20 日
編集済み: Bruno Luong 2023 年 1 月 20 日
Ask people who claim it, here my value is smal becaise the depth (beta) is 24 as in your example of code.
1/2^24
ans = 5.9605e-08
You have all the values in my code, why can't you check it.
I simply implement what you wrote above as formula, I don't know this specific formula, the paper and people who wrote it.
What I know is entropy never have strict unit definition, as long as it's defined consistently across the usage for comparison.
Simone
Simone 2023 年 1 月 23 日
You're right, I hadn't thought of that. A thousand thanks @Bruno Luong

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

その他の回答 (1 件)

Image Analyst
Image Analyst 2023 年 1 月 20 日
What about entropy
e = entropy(grayImage(row1:row2, col1:col2))
  1 件のコメント
Simone
Simone 2023 年 1 月 20 日
Hi @Image Analyst, the the way the entropy function is calculated is different from formula (4). I wrote this routine, do you think it will work?
A1=imread('IMG_111.png');
A=double(A1);
g=rgb2gray(A);
x=2000 %coordinate of subset center
y=2000 %coordinate of subset center
j=60 %subset radius
A1=A([(x-(j-1)):(x+j)],[(y-(j-1)):(y+j)]);
xx=((j*2)-9)
for k=8:1:xx
for l=8:1:xx
A2=A1([(k-7):(k+9)],[(l-7):(l+9)]);
for i=1:1:17
for j=1:1:17
Ii=A2([i],[j]);
row=size(A2,1);
column=size(A2,2);
Ip=A2([(row-1)/2],[(column-1)/2]);
c=abs(Ip-Ii);
C(i,j)=c;
S = sum(C(:));
end
end
D(k,l)=S;
end
end
S1 = sum(D(:));
subsetentropy=S1/((2^24)*(j*2*j*2))

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

カテゴリ

Help Center および File ExchangeImage Segmentation and Analysis についてさらに検索

製品


リリース

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by