andrew.kirillov wrote:When you say the code does not work, what does it really mean? Exception? Error? An image which does not look right? Or?
i say that it doesn't work because the result as you can see in my previous post is not what i pretend. can you see the pictures that i posted?
I found a post where you posted the following:
Postby andrew.kirillov » Sat Aug 13, 2011 7:02 am
Here is the code, which will do what you need (follow documentation if there is something unclear):
- Code: Select all
Bitmap image1 = (Bitmap) Bitmap.FromFile( "d:\\test.jpg" );
Bitmap temp = Grayscale.CommonAlgorithms.BT709.Apply( image1 );
Invert invert = new Invert( );
invert.ApplyInPlace( temp );
Threshold threshold = new Threshold( );
threshold.ApplyInPlace( temp );
BlobCounter blobCounter = new BlobCounter( );
blobCounter.FilterBlobs = true;
blobCounter.MinWidth = 80;
blobCounter.MinWidth = 80;
blobCounter.ObjectsOrder = ObjectsOrder.Size;
blobCounter.ProcessImage( temp );
Blob[] blobs = blobCounter.GetObjectsInformation( );
if ( blobs.Length > 0 )
{
blobCounter.ExtractBlobsImage( temp, blobs[0], true );
FillHoles fillHoles = new FillHoles( );
fillHoles.ApplyInPlace( blobs[0].Image );
GrayscaleToRGB toRgb = new GrayscaleToRGB( );
UnmanagedImage mask = toRgb.Apply( blobs[0].Image );
Intersect intersect = new Intersect( );
intersect.UnmanagedOverlayImage = mask;
image1 = intersect.Apply( image1 );
}
And it works like a charm

, after adding "image1.MakeTransparent();" !
The only small problem now is that some black pixels on cloth where obviously made transparent.. any tip to apply transparency only around the image?