Results 1 to 22 of 22

Thread: color purity..ideas

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2005
    Posts
    125

    Lightbulb color purity..ideas

    Hi, is there a way that a specific pixel point can be rounded to its nearest pure color in its current state and then using an if statment to act if that color changes?

    I can get the decimal values for pixel colors using the getpixel api, but my problem with that is the numbers changes very slightly with even the smallest different shade of the same color. Though i can work with that its a real hassle when you can come up with 10 different decimal values for something to the plain eye is black.

    For example, if i look at two pixels side by each other that look like they are black but one of them has the decimal value of 2565927 and the next one is 1315860, could i create a code for my program to read each of those pixel positions and consider them as being 0 - pure black.

    Ive searched around the forum for converting and determining shades but only knowing the bare basics of pixel color values I didnt manage to understand too much. So any code of this subject would be awesome. Thanks
    Last edited by Resilience; Aug 3rd, 2005 at 12:24 AM.
    --- Science does not explain why things are what they are. What we get from Science is our interpretation of how things do what they do.
    --- No Scientific law of the universe is stable, we did not create it, and we will never understand all of its abilities.
    --- What we determine as reality is a mere assumption of what tomorrow will be based on what yesterday was.

  2. #2
    Member
    Join Date
    Mar 2004
    Location
    Computer
    Posts
    56

    Re: color purity

    Couldn't you just round the numbers? I believe the syntax would be:
    Code:
    Round(StrNumber, 0)
    The 0 is the number of numbers after the decimel. Just try that and see if it works.
    ~!~Computer Nerd~!~

  3. #3

    Thread Starter
    Lively Member
    Join Date
    May 2005
    Posts
    125

    Re: color purity

    sorry im not sure how i would use that. there isnt actually a decimal point in the value for the color. After reading other posts many members just labeled that format of color value as the decimal value. where there are other formats of hex,rgb,html.
    --- Science does not explain why things are what they are. What we get from Science is our interpretation of how things do what they do.
    --- No Scientific law of the universe is stable, we did not create it, and we will never understand all of its abilities.
    --- What we determine as reality is a mere assumption of what tomorrow will be based on what yesterday was.

  4. #4
    Member
    Join Date
    Mar 2004
    Location
    Computer
    Posts
    56

    Re: color purity

    Ah, then I'm sorry, I can't help you
    ~!~Computer Nerd~!~

  5. #5
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: color purity

    Use HEX() values of colors, not decimal. Not sure of the value of Black, but it may be FFFFFF, where the first is Red, the second Green, and the last is Blue.
    FF-FF-FF. If the color is in a range, you could change it to vbBlack.

  6. #6

    Thread Starter
    Lively Member
    Join Date
    May 2005
    Posts
    125

    Re: color purity..ideas

    Hi dglienna, Ive never used hex values before and when i tried now i had to enter in numbers: hex(in here) and not letters. Checking the black pixel and comparing it to hex(0) still did not recongize it as being a pure black.

    Thanks for any help.
    --- Science does not explain why things are what they are. What we get from Science is our interpretation of how things do what they do.
    --- No Scientific law of the universe is stable, we did not create it, and we will never understand all of its abilities.
    --- What we determine as reality is a mere assumption of what tomorrow will be based on what yesterday was.

  7. #7
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: color purity..ideas

    Not sure which is the correct way to do it, but look at this to see if it helps:

    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Form_Load()
    4.  MsgBox Hex("2565927") And &HFF
    5.  MsgBox Hex("2565927") Or &HFF
    6. End Sub

  8. #8

    Thread Starter
    Lively Member
    Join Date
    May 2005
    Posts
    125

    Re: color purity..ideas

    Ok..yes that just changes the value format but how could i use that hex format to do what i described in post 1. It doesnt have to be specific of positions to wirte an example. Thanks
    --- Science does not explain why things are what they are. What we get from Science is our interpretation of how things do what they do.
    --- No Scientific law of the universe is stable, we did not create it, and we will never understand all of its abilities.
    --- What we determine as reality is a mere assumption of what tomorrow will be based on what yesterday was.

  9. #9
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: color purity..ideas

    Well, color OR &HFFFFFF is WHITE, and color OR &H0000FF is blue. The first is Red, the second Green. You would have to check if one color value is greater than the other, and use that one I think.

    EDIT: oops
    Last edited by dglienna; Aug 13th, 2005 at 10:53 PM.

  10. #10
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: color purity..ideas

    BTW &HFFFFFF is white, &h0 is black

    Anyway, what you want to do is round each color to some predetermined color resolution.
    So for instance if you have Color = &hEF0000 and &hF00000 you want to change them both to &hFF0000.
    it will take some experimenting to see what you want your resolution to be.

  11. #11

    Thread Starter
    Lively Member
    Join Date
    May 2005
    Posts
    125

    Re: color purity..ideas

    hi moeur, yes what you mentioned is what i want but my problem is i have no idea where to start on rounding hex,decimal or rgb values. I truly do not know vb6 or the pixel color structure well enough to learn how to fix this issue by even experimenting on my own.

    dglienna, using the hex values to check the different shades of black still gave me different results with each little shade change, so that didnt seem any different than using the decimal format.

    If anyone really knows how the pixel color structure works could you please give me an example that i can work from for different shades of any color being rounded to its nearest full color.

    Thank you very much.
    --- Science does not explain why things are what they are. What we get from Science is our interpretation of how things do what they do.
    --- No Scientific law of the universe is stable, we did not create it, and we will never understand all of its abilities.
    --- What we determine as reality is a mere assumption of what tomorrow will be based on what yesterday was.

  12. #12
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: color purity..ideas

    You would have to figure out which color has the greatest value.

    red = color AND &FF0000
    green = color AND &h00FF00
    blue = color AND &h0000FF

    find which on is the highest and do use the or to change it to
    the pure colour once you have each color

    you can test to see which one is bigger if red > blue and red > green etc.
    VisualAd helped with this a few weeks ago.

  13. #13

    Thread Starter
    Lively Member
    Join Date
    May 2005
    Posts
    125

    Re: color purity..ideas

    ok thank you, i didnt notice that topic and didnt find it in any searches.

    that seems simple and affective, but how would i go about using that red,blue,green method for different shades of black.

    edit, i tried adding to your reputation for your help deligenna but a message said i had to spread reputation around first. I cant help it your in every other topic helping lol.
    Last edited by Resilience; Aug 13th, 2005 at 11:25 PM.
    --- Science does not explain why things are what they are. What we get from Science is our interpretation of how things do what they do.
    --- No Scientific law of the universe is stable, we did not create it, and we will never understand all of its abilities.
    --- What we determine as reality is a mere assumption of what tomorrow will be based on what yesterday was.

  14. #14
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: color purity..ideas

    maka a small list of some of the values you got that you want to be represented by one color (say red). Post that list and then we can go from there.

  15. #15

    Thread Starter
    Lively Member
    Join Date
    May 2005
    Posts
    125

    Re: color purity..ideas

    Okay, theyre all shades of black though so Im not sure how they could be represented by red blue or green. Also I have so many different shades of black im just going to post 5 of them and do the rest on my own off of the example, unless you would rather i post the rest.

    1645858
    1843237
    2632749
    3290164
    1316893
    --- Science does not explain why things are what they are. What we get from Science is our interpretation of how things do what they do.
    --- No Scientific law of the universe is stable, we did not create it, and we will never understand all of its abilities.
    --- What we determine as reality is a mere assumption of what tomorrow will be based on what yesterday was.

  16. #16
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: color purity..ideas

    OK,

    First notice what each value is in Hexidecimal. You can view these values by using the HEx function
    Print Hex(1645858)
    gives
    191D22
    which represents three colors
    &h19 &H1D &h22
    blue green red (may be reversed depending on what gave you the numbers)
    The max single color value in your list is &h32
    If I do something like
    Me.BackColor = &h323232
    the form's backcolor turns a shade of black(grey)
    so for starters you may want to look for pure black like this
    VB Code:
    1. 'let's say lColor holds the color value
    2. Dim lColor As Long
    3. Dim Red As Byte
    4. Dim Blue As Byte
    5. Dim Green As Byte
    6.  
    7. 'split into colors
    8. Red = lColor And &HFF
    9. Green = Int(lColor \ &H100) And &HFF
    10. Blue = Int(lColor \ &H10000) And &HFF
    11.  
    12. 'turn to pure black - adjust threshold to your liking
    13. If Red < &H40 And Green < &H40 And Blue < &H40 Then lColor = 0

  17. #17

    Thread Starter
    Lively Member
    Join Date
    May 2005
    Posts
    125

    Re: color purity..ideas

    Okay, if it makes any difference i got the hexidecimal numbers from the plain getpixel Api. In the code where your splitting the colors why do you have "and &hff" (which means red right) after blue and green aswell?

    I also dont know what color &h40 is exactly but im assuming thats the color you mean by adjusting the threashold.

    So what i would do for adjusting that would be to get the hex value of the max single color i have (in what i showed you being "&h32") and adjust the comparison (in what you have as "&h40") to be just a bit higher than the max single color value, right. and for black make sure red blue and green are less than what theyre comparing to.

    Could you show me how i would get the pure color of yellow or any other color than red,blue,green,white and black?

    Thank you very much.
    --- Science does not explain why things are what they are. What we get from Science is our interpretation of how things do what they do.
    --- No Scientific law of the universe is stable, we did not create it, and we will never understand all of its abilities.
    --- What we determine as reality is a mere assumption of what tomorrow will be based on what yesterday was.

  18. #18
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: color purity..ideas

    give me an example list of another color

  19. #19

    Thread Starter
    Lively Member
    Join Date
    May 2005
    Posts
    125

    Re: color purity..ideas

    ok, these are all parts yellow

    9763583
    10026751
    10420223
    11337727
    12255231
    --- Science does not explain why things are what they are. What we get from Science is our interpretation of how things do what they do.
    --- No Scientific law of the universe is stable, we did not create it, and we will never understand all of its abilities.
    --- What we determine as reality is a mere assumption of what tomorrow will be based on what yesterday was.

  20. #20
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: color purity..ideas

    Sorry,
    didn't get email notification of your reply.
    Here is something to work with, you'll have to play with the thresholds
    VB Code:
    1. 'split into colors
    2. Sub SplitColors(lcolor As Long, red As Byte, green As Byte, blue As Byte)
    3.     red = lcolor And &HFF
    4.     green = Int(lcolor \ &H100) And &HFF
    5.     blue = Int(lcolor \ &H10000) And &HFF
    6. End Sub
    7.  
    8. 'returns true if color is in range of yellow
    9. Function PureYellow(lcolor As Long) As Boolean
    10.     Dim red As Byte
    11.     Dim green As Byte
    12.     Dim blue As Byte
    13.     PureYellow = False
    14.     Call SplitColors(red, green, blue)
    15.     If red > &HD0 Then Exit Function
    16.     If green < &HF0 Or blue < &HF0 Then Exit Function
    17.     PureYellow = True
    18. End Function
    Can you see how this is being done?
    for each of the three colors, you'll have to figure out what the conditions are for the purecolor. It will be tedious, but is doable.

  21. #21

    Thread Starter
    Lively Member
    Join Date
    May 2005
    Posts
    125

    Re: color purity..ideas

    yes meour i get the idea for the method but im curious now about the color format as i spoke of in my eariler post. I looked around for some color charts, is "&hff0000" for example the same as the html version of "#ff0000"?
    --- Science does not explain why things are what they are. What we get from Science is our interpretation of how things do what they do.
    --- No Scientific law of the universe is stable, we did not create it, and we will never understand all of its abilities.
    --- What we determine as reality is a mere assumption of what tomorrow will be based on what yesterday was.

  22. #22
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: color purity..ideas

    Yes,
    In vb &H means hexidecimal as does # in HTML
    The question i negelected to answer above was regarding And &HFF
    don't think of this as a color, but just a masking since I only want the lowest byte in the number after I do the division, And &HFF lops off everthing else.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width