matlab - Garment Cropping from mannequin -
i have 2 images – mannequin with , without garment.
please refer sample images below. ignore jewels, footwear on mannequin, imagine second mannequin has only dress.
i want extract garment 2 images further processing.
the complexity there slight displacement in position of camera when taking 2 pictures. due simple subtraction generate garment mask not work.
can tell me how handle it?
i think need registration between 2 images can extract garment image?
any references blogs, articles , codes highly appreciated.
-- thanks
idea
this idea of how it, haven't tested gut tells me might work. i'm assuming there slight differences in pose of manequin camera attitude.
let original image a
, , clothed image b
.
take difference d = |a - b|
, apply median filter proportional largest deviation expect pose , camera attitude error: dmedian = median(d, kernelsize)
.
quantize dmedian
binary mask dmask = q(dmedian, threshold)
using appropriate threshold values obtain approximate mask garment (this smaller garment due median filter). reject shapes in dmedian
have small area setting pixels 0.
expand shape(s) in dmask
proportionally size of median kernel emask=expand(dmask, k*kernelsize)
. construct difference in masks fmask=|dmask - emask|
contains areas of pixels garment edge expected be. every pixel in fmask
in area, find correlation cxy
between a
, b
using small neighbourhood, store correlations image c=1.0 - corr(a,b, fmask, n)
.
your final garment mask m=c+dmask
.
explanation
since image has nice , continuous swatches of colour, difference between 2 similar images thin lines , small gradients pose , camera attitude different. when taking median filter of difference image on sufficiently large kernel, these lines removed because in minority of pixels.
the garment on other hand (hopefully) have significant difference colors in unclothed version. , generate bigger difference. thresholding difference after median filter should give rough mask of garment undersized dues of pixels on edge being rejected due median values being low. stop here if approximation enough you.
by expanding mask obtained above probable region "true" edge. above process has served narrow our search region true edge considerably , can apply more costly correlation search between images along edge find garment is. high correlation means no carment , low correlation means garment.
we use inverted correlation alpha value smaller mask obtain alpha valued mask of garment can used extracting it.
clarification
expand: mean "expanding mask" find contour of mask region , outsetting/growing/enlarging make larger.
corr(a,b,fmask,n)
: arbitrarily chosen correlation function gives correlation between pixels in a
, b
selected mask fmask
using region of size n
. function returns 1.0
perfect match , 0.0
anti-match each pixel tested. function pseudocode:
foreach px_pos in fmask fmask[px_pos] == 1 ap = subregion(a, px_pos, size) - mean(mean(a)); bp = subregion(b, px_pos, size) - mean(mean(b)) cxy = sum(sum(ap .* bp))*sum(sum(ap .* bp)) / (sum(sum(ap.*ap))*sum(sum(bp.*bp))) c[px_pos] = 1.0 - cxy; end
where subregion
selects region of size size
around pixel position px_pos
. can see if ap == bp
cxy=1
Comments
Post a Comment