A list,









Ii. Source code

%*********************************************
%Image thresholding using Tsallis entropy

%2021- 326 - 
%*********************************************
clear all;
close all;
clc

format short g;
% disp(strcat('***************apply on whiteRose.jpg'));

% I=imread('whiteRose.jpg');
I=imread('C:\Users\lenovo\Desktop\113172244Tsallis-entropy\Tsallis entropy/cell.jpg');
% I=imread('ndmz.png');
% I=imread('star.jpg');
% I=imread('cell2.jpg'); imgray = rgb2gray(I); % grayscale thresh=graythresh(imgray); % I2= IM2BW (IMgray, Thresh); % binary graph convert subplot(2.3.1) imshow(I); title('original');
subplot(2.3.2) imshow(imgray); title('Grayscale');
subplot(2.3.3) imhist(imgray); title('Gray histogram');
subplot(2.3.4)
omega=num2str(uint8(round(thresh*255))); imshow(I2); title(['OTSU threshold: ',omega]);
disp(strcat('OTSU calculated gray threshold: ',num2str(uint8(round(thresh*255))))); thresh1=thresh [m,n]=size(imgray); N=m*n ; The total number of grey value % % * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * % KAPUR_entroy maximum entropy value method threshold figure (1)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[count,x]=imhist(imgray,256); A=[x,count]; p=count/N; % to calculate the probability of each gray value % with'1985-histo'The new algorithm mentioned in the literature calculates the threshold a=min(find(p~=)0.0));
P=p(p~=0); % Extract the item where P is not zero and eliminate the singularity p=p(a:256); % remove the singularities where the first several terms are zero b=length(p); ps=cumsum(p); % probability1- T sum PS = cumsum (P); Hs=-cumsum(P.*log(P));
HA=log(PS)+Hs./PS;
HB=log(1-PS)+(Hs(end)-Hs)./(1-PS); L2=length(HA); % to eliminate1-PS为零的点
HA=HA(1:(L2)- 1);
HB=HB(1:(L2)- 1);
Ts=HA+HB;
s=mean(find(Ts==max(Ts))+a2 -);
disp(strcat('KAPUR_entroy calculates gray threshold: ',num2str(s)));
thresh2=double(s)/255
I3=im2bw(imgray,double(s)/255);   
subplot(2.3.5); imshow(I3); title(['KAPUR threshold: ',num2str(s)]);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Image thresholding using Tsallis entropy
q=0.5;
for T=1:1:b
    sumA=0.0; sumB=0.0;
      for i=1:1:T
       sumA=sumA+(p(i)/ps(T))^q;
      end
        for j=T+1:1:b
        sumB=sumB+(p(j)/(1-ps(T)))^q;
        end
    c(T)=sumA;
    d(T)=sumB;
end
L=min(find(d==0)); % d =0The singularity of c = c (1:L- 1);
d=d(1:L- 1);
 g=[c',d'];
    Sqa=(1-c)./(q- 1);
    Sqb=(1-d)./(q- 1);
    g=[Sqa',Sqb'];
    ST=Sqa+Sqb+(1-q).*Sqa.*Sqb; T= mean(find(ST== Max (ST))+a2 -);
disp(strcat('Tsallis Entropy calculates the grayscale threshold: ',num2str(t)));
thresh3=double(t)/255
I3=im2bw(imgray,thresh3);   
subplot(2.3.6); imshow(I3); title(['Tsallis threshold: ',num2str(t)]);
%*****************************************
figure(2) % % % * * * * * * * * * * * * * under different q value of * * * * * * * % * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * % disp (strcat('***************apply on star.jpg'));
% I=imread('whiteRose.jpg');
%  I=imread('ROSE2.jpg');
% I=imread('ndmz.png');
% I=imread('star.jpg');
% I=imread('inftest.jpg');
% I=imread('kejian.jpg');
I=imread('fengz.jpg');
% I=imread('cell.jpg');
%  I=imread('xingzuo.jpg'); imgray=rgb2gray(I); % grayscale thresh=graythresh(imgray); % I2= IM2BW (IMgray, Thresh); % binary graph convert subplot(2.3.1) imshow(I); title('original');
subplot(2.3.2) imshow(imgray); title('Grayscale');
subplot(2.3.3) imhist(imgray); title('Gray histogram');
subplot(2.3.4)
omega=num2str(uint8(round(thresh*255))); imshow(I2); title(['OTSU threshold: ',omega]);
disp(strcat('OTSU calculated gray threshold: ',num2str(uint8(round(thresh*255))))); thresh1=thresh [m,n]=size(imgray); N=m*n ; The total number of grey value % % * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * % KAPUR_entroy maximum entropy value method threshold figure (2)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[count,x]=imhist(imgray,256); A=[x,count]; p=count/N; % to calculate the probability of each gray value % with'1985-histo'The new algorithm mentioned in the literature calculates the threshold a=min(find(p~=)0.0));
P=p(p~=0); % p=p(a:256); b=length(p); ps=cumsum(p); % probability1- T sum PS = cumsum (P); Hs=-cumsum(P.*log(P));
HA=log(PS)+Hs./PS;
HB=log(1-PS)+(Hs(end)-Hs)./(1-PS); L2=length(HA); % to eliminate1-ps is zero singularity HA=HA(1:(L2)- 1);
HB=HB(1:(L2)- 1);
Ts=HA+HB;
s=mean(find(Ts==max(Ts))+a2 -);
disp(strcat('KAPUR_entroy calculates gray threshold: ',num2str(s)));
thresh2=double(s)/255
I3=im2bw(imgray,double(s)/255);   
subplot(2.3.5); imshow(I3); title(['KAPUR threshold: ',num2str(s)]); % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %Image thresholding using Tsallis entropy ****figure(2)
q= [0.1.0.5.1.1.5.2];
for n=1:1:5
    if q(n)~=1Q / = % calculation1Tsallis entropyfor T=1:1:b
    sumA=0.0; sumB=0.0;
    for i=1:1:T 
        sumA=sumA+(p(i)/ps(T))^q(n);
    end
    for j=T+1:1:b
        sumB=sumB+(p(j)/(1-ps(T)))^q(n);
    end
   
    c(T)=sumA;
    d(T)=sumB;
end
L=min(find(d==0)); D = % processing0The singularity of c = c (1:L- 1);
d=d(1:L- 1);
 f=[c',d'];
    Sqa=(1-c)./(q(n)- 1);
    Sqb=(1-d)./(q(n)- 1);
    h=[Sqa',Sqb'];
    ST=Sqa+Sqb+(1-q(n)).*Sqa.*Sqb;
    ss=[f,h,ST'];
    find(ST==max(ST));
    t(n)=mean(find(ST==max(ST))+a2 -);
    else
Copy the code

3. Operation results







Fourth, note

Version: 2014 a