Click here to Skip to main content
15,868,340 members
Please Sign up or sign in to vote.
1.22/5 (2 votes)
See more:
I have image:

someImage.jpg

Image<bgr,byte> someImage = new Image<bgr,byte>(someImage.jpg);

How can I make black color transparent?
Posted
Comments
BillWoodruff 30-Nov-13 21:46pm    
You need to ask detailed questions, and to describe the tools you have at hand, and the goal you have in mind. Specify which .NET technology you are using. If you are using some 3rd. party library, like Emgu, it becomes even more important to be very detailed.

We're not psychics.

You don't need EMGU or OpenCV to do that. You need to read your image into array of pixels and do whatever you want with them. You image is way to simple to apply image recognition (in a way, you can consider it as a result of already performed image recognition).

You can use System.Drawing.Bitmap.LockBits:
http://msdn.microsoft.com/en-us/library/system.drawing.bitmap.lockbits%28v=vs.110%29.aspx[^],
http://msdn.microsoft.com/en-us/library/System.Drawing.Bitmap%28v=vs.110%29.aspx[^].

To see some code sample, load the first MSDN page referenced above and click on one or another method.

—SA
 
Share this answer
 
If you display this on a form you can set the "transparency key"

C#
public void InitializeMyForm()
 {
    this.BackColor = Color.Black;
    // Make the background color of form display transparently. 
    this.TransparencyKey = BackColor;
 }


If this doesn't work you may need to set that image as your background image then call
C#
this.TransparencyKey = Color.Black;
 
Share this answer
 
Comments
Mich_90 30-Nov-13 20:15pm    
I need the image to calculate histogram.I dont want to make calculation on black pixels.
Hi there,
First, if i want to make a part of my image transparent, i use to add (Alpha channel) using Gimp software.

Now after that, you have many options to fetch for black color, i suggest you write a black color filter. next, you delete the fetched result. and that should do it.

if you have problems with Emgu coding, i suggest you go to www.emgu.com/forum

Good Luck,
z3ngew
 
Share this answer
 
v2
Set the Transparent color for the Form to "Black". So where ever the black color is there that will be transparent.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900