AForge.NET

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

Get the specific colored pixels from an image

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

Get the specific colored pixels from an image

Postby tanismk » Thu Jun 23, 2016 8:45 pm

Hello, I worked in Matlab and got the following output against the given input. I tried to find any method that would convert matlab code to C# but could not find any. Now, I want to apply some image processing methods on the input image using Aforge library in C# to get the following output.

22.png
22.png (23.23 KiB) Viewed 10268 times


Kindly help me and reply me as soon as possible. Thank you!
tanismk
 
Posts: 2
Joined: Wed Jun 22, 2016 7:43 pm

Re: Get the specific colored pixels from an image

Postby andrew.kirillov » Fri Jun 24, 2016 7:16 am

Hello,

What are the steps you did so far? Did you try anything yourself? Did you try looking at what is available in AForge.NET?
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 3453
Joined: Fri Jan 23, 2009 9:12 am
Location: UK

Re: Get the specific colored pixels from an image

Postby tanismk » Wed Jul 20, 2016 12:14 pm

hello,
The link helped me in getting the color but it is getting only one color at a time. I want to extract all colors on a single click. How can I concatenate all these color ranges so that I get the desired output on a single click. I have following code for this..

private void process_Click(object sender, EventArgs e)
{
pictureBox3.Image = (Bitmap)pictureBox2.Image;

// create filter
ColorFiltering filter = new ColorFiltering();

// set color range of each color to be kept for further processing

//red
filter.Red = new IntRange(100, 255);
filter.Green = new IntRange(0, 75);
filter.Blue = new IntRange(0, 75);
// apply the filter
filter.ApplyInPlace((Bitmap)pictureBox2.Image);

//green
//filter.Green = new IntRange(100, 255);
//filter.Red = new IntRange(0, 100);
//filter.Blue = new IntRange(0, 150);
//// apply the filter
//filter.ApplyInPlace((Bitmap)pictureBox2.Image);

////blue
//filter.Blue = new IntRange(80, 255);
//filter.Red = new IntRange(0, 30);
//filter.Green = new IntRange(0, 70);
//// apply the filter
//filter.ApplyInPlace((Bitmap)pictureBox2.Image);

////magenta
//filter.Blue = new IntRange(0, 255);
//filter.Red = new IntRange(0, 255);
//filter.Green = new IntRange(0, 0);
//// apply the filter
//filter.ApplyInPlace((Bitmap)pictureBox2.Image);

////yellow
//filter.Blue = new IntRange(0, 136);
//filter.Red = new IntRange(170, 255);
//filter.Green = new IntRange(170, 255);
//// apply the filter
//filter.ApplyInPlace((Bitmap)pictureBox2.Image);
}

for e.g. the above code gives me the following output
s.png
s.png (146.09 KiB) Viewed 10161 times

if I un-comment the color range of green filter and comment the red color range filter, I get the following output,
g.png
g.png (149.18 KiB) Viewed 10161 times

If I un-comment all color ranges, I don't get any kind of output... What I can I do to concatenate all the color ranges?
And I would be thankul if someone can tell me the color range of the color 'magenta' :)
Thank you
tanismk
 
Posts: 2
Joined: Wed Jun 22, 2016 7:43 pm

Re: Get the specific colored pixels from an image

Postby andrew.kirillov » Wed Jul 20, 2016 3:04 pm

Hello,

You will need to perform separate filtering for different colors. However you can than combine results into single image using Merge and Add filters.
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 3453
Joined: Fri Jan 23, 2009 9:12 am
Location: UK




Return to Image Processing and Computer Vision

cron