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

1 visualización (últimos 30 días)
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.

Respuesta aceptada

Bruno Luong
Bruno Luong el 20 de En. de 2023
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 comentarios
Bruno Luong
Bruno Luong el 20 de En. de 2023
Editada: Bruno Luong el 20 de En. de 2023
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 el 23 de En. de 2023
You're right, I hadn't thought of that. A thousand thanks @Bruno Luong

Iniciar sesión para comentar.

Más respuestas (1)

Image Analyst
Image Analyst el 20 de En. de 2023
What about entropy
e = entropy(grayImage(row1:row2, col1:col2))
  1 comentario
Simone
Simone el 20 de En. de 2023
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))

Iniciar sesión para comentar.

Categorías

Más información sobre Image Segmentation and Analysis en Help Center y File Exchange.

Productos


Versión

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by