graphics2D and hit highlighting

G

gwoodhouse

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
 
J

Jeff Higgins

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>
 
G

gwoodhouse

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
 
J

Jeff Higgins

gwoodhouse said:
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?
 
K

Knute Johnson

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.
 
M

Mark Thornton

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
 
M

Michael Jung

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top