Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Image Processing - Dress Segmentation using opencv

image

I am working on dress feature identification using opencv. As a first step, I need to segment t-shirt by removing face and hands from the image. Any suggestion is appreciated.

like image 407
Amarnath R Avatar asked Apr 24 '16 10:04

Amarnath R


People also ask

Can OpenCV be used for image processing?

OpenCV is a pre-built, open-source CPU-only library (package) that is widely used for computer vision, machine learning, and image processing applications.

Which segmentation is best for image processing?

Edge-Based Segmentation Edge-based segmentation is one of the most popular implementations of segmentation in image processing. It focuses on identifying the edges of different objects in an image.

What is image segmentation in image processing?

Image segmentation is a method in which a digital image is broken down into various subgroups called Image segments which helps in reducing the complexity of the image to make further processing or analysis of the image simpler. Segmentation in easy words is assigning labels to pixels.


1 Answers

I suggest the following approach:

  1. Use Adrian Rosebrock's skin detection algorithm for detecting the skin (thank you for Rosa Gronchi for his comment).
  2. Use region growing algorithm on the variance map. The initial seed can be calculated by using stage 1(see the attached code for more information).

code:

%stage 1: skin detection -  Adrian Rosebrock solution
im = imread(<path to input image>);
hsb = rgb2hsv(im)*255;

skinMask = hsb(:,:,1) > 0 & hsb(:,:,1) < 20;
skinMask = skinMask & (hsb(:,:,2) > 48 & hsb(:,:,2) < 255);
skinMask = skinMask & (hsb(:,:,3) > 80 & hsb(:,:,3) < 255);
skinMask = imclose(skinMask,strel('disk',6));

%stage 2: calculate top, left and right centroid from the different connected
%components of the skin
stats = regionprops(skinMask,'centroid');
topCentroid = stats(1).Centroid;
rightCentroid = stats(1).Centroid;
leftCentroid = stats(1).Centroid;
for x = 1 : length(stats)
    centroid = stats(x).Centroid;
    if topCentroid(2)>centroid(2)
        topCentroid = centroid;
    elseif centroid(1)<leftCentroid(1)
        leftCentroid = centroid;
    elseif centroid(1)>rightCentroid(1)
        rightCentroid = centroid;
    end
end

%first seed - the average of the most left and right centroids.
centralSeed = int16((rightCentroid+leftCentroid)/2);

%second seed - a pixel which is right below the face centroid.
faceSeed = int16(topCentroid);
faceSeed(2) = faceSeed(2)+40; 

%stage 3: std filter
varIm = stdfilt(rgb2gray(im));

%stage 4 - region growing on varIm  using faceSeed and centralSeed
res1=regiongrowing(varIm,centralSeed(2),centralSeed(1),8);
res2=regiongrowing(varIm,faceSeed(2),faceSeed(1),8);
res = res1|res2;

%noise reduction
res = imclose(res,strel('disk',3));
res = imopen(res,strel('disk',2));

result after stage 1(skin detection):

skin detection

final result:

final result

Comments:

  1. Stage 1 is calculated using the following algorithm.
  2. The region growing function can be downloaded here.
  3. The solution is not perfect. For example, it may fail if the texture of the shirt is similar to the texture of the background. But I think that it can be a good start.
  4. Another improvement which can be done is to use a better region growing algorithm, which doesn't grows into the skinMask location. Also, instead of using the region growing algorithm twice independently, the result of the second call of region growing can can be based on the result from the first one.
like image 140
ibezito Avatar answered Sep 28 '22 08:09

ibezito