AForge.NET

  :: AForge.NET Framework :: Articles :: Forums ::

Change Background colour of extracted blob

The forum is to discuss topics related to different areas of image processing and computer vision.

Change Background colour of extracted blob

Postby RGulliver » Tue Sep 06, 2016 12:07 am

Hi Guys,

Firstly, congratulations on a fantastic framework.

I have successfully extracted shaped blobs from an image and saved the individual blobs as separate image files for further processing. They extracted blobs which are saved in PNG format have transparent backgrounds, how can I change the background colour to black(0,0,0) on extraction and saving.

thanks in advance

Richard
RGulliver
 
Posts: 4
Joined: Tue Sep 06, 2016 12:01 am

Re: Change Background colour of extracted blob

Postby RGulliver » Tue Sep 06, 2016 12:27 pm

Hi guys,

Resolved the issue myself by creating an 24bit image and copying the extracted blob to that image, the background colour is now black(0,0,0)

Code: Select all
Do While i < n
            If (blobs.Length > 0) Then
                blobCounter.ExtractBlobsImage(Bitmap, blobs(i), False)
                Dim glassPane32 As Bitmap = blobs(i).Image.ToManagedImage()
                Dim glassPane24 As New Bitmap(glassPane32.Width, glassPane32.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb)
                Dim g As Graphics = Graphics.FromImage(glassPane24)
                g.DrawImage(glassPane32, 0, 0, glassPane32.Width, glassPane32.Height)
                Dim glassName As String = i & "_" & DateAndTime.Now.ToString("ddMMyyyy_HH_mm_ss") & ".png"
                glassPane24.Save(Application.StartupPath & "\process_image\" & glassName, System.Drawing.Imaging.ImageFormat.Png)
                glassPane32.Dispose()               
                glassPane24.Dispose()
                g.Dispose()
            End If
            i += 1
        Loop


Cheers Richard
RGulliver
 
Posts: 4
Joined: Tue Sep 06, 2016 12:01 am




Return to Image Processing and Computer Vision