Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / February 2010

Tip: Looking for answers? Try searching our database.

muting background images

Thread view: 
Roedy Green - 31 Jan 2010 10:55 GMT
If you wanted to use an image as background often you need to "mute"
it, so that you can still read foreground text laid over top.

Just what do I mean by muting?

I am not quite sure, but it might consist of:

1. an effect like looking through a screen door to break the
background up and provide some uniform contrasting colour for the
lettering.

2. unenhancing contrast.

3. blurring.

4. shifting all the colours toward a mid grey tone.

Does this processing have a name?

If you do it, what tool do you use?

If there is no such tool, if someone were to create one for you, how
would you like it to behave?
Signature

Roedy Green Canadian Mind Products
http://mindprod.com
Computers are useless. They can only give you answers.
~ Pablo Picasso (born: 1881-10-25 died: 1973-04-08 at age: 91)

markspace - 31 Jan 2010 15:59 GMT
> If you wanted to use an image as background often you need to "mute"
> it, so that you can still read foreground text laid over top.
[quoted text clipped - 12 lines]
>
> 4. shifting all the colours toward a mid grey tone.

#4 is called "desaturation."

I use Gimp.  Great photo editing software.

A programmatic way of doing this would be great, especially one which
works with all Swing classes, if you're interested in doing some work.

For Swing, I'd like it to take the background color and an image and put
them together, so the image will match somewhat the requested background
color.  Probably, draw the background then draw the image at some %
transparency.  Allow the caller to specify the transparency and the
image used.  Background color is already a property in Swing classes.
John B. Matthews - 31 Jan 2010 16:58 GMT
> > If you wanted to use an image as background often you need to
> > "mute" it, so that you can still read foreground text laid over
[quoted text clipped - 28 lines]
> and the image used.  Background color is already a property in Swing
> classes.

#3, "blurring", can be done with a convolution, discussed here:

<http://www.jhlabs.com/ip/blurring.html>

and also available as part of Java Advanced Imaging.

Apple's Mac OS X feature called Exposé darkens background windows when
you press F10 to highlight Application Windows.

<http://www.apple.com/macosx/what-is-macosx/expose.html>

Here's a translucent panel that shows 100% white lettering atop a 50%
transparent black background. You can use this demo to find the value of
the result:

<http://sites.google.com/site/drjohnbmatthews/composite>

import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.Timer;

/** @author John B. Matthews */
public class Translucent extends JPanel implements ActionListener {

   private static final Font font =
       new Font("Serif", Font.PLAIN, 36);
   private static final SimpleDateFormat format =
       new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss");
   private final Timer timer = new Timer(1000, this);

   public Translucent() {
       super(true);
       this.setPreferredSize(new Dimension(360, 100));
       timer.start();
   }

   @Override
   protected void paintComponent(Graphics g) {
       Graphics2D g2d = (Graphics2D) g;
       g2d.setRenderingHint(
           RenderingHints.KEY_ANTIALIASING,
           RenderingHints.VALUE_ANTIALIAS_ON);
       g2d.setComposite(AlphaComposite.SrcAtop);
       g2d.fillRect(0, 0, getWidth(), getHeight());
       g2d.setFont(font);
       String s = format.format(new Date());
       int xx = this.getWidth();
       int yy = this.getHeight();
       int w2 = g.getFontMetrics().stringWidth(s) / 2;
       int h2 = g.getFontMetrics().getDescent();
       g2d.setColor(Color.green);
       g2d.drawString(s, xx / 2 - w2, yy / 2 + h2);
   }

   private static void create() {
       JFrame f = new JFrame();
       f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
       f.setBackground(new Color(0.0f, 0.0f, 0.0f, 0.5f));
       f.add(new Translucent());
       f.pack();
       f.setVisible(true);
   }

   public static void main(String[] args) {
       EventQueue.invokeLater(new Runnable() {
           @Override
           public void run() {
               create();
           }
       });
   }

   @Override
   public void actionPerformed(ActionEvent e) {
       this.repaint();
   }
}

Signature

John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>

RedGrittyBrick - 01 Feb 2010 10:05 GMT
> If you wanted to use an image as background often you need to "mute"
> it, so that you can still read foreground text laid over top.
[quoted text clipped - 8 lines]
>
> 2. unenhancing contrast.

contrast *reduction*.

> 3. blurring.

This shouldn't be necessary. I think it undesirable. Even pin-sharp
images can be satisfactorily used for backgrounds so long as the tonal
contrast is low across the majority of the image. One image I use is of
yachts on a lake with mountains in the background. I flipped the image
so that the yachts were on the right hand side and didn't interfere with
desktop icons (mostly on left hand side). The water, mountains and sky
don't interfere visually with desktop icons and windows. The yachts are
absolutely pin sharp.

> 4. shifting all the colours toward a mid grey tone.

I find it better to select an image that doesn't have a lot of
high-contrast visual clutter in the first place.

> Does this processing have a name?
>
> If you do it, what tool do you use?

Imagemagick, gimp, picasa, ...

> If there is no such tool, if someone were to create one for you, how
> would you like it to behave?

I find a slider with real-time preview works best for me. Ideally you
would superimpose example foreground matter (unprocessed of course).

Signature

RGB

Thomas A. Russ - 01 Feb 2010 17:17 GMT
> If you wanted to use an image as background often you need to "mute"
> it, so that you can still read foreground text laid over top.
...
> Does this processing have a name?

Watermarking?

I think that is what MS Word used for a similar feature.

Signature

Thomas A. Russ,  USC/Information Sciences Institute

Roedy Green - 04 Feb 2010 19:17 GMT
On Sun, 31 Jan 2010 02:55:34 -0800, Roedy Green
<see_website@mindprod.com.invalid> wrote, quoted or indirectly quoted
someone who said :

>If you wanted to use an image as background often you need to "mute"
>it, so that you can still read foreground text laid over top.

I have collected the ideas posted, and composed a student project to
create the tool.  See
http://mindprod.com/project/watermarkbackgrounds.html
Signature

Roedy Green Canadian Mind Products
http://mindprod.com
Computers are useless. They can only give you answers.
~ Pablo Picasso (born: 1881-10-25 died: 1973-04-08 at age: 91)



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2010 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.