% The calculating program developed by Fluid and Flow Group of HIT. % If you want to run this program please change the file suffix type % to '.m' and save. Then run it using MATLAB. close all; %close all the images clear all; %clear all variables clc; %clear screen % Import an image into MATLAB from your storage path string=strcat('D:\experimental images\1.jpg'); RGB=imread(string); % Colour space conversion(from RGB to HSI) hsi=rgb2hsi(RGB); % Extact intensity image ii=hsi(:,:,3); figure imshow(ii) % Extract valid regions by function [x,y]=ginput(2) % obtain two points'(upper left corner and lower right corner) coordinates of rectangular region % Pay attention to the definition of coordinate in matlab [x,y]=ginput(2) xn1=x(1,1);%Upper left corner yn1=y(1,1); xn2=x(2,1);%Lower right corner yn2=y(2,1); c=round(xn1) r=round(yn1) % Calculate the upper left corner coordinates of small rectangles N=8; % The number of small rectangles n=round((xn2-xn1)/(N)) m=round(yn2-yn1) cy(1)=c rx(1)=r for k=2:N cy(k)=m+cy(k-1) rx(k)=rx(1) end % Extract images and compute mixing indexes for k=1:N z=subim(ii,m,n,rx(k),cy(k)); figure; imshow(z) % Compute maximum intensity value of an image max=z(1,1); for i=1:m for j=1:n if max<=z(i,j) max=z(i,j); end end end % Compute mean intensity value of an image num=n*m; total=0; for i=1:m for j=1:n total=total+z(i,j); end end ave=total/num; % For computing standard variance value of an image sum=0; for i=1:m for j=1:n sum=sum+(z(i,j)-ave)^2; end end % The sum for computing mixing index based on formula (1) sum1=0; for i=1:m for j=1:n sum1=sum1+(z(i,j)-max)^2; end end % Compute mixing indexes % (The first kind)Both the mean and standard variance % decreasing with the enhancement of mixing sigma=sqrt(sum/num); I1=sqrt(sum1/num) I2=1-sigma/ave I4=sigma*sigma/(1-ave)/ave I5=sqrt(sum/(num-1))/ave I6=sigma I20=1/(ave*sigma) I21=-ave*sigma % % (The second kind)The mean increasing and standard variance % % decreasing with the enhancement of mixing % sigma=sqrt(sum/num); % I1=sqrt(sum1/num) % I2=1-sigma/ave % I4=sigma*sigma/(1-ave)/ave % I5=sqrt(sum/(num-1))/ave % I6=sigma % I20=ave/sigma % I21=-sigma/ave % Construct data variable to export into an excel sheet excel_data(k,1)=k; excel_data(k,2)=I1; excel_data(k,3)=I2; excel_data(k,4)=I4; excel_data(k,5)=I5; excel_data(k,6)=I6; excel_data(k,7)=I20; excel_data(k,8)=I21; end disp('Mixing indexes are computed completely!'); % Export the computing results into an excel sheet excel_outpath='D:\experimental images\experimental results 1.xls'; % Construct the head of excel sheet excel_head={'Serial number','I1','I2','I4','I5','I6','I20','I21'}; rtn=xlswrite(excel_outpath,excel_head,'A1:H1'); disp('Excel head is complished!'); %export data into an excel sheet xlswrite(excel_outpath,excel_data,'A2:H9') disp('Excel data output completely!');