【问题标题】:identify the redness in an image & then compare with the other image using Matlab识别图像中的红色,然后使用 Matlab 与其他图像进行比较
【发布时间】:2014-10-01 06:03:26
【问题描述】:

我想识别图像中的发红,然后将该值与另一张图像中的发红进行比较。我对 Matlab 很陌生,没有图像处理知识。但是,我一直在尝试一些随机技术来做到这一点。到目前为止,我已经使用了单个图像的 RGB 通道的直方图,并且还比较了单个图像中 RGB 通道的平均数值。不幸的是,我在这两种情况下都看到了几乎相似的结果,并且无法识别红色较少和红色较多的图像之间的区别。

我也随机尝试使用灰度直方图,但发现它没用。


(来源:ucoz.ru

(来源:luc.edu

附:我在这个论坛上搜索并试图找到类似的问题,但我没有找到任何可以帮助我的东西。 我需要的是: 一种。哪种技术可用于检查图像中的发红? 湾。 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');

【问题讨论】:

标签: matlab image-processing rgb


【解决方案1】:

您不能假设红色通道与像素本身的红色相同。一个像素的红度的一个很好的估计可以通过这样的方式来实现:

redness = max(0, red - (blue + green) / 2);

其中红色、绿色和蓝色是图像中不同 RGB 通道的值。 计算出图像的此值后,您可以通过平均或直方图等方法估计图像的红度。

【讨论】:

  • 抱歉,我没有完全理解“图像中不同 RGB 通道的值”。是不是像图片中所有像素的R、G、B的平均值一样?
  • 不,红绿蓝和你自己代码中的imgr、imgg、imgb完全一样。祝你好运!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-12-01
  • 2011-08-25
  • 2015-10-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多