Question Is it possible to code a color seperation program

inkedgfx

Well-known member
Joined
Sep 29, 2012
Messages
139
Location
USA
Programming Experience
Beginner
I am interested in coding a color seperation program for the printing industry. what I would like to do is have the program seperate
all the colors in the image and put each color in its own picturebox.....so lets say the image has 3 colors in it...the program will get all
of the pixel in each color and put them into seperate pictureboxes in greyscale.......then I would like to be able to print the contents of
each picturebox seperately......is this even possible in VB.NET?



thank you

InkedGFX
 
Could you try reading in the RGB values of each pixel and then seperate that into its Red, Blue and Green values.
So when you say 'Put the color in its own picture box' what do you mean by that exactly?
 
I tried reading the r,g and b color values ...but what it does is fill the whole picturebox with a solid red , green or blue....I need the program to get each color ...then set the picturebox with just that colors pixels...if that makes sence.

Inkedgfx
 
Hi,

I am not great with graphics but after a quick look on the net I hashed together this example which will save the individual RGB colour of each pixel from an original image in it's own PictureBox. Maybe you can use this as a starting point for what you are trying to do?

You will need 4 PictureBox's and a button on a form. Then add any image you want to PictureBox1 and then run.

VB.NET:
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
  Dim xPos As Integer
  Dim yPos As Integer
 
  Dim myBitMap As New Bitmap(PictureBox1.Image)
  Dim RedBM As New Bitmap(myBitMap.Width, myBitMap.Height)
  Dim GreenBM As New Bitmap(myBitMap.Width, myBitMap.Height)
  Dim BlueBM As New Bitmap(myBitMap.Width, myBitMap.Height)
 
  PictureBox2.Image = RedBM
  PictureBox3.Image = GreenBM
  PictureBox4.Image = BlueBM
 
  For xPos = 0 To myBitMap.Width - 1
    For yPos = 0 To myBitMap.Height - 1
      With myBitMap.GetPixel(xPos, yPos)
        RedBM.SetPixel(xPos, yPos, Color.FromArgb(.R, 0, 0))
        GreenBM.SetPixel(xPos, yPos, Color.FromArgb(0, .G, 0))
        BlueBM.SetPixel(xPos, yPos, Color.FromArgb(0, 0, .B))
      End With
    Next yPos
  Next xPos
End Sub

Hope it helps.

Cheers,

Ian
 
IanRyder

thank you for the reply... this works , but what it does is colors the whole picbox red or green or blue...but this does show the image...see the screen shot below....what I need if to invert the image so only the color parts are filled...not the white areas.....

ColorSeppreview.jpg

thank you for your help

InkedGFX
 
Pure white is RBG triplet (255,255,255), but when you extract only one of those values you get a color that is pure Red, Green or Blue. Same goes for the "white" in that image, which has RBG values around 240-250. To filter those out you need to set a treshold for brightness, for example ignore all values larger than 0.9 something. Try this in the extraction loop:
If .GetBrightness > 0.97 Then Continue For
 
this works.....I had to change the brightness to 0.91 to get all the color in the image.....

Thank You

InkedGFX
 
Back
Top