|
灰度共生矩阵GLCM、图像均值、方差、熵、Percentile mean and SD、Kurtosis、Skewness等特征:
- function feature = feature_extracted2( im2,x,y )
- [h,w] = size(im2);
- % Gray-level histogram features
- % [n_count,x_value] = imhist(im2);
- Nt = h*w;
- % prob = n_count./Nt; % Pi概率值
- % x_value = prob;
- % x_value = im2(:);
- for i=1:length(x)
- x_value(i) = im2(x(i),y(i));
- end
- mean1 = mean(x_value); % 均值
- SD1 = std(x_value); % 方差
- % Percentile mean and SD
- x_value1 = sort(x_value,'ascend');
- mean_beta_10 = mean( x_value1(floor(0.90*length(x_value1)):end ) );
- mean_beta_25 = mean( x_value1(floor(0.75*length(x_value1)):end ) );
- mean_beta_50 = mean( x_value1(floor(0.50*length(x_value1)):end ) );
- SD_beta_10 = std( x_value1(floor(0.90*length(x_value1)):end ) );
- SD_beta_25 = std( x_value1(floor(0.75*length(x_value1)):end ) );
- SD_beta_50 = std( x_value1(floor(0.50*length(x_value1)):end ) );
- % Kurtosis
- % kurtosis1 = sum((x_value-mean1).^4)/Nt ./ sqrt( sum((x_value-mean1).^2)./Nt ).^4;
- % kurtosis1 = sum((x_value-mean1).^4) ./ sqrt( sum((x_value-mean1).^2) ).^4;
- % Skewness
- % skewness1 = sum((x_value-mean1).^3)/Nt ./ sqrt( sum((x_value-mean1).^2)./Nt ).^3;
- % skewness1 = sum((x_value-mean1).^3) ./ sqrt( sum((x_value-mean1).^2) ).^3;
- kurtosis1 = kurtosis(double(x_value));
- skewness1 = skewness(double(x_value));
- % Gray-Level Co-Occurrence Matrix(GLCM)
- % Angle OFFSET
- % ----- ------
- % 0 [0 D]
- % 45 [-D D]
- % 90 [-D 0]
- % 135 [-D -D]
- glcms_0 = graycomatrix(im2, 'offset', [0 1]); % Angle = 0
- glcms_45 = graycomatrix(im2, 'offset', [-1 1]); % Angle = 45
- glcms_90 = graycomatrix(im2, 'offset', [-1 0]); % Angle = 90
- glcms_135 = graycomatrix(im2, 'offset', [-1 -1]); % Angle = 135
- stats_0 = graycoprops(glcms_0, 'all');
- stats_45 = graycoprops(glcms_45, 'all');
- stats_90 = graycoprops(glcms_90, 'all');
- stats_135 = graycoprops(glcms_135, 'all');
- Contrast_0 = stats_0.Contrast;
- Correlation_0 = stats_0.Correlation;
- Energy_0 = stats_0.Energy;
- Homogeneity_0 = stats_0.Homogeneity;
- % 求解熵
- tGLCM = glcms_0./sum(glcms_0(:));
- entropy_0 = -sum(sum(tGLCM.*log(tGLCM+eps)));
- Contrast_45 = stats_45.Contrast;
- Correlation_45 = stats_45.Correlation;
- Energy_45 = stats_45.Energy;
- Homogeneity_45 = stats_45.Homogeneity;
- % 求解熵
- tGLCM = glcms_45./sum(glcms_45(:));
- entropy_45 = -sum(sum(tGLCM.*log(tGLCM+eps)));
- Contrast_90 = stats_90.Contrast;
- Correlation_90 = stats_90.Correlation;
- Energy_90 = stats_90.Energy;
- Homogeneity_90 = stats_90.Homogeneity;
- % 求解熵
- tGLCM = glcms_90./sum(glcms_90(:));
- entropy_90 = -sum(sum(tGLCM.*log(tGLCM+eps)));
- Contrast_135 = stats_135.Contrast;
- Correlation_135 = stats_135.Correlation;
- Energy_135 = stats_135.Energy;
- Homogeneity_135 = stats_135.Homogeneity;
- % 求解熵
- tGLCM = glcms_135./sum(glcms_135(:));
- entropy_135 = -sum(sum(tGLCM.*log(tGLCM+eps)));
- feature = [mean1,SD1,mean_beta_10,mean_beta_25,mean_beta_50,SD_beta_10,SD_beta_25,SD_beta_50,...
- kurtosis1,skewness1,...
- Contrast_0,Correlation_0,Energy_0,Homogeneity_0,entropy_0...
- Contrast_45,Correlation_45,Energy_45,Homogeneity_45,entropy_45...
- Contrast_90,Correlation_90,Energy_90,Homogeneity_90,entropy_90...
- Contrast_135,Correlation_135,Energy_135,Homogeneity_135,entropy_135];
复制代码 图像滤波函数:
- function im5 = freqfilter2(im1,delta)
- % 滤波器
- % input:
- % M,N:频域滤波器的尺寸
- % delta:带阻滤波器的截止频率
- % output:
- % H:M x N的矩阵,表示频域滤波器矩阵,数据类型为double,
- if ~isa(im1,'double')
- im1 = double(im1)/255;
- end
- % im2 = fft2(im1); % 傅里叶变换
- % im3 = fftshift(im2); % 中心化
- % [N1, N2] = size(im3);
- for i = 1:3
- for j = 1:3
- h(i,j) = -1/3.1415926/(delta.^4).*(1-(i.^2+j.^2)/2/delta/delta).*exp( -((i.^2+j.^2)./2/delta/delta) );
- end
- end
- im5 = conv2(im1,h,'same');
- % result = ifftshift(result); % 反中心化
- % im4 = ifft2(result); % 反变换
- % % im5 = im2uint8(real(im4)); % 滤波图像
- % im5 = abs(real(im4)); % 滤波图像
- minV = min(min(im5));
- maxV = max(max(im5));
- im5 = 255.0*(im5-minV)./(maxV-minV);
- end
复制代码 图像特征求解,主程序:
- clc,clear,close all
- warning off
- im = dicomread('例图2.dcm');
- im = mat2gray(im);
- % figure(1),imshow(im)
- % 扣出感兴趣区域
- bw = im>0;
- % figure(2),imshow(bw)
- [x,y] = find(bw==1);
- im1 = im(min(x):max(x),min(y):max(y));
- bw = im2bw(im1);
- [x,y] = find(bw==1);
- minV = min(min(im1));
- maxV = max(max(im1));
- im1 = 255.0*(im1-minV)./(maxV-minV);
- % im1 = im2uint8(im1);
- figure(3),imshow(im1,[])
- [h,w] = size(im1);
- delta = [0.0,1.0,1.5,2.0,2.5];
- feature_total = [];
- for i = 1:length(delta)
-
- if isequal(delta(i),0)
- im2 = im1;
- else
- % 图像滤波
- im2 = freqfilter2(im1,delta(i));
- end
- % 特征求解
- feature = feature_extracted2( im2,x,y );
-
- figure,imshow(im2,[])
- feature2(i,:) = feature;
- feature_total = [feature_total,feature];
-
- end
- %% 特征绘图
- figure(10),plot(feature_total,'ro-','linewidth',2);
- grid on
复制代码
参考资料:【1】结肠癌 淋巴转移 nomogram JCO:http://pan.baidu.com/s/1cgYzO6
【2】Development and validation of a radiomics nomogram for preoperative predicting lymph node metastasis in colorectal cancer :http://pan.baidu.com/s/1jHDBSEU
【3】图像:http://pan.baidu.com/s/1nuXmiXr
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
|