均匀化直方图箱的MATLAB实现
我一直在从事一个与MATLAB中的图像分析相关的项目。其中一部分要求我创建多组直方图,以比较我为图像计算的GCLM系数的值分布 我使用的是PH2数据库,总共有200张图像(80张、80张、40张,按诊断分为三类)。我制作了直方图来显示每个诊断的分布,我还想叠加直方图来显示分布的比较情况。这是我正在使用的代码:均匀化直方图箱的MATLAB实现,matlab,image-processing,statistics,histogram,Matlab,Image Processing,Statistics,Histogram,我一直在从事一个与MATLAB中的图像分析相关的项目。其中一部分要求我创建多组直方图,以比较我为图像计算的GCLM系数的值分布 我使用的是PH2数据库,总共有200张图像(80张、80张、40张,按诊断分为三类)。我制作了直方图来显示每个诊断的分布,我还想叠加直方图来显示分布的比较情况。这是我正在使用的代码: % DECOMP MAX figure for k=1:4 subplot(2,2,1) h0 = histogram(gc
% DECOMP MAX
figure
for k=1:4
subplot(2,2,1)
h0 = histogram(gclm_decomp_max_p(diagn.ClinicalDiagnosis == 0,k),10);
h0.FaceColor = 'green';
title('Typical')
subplot(2,2,2)
h1 = histogram(gclm_decomp_max_p(diagn.ClinicalDiagnosis == 1,k),10);
h1.FaceColor = 'yellow';
title('Atypical')
subplot(2,2,3)
h2 = histogram(gclm_decomp_max_p(diagn.ClinicalDiagnosis == 2,k),10);
h2.FaceColor = 'red';
title('Melanoma')
subplot(2,2,4)
h0 = histogram(gclm_decomp_max_p(diagn.ClinicalDiagnosis == 0,k),10);
hold on
h1 = histogram(gclm_decomp_max_p(diagn.ClinicalDiagnosis == 1,k),10);
h2 = histogram(gclm_decomp_max_p(diagn.ClinicalDiagnosis == 2,k),10);
h0.FaceColor = 'green';
h1.FaceColor = 'yellow';
h2.FaceColor = 'red';
title('Overlayed')
suptitle(names_gclm{:,k})
fname = sprintf('maxdecomp%d', k);
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
saveas(gcf,fname,'png')
close all
end
我的问题从覆盖部分开始。尽管我尽了最大的努力,但我还没能让垃圾箱看起来对所有三种诊断都一模一样。我试着手动设置垃圾箱的编号以及栏和垃圾箱的宽度。有什么我遗漏的吗?我还能试什么?我将不胜感激,因为我已经智穷了
这里有两个示例图像-正如您所看到的,黑色素瘤直方图在第一个图像中的其他图像旁边完全消失了。在第二种情况下,每个组看起来都不同,因此无法比较分布。
问题在于,您需要明确地定义。你只是告诉直方图函数你想要10个箱子。这会导致数据的最小值和最大值之间的间距均匀,如果每个数据集具有不同的边界,则这是不可取的。相反,请按如下方式明确定义箱边
% DECOMP MAX
figure
for k=1:4
% determine bin edges
edge_min = min(gclm_decomp_max_p(diagn.ClinicalDiagnosis == 0 | diagn.ClinicalDiagnosis == 1 | diagn.ClinicalDiagnosis == 2,k))
edge_max = max(gclm_decomp_max_p(diagn.ClinicalDiagnosis == 0 | diagn.ClinicalDiagnosis == 1 | diagn.ClinicalDiagnosis == 2,k))
edges = linspace(edge_min, edge_max, 10+1);
subplot(2,2,1)
h0 = histogram(gclm_decomp_max_p(diagn.ClinicalDiagnosis == 0,k),edges);
h0.FaceColor = 'green';
title('Typical')
subplot(2,2,2)
h1 = histogram(gclm_decomp_max_p(diagn.ClinicalDiagnosis == 1,k),edges);
h1.FaceColor = 'yellow';
title('Atypical')
subplot(2,2,3)
h2 = histogram(gclm_decomp_max_p(diagn.ClinicalDiagnosis == 2,k),edges);
h2.FaceColor = 'red';
title('Melanoma')
subplot(2,2,4)
h0 = histogram(gclm_decomp_max_p(diagn.ClinicalDiagnosis == 0,k),edges);
hold on
h1 = histogram(gclm_decomp_max_p(diagn.ClinicalDiagnosis == 1,k),edges);
h2 = histogram(gclm_decomp_max_p(diagn.ClinicalDiagnosis == 2,k),edges);
h0.FaceColor = 'green';
h1.FaceColor = 'yellow';
h2.FaceColor = 'red';
title('Overlayed')
% set plot limits to bin bounds
xlim([edge_min edge_max]);
ax = axis();
% make sure all the axis have same limits
subplot(2,2,1);
axis(ax);
subplot(2,2,2);
axis(ax);
subplot(2,2,3);
axis(ax);
suptitle(names_gclm{:,k})
fname = sprintf('maxdecomp%d', k);
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
saveas(gcf,fname,'png')
close all
end
编辑:用完整的解决方案更新。当你说你希望箱子是统一的时,你的意思是,还是希望箱子有统一的间距,即每个箱子有相同的宽度?如果你能发布一个示例输出图像并描述它的错误,可能会更容易。@jodag-我用图像编辑了这篇文章。我希望我的问题现在更有意义!你试过在每个直方图中指定而不是指定垃圾箱的数量吗?我知道这样发表评论并不完全是一种礼貌,但我想表达我的感激之情——这很有魅力!非常感谢你。