Results 1 to 7 of 7

Thread: [Advanced] Color Tolerances

  1. #1
    Join Date
    Feb 2007
    Posts
    211
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default [Advanced] DTMs to Text & Color Tolerance

    How exactly do they work? Or let me just skip exactly to what I am needing it for is to make a function like:

    function InColorTolerance(TheColorToTest, Color, Tolerance): Boolean;

    What would be the best way to do such a thing? Is tolerances done based on HSL? RGB? What?

    Help would be greatly appreciated.

    Edit1: Found theres a function all ready available to do just this:
    SCAR Code:
    function SimilarColors(col1, col2, tolerance: Integer): Boolean;


    If someone has knowledge of the super secretive DTM to string please send me a PM. Its not for public use but for an SRL project. Feel free to add my MSN if you would rather communicate there, I will not disclose the project to the community so if you have information on DTMs please find a way to contact me
    Current Project: Catching up on what I missed, re-writing some old includes I done in the past.
    Upcoming Project: Open For Suggestions

  2. #2
    Join Date
    Mar 2006
    Posts
    3,051
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    As I understand it, ColorToleranceSpeed 0 and 1 are based on RGB.

    So, to find the tolerance "distance" between two colors, you do ColorToRGB on them, and then just add the absolute value of the distance between each color component.

    Example:

    |R1 - R2| = DR
    |G1 - G2|= DG
    |B1 - B2| = DG
    Tolerance = DR + DG + DB

    Speed 0 and 1 will not always have the same result, though, so there is something else involved in the calculations as well.

    ColorToleranceSpeed 2 is based on HSL. I'm not sure exactly what the calculation is, but I assume it's similar, based on the absolute values of the distance between color 1 and color 2 on each component of H, S, and L.

    I could be totally wrong, but that's my understanding.


  3. #3
    Join Date
    Feb 2007
    Posts
    211
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanks a ton, updated my post with a bit of information! And +rep'd you.
    Current Project: Catching up on what I missed, re-writing some old includes I done in the past.
    Upcoming Project: Open For Suggestions

  4. #4
    Join Date
    Dec 2006
    Location
    Copy pastin to my C#
    Posts
    3,788
    Mentioned
    8 Post(s)
    Quoted
    29 Post(s)

    Default

    Tarajunky, as far as I know, in the HSL mode similar colors compares the Hue and Saturation of a color. When we use 0.2 and 0.2 as the modifiers, SimilarColors compares the colors if they are within Tol * 0.2 and Tol * 0.2 ranges...

  5. #5
    Join Date
    Feb 2007
    Posts
    211
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by n3ss3s View Post
    Tarajunky, as far as I know, in the HSL mode similar colors compares the Hue and Saturation of a color. When we use 0.2 and 0.2 as the modifiers, SimilarColors compares the colors if they are within Tol * 0.2 and Tol * 0.2 ranges...
    Okay what I was hoping was somewhat on the simple side after everything got converted correctly has turned out rather complex and spawned new questions.

    If I am comparing 2 Integers (The colors) will SimilarColors work, for simplicity we will say I used GetColor to get the color.
    Current Project: Catching up on what I missed, re-writing some old includes I done in the past.
    Upcoming Project: Open For Suggestions

  6. #6
    Join Date
    Dec 2006
    Location
    Copy pastin to my C#
    Posts
    3,788
    Mentioned
    8 Post(s)
    Quoted
    29 Post(s)

    Default

    SimilarColors(GetColor(326, 442), ReferenceColor, Tolerance) for example.

  7. #7
    Join Date
    Feb 2007
    Posts
    211
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by n3ss3s View Post
    SimilarColors(GetColor(326, 442), ReferenceColor, Tolerance) for example.
    I understand the functionality of it, I was just wondering if your post involved something I should keep an eye on. Back to toying with the dtm editor over and over until I can figure out dtm strings

    Sorry for the confusing part of my initial post, I posted questioning how tolerances worked because I needed to make a function, I also edited in the question about dtms, then searching through the guides I found a function that did exactly that.

    Why is SCAR ignoring colors and skipping whole rows of pixels? I was trying to make a floodfill function but scar hates it, it makes no sense. It is set so it can't cross the color of the border (even tested it again with a tolerance of 5 on the border) but yet it still does occasionally, tested adding waits with no luck, and theres random pixels it don't pickup inside the floodfill -.- oh well i pulled an all nighter going to go get breakfast and take a nap
    Current Project: Catching up on what I missed, re-writing some old includes I done in the past.
    Upcoming Project: Open For Suggestions

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 5
    Last Post: 07-31-2007, 07:23 PM
  2. How Do I Use Tolerances?
    By Timer in forum OSR Help
    Replies: 10
    Last Post: 07-27-2007, 07:01 PM
  3. Useing grass color as road color??????
    By ronny.m.p in forum OSR Help
    Replies: 7
    Last Post: 04-28-2007, 09:42 PM
  4. dtm Q.[advanced]
    By del_signo in forum OSR Help
    Replies: 9
    Last Post: 03-20-2007, 02:09 AM

Posting Permissions

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