【发布时间】:2014-10-01 06:03:26
【问题描述】:
我想识别图像中的发红,然后将该值与另一张图像中的发红进行比较。我对 Matlab 很陌生,没有图像处理知识。但是,我一直在尝试一些随机技术来做到这一点。到目前为止,我已经使用了单个图像的 RGB 通道的直方图,并且还比较了单个图像中 RGB 通道的平均数值。不幸的是,我在这两种情况下都看到了几乎相似的结果,并且无法识别红色较少和红色较多的图像之间的区别。
我也随机尝试使用灰度直方图,但发现它没用。
附:我在这个论坛上搜索并试图找到类似的问题,但我没有找到任何可以帮助我的东西。 我需要的是: 一种。哪种技术可用于检查图像中的发红? 湾。 Matlab 有什么帮助吗?
%-------------------------------------------
%For histograms of all 3 RGB channels in an image
i = imread('<Path>\a7.png');
imgr = i(:,:,1);
imgg = i(:,:,2);
imgb = i(:,:,3);
histr = hist(imgr(:), bins);
histg = hist(imgg(:), bins);
histb = hist(imgb(:), bins);
hfinal = [histr(:); histg(:); histb(:)];
plot(bins, histr);
%-------------------------------------------
%To compare mean values of R channels of all images
clear all;
%read all images in a sequence
flist=dir('<Path>\*.png');
for p = 1:length(flist)
for q = 1 : 3
fread = strcat('<Path>\',flist(p).name);
im = imread(fread);
meanim(p,q) = mean2(im(:,:,q));
end
end
%disp(meanim);
rm = meanim(:,1);
frm = sum(rm(:));
gm = meanim(:,2);
fgm = sum(gm(:));
bm = meanim(:,3);
fbm = sum(bm(:));
figure();
set(0,'DefaultAxesColorOrder',[1 0 0;0 1 0;0 0 1]);
pall = [rm(:), gm(:), bm(:)];
plot(pall);
title('Mean values of R, G and B in 12 images');
leg1 = legend('Red','Green','Blue', ...
'Location','Best');
print (gcf, '-dbmp', 'rgbchannels.bmp')
sm = sum(meanim);
fsum = sum(sm(:));
% disp(fsum);
f2 = figure(2);
set(f2, 'Name','Average Values');
t = uitable('Parent', f2, 'Position', [20 20 520 380]);
set(t, 'ColumnName', {'Average R', 'Average G', 'Average B'});
set(t, 'Data', pall);
print (gcf, '-dbmp', 'rgbtable.bmp') ;
rgbratio = rm ./ fsum;
disp(rgbratio);
f3 = figure(3);
aind = 1:6;
hold on;
subplot(1,2,1);
plot(rgbratio(aind),'r+');
title('Plot of anemic images - having more pallor');
nind = 7:12;
subplot(1,2,2);
plot(rgbratio(nind),'b.');
title('Plot of non anemic images - having less pallor');
hold off;
print (gcf, '-dbmp', 'anemicpics.bmp');
【问题讨论】:
-
谢谢大卫。这是两个链接:proped.ucoz.ru/_ph/5/140053931.jpgmeddean.luc.edu/lumen/meded/mech/cases/case7/conjunct.jpg我只需要裁剪的结膜(内眼睑)图像,我没有使用整个眼睛的图像。
-
你去。不过这些照片真的很吓人!我不知道如何裁剪图片,抱歉。
-
您可能有兴趣查看我不久前写给search for red objects in random images 的一些代码。经过一番反复试验,我发现
redness = max(0,r-(max(g,b)+abs(g-b)))给出了相当不错的结果。
标签: matlab image-processing rgb