|
-
Aug 2nd, 2005, 10:34 PM
#1
Thread Starter
Lively Member
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.
-
Aug 2nd, 2005, 10:41 PM
#2
Member
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.
-
Aug 2nd, 2005, 10:48 PM
#3
Thread Starter
Lively Member
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.
-
Aug 2nd, 2005, 10:59 PM
#4
Member
Re: color purity
Ah, then I'm sorry, I can't help you
-
Aug 3rd, 2005, 12:16 AM
#5
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.
-
Aug 3rd, 2005, 12:34 AM
#6
Thread Starter
Lively Member
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.
-
Aug 3rd, 2005, 02:19 AM
#7
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:
Option Explicit
Private Sub Form_Load()
MsgBox Hex("2565927") And &HFF
MsgBox Hex("2565927") Or &HFF
End Sub
-
Aug 3rd, 2005, 02:46 PM
#8
Thread Starter
Lively Member
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.
-
Aug 3rd, 2005, 03:35 PM
#9
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.
-
Aug 3rd, 2005, 05:16 PM
#10
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.
-
Aug 13th, 2005, 10:49 PM
#11
Thread Starter
Lively Member
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.
-
Aug 13th, 2005, 11:02 PM
#12
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.
-
Aug 13th, 2005, 11:12 PM
#13
Thread Starter
Lively Member
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.
-
Aug 14th, 2005, 12:14 AM
#14
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.
-
Aug 14th, 2005, 12:47 AM
#15
Thread Starter
Lively Member
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.
-
Aug 14th, 2005, 01:07 AM
#16
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:
'let's say lColor holds the color value
Dim lColor As Long
Dim Red As Byte
Dim Blue As Byte
Dim Green As Byte
'split into colors
Red = lColor And &HFF
Green = Int(lColor \ &H100) And &HFF
Blue = Int(lColor \ &H10000) And &HFF
'turn to pure black - adjust threshold to your liking
If Red < &H40 And Green < &H40 And Blue < &H40 Then lColor = 0
-
Aug 14th, 2005, 01:29 AM
#17
Thread Starter
Lively Member
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.
-
Aug 14th, 2005, 01:31 AM
#18
Re: color purity..ideas
give me an example list of another color
-
Aug 14th, 2005, 01:41 AM
#19
Thread Starter
Lively Member
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.
-
Aug 14th, 2005, 06:40 PM
#20
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:
'split into colors
Sub SplitColors(lcolor As Long, red As Byte, green As Byte, blue As Byte)
red = lcolor And &HFF
green = Int(lcolor \ &H100) And &HFF
blue = Int(lcolor \ &H10000) And &HFF
End Sub
'returns true if color is in range of yellow
Function PureYellow(lcolor As Long) As Boolean
Dim red As Byte
Dim green As Byte
Dim blue As Byte
PureYellow = False
Call SplitColors(red, green, blue)
If red > &HD0 Then Exit Function
If green < &HF0 Or blue < &HF0 Then Exit Function
PureYellow = True
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.
-
Aug 15th, 2005, 04:00 PM
#21
Thread Starter
Lively Member
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.
-
Aug 15th, 2005, 05:23 PM
#22
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|