【问题标题】:How to get skin detection running如何让皮肤检测运行
【发布时间】:2019-10-03 23:36:15
【问题描述】:

我正在尝试使用此算法检测皮肤,但我只有一张黑白图像。

我尝试使用 cat(im1,im1,im1) 组合我的图像,但结果是它只会将皮肤变成粉红色。

im= double(im);
im = colorspace('HSL<-rgb',im);

ims1 = (im(:,:,1)>95) & (im(:,:,2)>40) & (im(:,:,3)>20);
ims2 = (im(:,:,1)-im(:,:,2)>15) | (im(:,:,1)-im(:,:,3)>15);
ims3 = (abs(im(:,:,1)-im(:,:,2))>15) & (im(:,:,1)>im(:,:,3)) & (im(:,:,1)>im(:,:,2));
ims = ims1 & ims2 & ims3;

figure, imshow(ims);

我也尝试了这个算法,但没有使用任何转换,但结果只会是黑白的。

【问题讨论】:

  • 试试imshow(ims.*im)

标签: matlab


【解决方案1】:

您发布的代码的前提是您可以执行颜色阈值以隔离对应于皮肤的 HSL 颜色空间子集。

你基本上没有黑白图像的颜色信息,所以这种方法对你没有帮助。

【讨论】:

    【解决方案2】:

    试试这个

    function main
    clc, clear
    
    A = imread('2000.jpg');
    subplot(1,2,1)
    imshow(A)
    
    RGB = [230 210 200];      % color you want
    e = 40;                   % color shift     
    
    B = pix_in(A,RGB,e);
    B = B + 255.*uint8(~B);   % choosing white background
    subplot(1,2,2)
    imshow(B)
    
    end
    
    function B = pix_in(A,RGB,e)
        % select specific pixels in image
        % A - color image (3D matrix uint8)
        % RGB - [R G B] - color to select
        % e - color shift/deviation
    
    A = double(A);              % for same class operations (RGB - double)
    [m, n, ~] = size(A);
    RGB = reshape(RGB,1,1,3);   
    RGB = repmat(RGB,m,n,1);    % creating 3D matrix
    b = abs(A-RGB) < e;         % logical 3D
    b = sum(b,3) == 3;          % if [R,G,B] of a pixel in range
    B = A.*repmat(b,1,1,3);     % selecting pixels those in range
    B = uint8(B);
    
    % cheking one pixel (loop version)
    % B = [0 0 0];
    % for k = 1:3
    %     t = double(A(1,1,k));
    %     B(k) = abs(t-RGB(k)) < e;
    % end
    % if sum(B) == 3, b = true; 
    % else b = false;
    % end
    
    end
    

    原图

    这就是脚本产生的结果

    【讨论】:

      猜你喜欢
      • 2012-10-09
      • 1970-01-01
      • 2015-08-06
      • 2018-08-26
      • 2018-05-11
      • 2017-12-30
      • 2017-03-28
      • 2011-12-19
      • 1970-01-01
      相关资源
      最近更新 更多