graphics2D and hit highlighting

Discussion in 'Java' started by gwoodhouse@gmail.com, Mar 11, 2008.

  1. Guest

    I hope that someone out there knows alot more about graphics than i
    do.

    Im currently trying to "hit highlight" a document, given the image and
    a set of coordinates of the rectangles to draw (the "hits"). Sounds
    easy right?

    My problem is this: on black and white images, it works well by using
    the setXORmode() to only draw the highlights graphics onto the white
    background - in this way it doesnt obscuse the black text (ie, the
    color is only overlayed onto the white, not onto the black).

    On greyscale images however, i can't figure out how to set a "range"
    of color for "white" and a range of color for "black". Meaning i can
    only draw translucent rectangles over the graphics object - partially
    obscuring the black lettering and making "highlighted" words harder to
    see.

    Now im fine with having this very slight worry going on - just
    changing the color makes things clearer but my boss isnt. after hours
    of google searching and reading the API's i thought i would risk
    asking you bunch of pro's.

    Does anyone know a way i can accomplish this - even a clue as to where
    to look would be really really greatly appreciated!

    Graeme
    , Mar 11, 2008
    #1
    1. Advertising

  2. Jeff Higgins Guest

    wrote:
    >I hope that someone out there knows alot more about graphics than i
    > do.
    >
    > Im currently trying to "hit highlight" a document, given the image and
    > a set of coordinates of the rectangles to draw (the "hits"). Sounds
    > easy right?
    >
    > My problem is this: on black and white images, it works well by using
    > the setXORmode() to only draw the highlights graphics onto the white
    > background - in this way it doesnt obscuse the black text (ie, the
    > color is only overlayed onto the white, not onto the black).
    >
    > On greyscale images however, i can't figure out how to set a "range"
    > of color for "white" and a range of color for "black". Meaning i can
    > only draw translucent rectangles over the graphics object - partially
    > obscuring the black lettering and making "highlighted" words harder to
    > see.
    >
    > Now im fine with having this very slight worry going on - just
    > changing the color makes things clearer but my boss isnt. after hours
    > of google searching and reading the API's i thought i would risk
    > asking you bunch of pro's.
    >
    > Does anyone know a way i can accomplish this - even a clue as to where
    > to look would be really really greatly appreciated!
    >


    I have absolutely no idea, but a quick web search
    produces these two, maybe they'll help. Good luck.

    <http://www.webbasedprogramming.com/Tricks-of-the-Java-Programming-Gurus/ch12.htm>
    <http://www.seismo.unr.edu/ftp/pub/ichinose/JavaWorm/ImageMap.java>
    Jeff Higgins, Mar 11, 2008
    #2
    1. Advertising

  3. Guest

    Hi Jeff,

    Thanks for the reply - Went through those links and they only contain
    information ove already got :( Although they did give me a curiousity
    into Image Filtering - perhaps something along this avenue might help
    me - although it seems i would have to do some pretty intensive image
    proccessing to get the results i wanted.

    Still up for more responses if anyone else has any similar experience!
    The more help the better! :)

    Thanks again!

    Graeme
    , Mar 11, 2008
    #3
  4. Jeff Higgins Guest

    gwoodhouse wrote:
    > Hi Jeff,
    >
    > Thanks for the reply - Went through those links and they only contain
    > information ove already got :( Although they did give me a curiousity
    > into Image Filtering - perhaps something along this avenue might help
    > me - although it seems i would have to do some pretty intensive image
    > proccessing to get the results i wanted.
    >
    > Still up for more responses if anyone else has any similar experience!



    > The more help the better! :)


    Maybe some idea of what your 'document' and 'image' are would help to
    raise more replys. Is your 'image document' an image in the sense of
    a java.awt.Image, or some type of text document, or an 'image' of a
    text document, or .. Are you using somejavax.swing.Component to display
    your image?
    Jeff Higgins, Mar 11, 2008
    #4
  5. wrote:
    > I hope that someone out there knows alot more about graphics than i
    > do.
    >
    > Im currently trying to "hit highlight" a document, given the image and
    > a set of coordinates of the rectangles to draw (the "hits"). Sounds
    > easy right?
    >
    > My problem is this: on black and white images, it works well by using
    > the setXORmode() to only draw the highlights graphics onto the white
    > background - in this way it doesnt obscuse the black text (ie, the
    > color is only overlayed onto the white, not onto the black).
    >
    > On greyscale images however, i can't figure out how to set a "range"
    > of color for "white" and a range of color for "black". Meaning i can
    > only draw translucent rectangles over the graphics object - partially
    > obscuring the black lettering and making "highlighted" words harder to
    > see.
    >
    > Now im fine with having this very slight worry going on - just
    > changing the color makes things clearer but my boss isnt. after hours
    > of google searching and reading the API's i thought i would risk
    > asking you bunch of pro's.
    >
    > Does anyone know a way i can accomplish this - even a clue as to where
    > to look would be really really greatly appreciated!
    >
    > Graeme


    XOR it with a bit mask. I used AFAFAF for something the other day but
    you can play with that to make it work better for your particular image.

    --

    Knute Johnson
    email s/nospam/linux/

    --
    Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
    ------->>>>>>http://www.NewsDem
    Knute Johnson, Mar 11, 2008
    #5
  6. wrote:
    > I hope that someone out there knows alot more about graphics than i
    > do.
    >
    > Im currently trying to "hit highlight" a document, given the image and
    > a set of coordinates of the rectangles to draw (the "hits"). Sounds
    > easy right?
    >
    > My problem is this: on black and white images, it works well by using
    > the setXORmode() to only draw the highlights graphics onto the white
    > background - in this way it doesnt obscuse the black text (ie, the
    > color is only overlayed onto the white, not onto the black).
    >
    > On greyscale images however, i can't figure out how to set a "range"
    > of color for "white" and a range of color for "black". Meaning i can
    > only draw translucent rectangles over the graphics object - partially
    > obscuring the black lettering and making "highlighted" words harder to
    > see.
    >
    > Now im fine with having this very slight worry going on - just
    > changing the color makes things clearer but my boss isnt. after hours
    > of google searching and reading the API's i thought i would risk
    > asking you bunch of pro's.
    >
    > Does anyone know a way i can accomplish this - even a clue as to where
    > to look would be really really greatly appreciated!
    >
    > Graeme


    My preference is to produce the effect of using a highlighter pen on a
    paper document. This involves alpha compositing the highlight area on
    top of the regular document. Pick a suitable highlight colour, and try
    different transparency. XOR was a computationally cheap trick, but the
    visual result was never ideal (except perhaps on two level monotone
    displays where it was the best you could do). You should also consider
    giving the user a selection of the usual iridescent highlight colours.

    Mark Thornton
    Mark Thornton, Mar 11, 2008
    #6
  7. Michael Jung Guest

    "" <> writes:
    > Im currently trying to "hit highlight" a document, given the image and
    > a set of coordinates of the rectangles to draw (the "hits"). Sounds
    > easy right?

    [...]
    > On greyscale images however, i can't figure out how to set a "range"
    > of color for "white" and a range of color for "black". Meaning i can
    > only draw translucent rectangles over the graphics object - partially
    > obscuring the black lettering and making "highlighted" words harder to
    > see.


    Let "a" be the greyscale value in the range [0,1]. You can then set
    the new pixel value b=a*a, making it darker, or b=(1-a)(1-a), making
    it lighter. There are other transformations mapping [0,1] to [0,1]
    (you could even do b=1-a, somewhat akin to XOR.) You may also prefer
    to only highlight on the boundary.

    Michael
    Michael Jung, Mar 11, 2008
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Wong Chee Wee

    Graphics2D and Panels

    Wong Chee Wee, Jul 17, 2003, in forum: Java
    Replies:
    2
    Views:
    499
    Wong Chee Wee
    Jul 18, 2003
  2. David Patterson
    Replies:
    1
    Views:
    423
    David Patterson
    Aug 22, 2003
  3. Michael C. Gilson
    Replies:
    4
    Views:
    947
    Ken DeLong
    Aug 31, 2003
  4. Amadeus
    Replies:
    0
    Views:
    491
    Amadeus
    Sep 2, 2003
  5. CK
    Replies:
    9
    Views:
    381
    Jerry Rasmussen
    Oct 19, 2006
Loading...

Share This Page