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

조회 수: 2 (최근 30일)
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.

채택된 답변

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 CenterFile Exchange에서 Image 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