Upload
agnianbu-wrong
View
124
Download
3
Tags:
Embed Size (px)
DESCRIPTION
Citation preview
Generic Lossless Visible Watermarking—ANew Approach
Submitted by
Manideep [Reg. Nos]
C.DuraiVenkatesh[Reg. Nos]
Govarthanan[Reg. Nos]
in the partial fulfillment for the award of the degree
of
BACHELOR OF ENGINEERING
in
Department Name Here
XXXXXXX COLLEGE OF ENGINEERING
ANNA UNIVERSITY
CHENNAI 600 025
APRIL 2010
BONAFIDE CERTIFICATE
Certified that this project report “TITLE” is the bonafide work of “XXXX (7777777),
ZZZZZZZZZZZZ (0000000000)” who carried out the project work under my supervision.
SIGNATURE SIGNATURE
HEAD OF THE DEPARTMENT SUPERVISOR
Submitted for the examination held on……………………………..
INTERNAL EXAMINER EXTERNAL EXAMINER
Completion Certificate
ABSTRACT
Abstract
A method for generic visible watermarking with a capability of lossless
image recovery is proposed. The method is based on the use of deterministic one-
to-one compound mappings of image pixel values for overlaying a variety of
visible watermarks of arbitrary sizes on cover images. The compound mappings
are proved to be reversible, which allows for lossless recovery of original images
from watermarked images.
The mappings may be adjusted to yield pixel values close to those of
desired visible watermarks. Different types of visible watermarks, including
opaque monochrome and translucent full color ones, are embedded as applications
of the proposed generic approach. A two-fold monotonically increasing compound
mapping is created and proved to yield more distinctive visible watermarks in the
watermarked image. Security protection measures by parameter and mapping
randomizations have also been proposed to deter attackers from illicit image
recoveries. Experimental results demonstrating the effectiveness of the proposed
approach are also included.
INTRODUCTION
Introduction
The advance of computer technologies and the proliferation of the Internet have
made reproduction and distribution of digital information easier than ever before.
Copyright protection of intellectual properties has, therefore, become an important topic.
One way for copyright protection is digital watermarking, which mean embedding of
certain specific information about the copyright holder (company logos, ownership
descriptions, etc.) into the media to be protected.
Digital watermarking methods for images are usually categorized into two types:
invisible and visible. The first type aims to embed copyright information imperceptibly
into host media such that in cases of copyright infringements, the hidden information can
be retrieved to identify the ownership of the protected host. It is important for the
watermarked image to be resistant to common image operations to ensure that the hidden
information is still retrievable after such alterations. Methods of the second type, on the
other hand, yield visible watermarks which are generally clearly visible after common
image operations are applied.
In addition, visible watermarks convey ownership information directly on the
media and can deter attempts of copyright violations. Embedding of watermarks, either
visible or invisible, degrade the quality of the host media in general. A group of
techniques, named reversible watermarking, allow legitimate users to remove the
embedded watermark and restore the original content as needed. However, not all
reversible watermarking techniques guarantee lossless image recovery, which means that
the recovered image is identical to the original, pixel by pixel. Lossless recovery is
important in many applications where serious concerns about image quality arise. Some
examples include forensics, medical image analysis, historical art imaging, or military
applications. Compared with their invisible counterparts, there are relatively few
mentions of lossless visible watermarking in the literature. Several lossless invisible
watermarking techniques have been proposed in the past. The most common approach is
to compress a portion of the original host and then embed the compressed data together
with the intended payload into the host. Another approach is to superimpose the spread-
spectrum signal of the payload on the host so that the signal is detectable and removable.
A third approach is to manipulate a group of pixels as a unit to embed a bit of
information .Although one may use lossless invisible techniques to embed removable
visible watermarks, the low embedding capacities of these techniques hinder the
possibility of implanting large-sized visible watermarks into host media. As to lossless
visible watermarking, the most common approach is to embed a monochrome watermark
using deterministic and reversible mappings of pixel values or DCT coefficients in the
watermark region. Another approach is to rotate consecutive watermark pixels to embed
a visible watermark. One advantage of these approaches is that watermarks of arbitrary
sizes can be embedded into any host image. However, only binary visible watermarks can
be embedded using these approaches, which is too restrictive since most company logos
are colorful. In this paper, a new method for lossless visible watermarking is proposed by
using appropriate compound mappings that allow mapped values to be controllable.
The mappings are proved to be reversible for lossless recovery of the original
image. The approach is generic, leading to the possibility of embedding different types of
visible watermarks into cover images. Two applications of the proposed method are
demonstrated, where opaque monochrome watermarks and no uniformly translucent full-
color ones are respectively embedded into color images. More specific compound
mappings are also created and proved to be able to yield visually more distinctive visible
watermarks in the watermarked image. To the best knowledge of the authors, this is the
first method ever proposed for embedding removable translucent full-color watermarks
which provide better advertising effects than traditional monochrome ones.
AIM AND SCOPE OF
PROJECT
1.1 PURPOSE OF THE SYSTEM
In this project, we describe the proposed approach to lossless
reversible visible watermarking, based on which appropriate one-to-one
compound mappings can be designed for embedding different types of
visible watermarks into images. The original image can be recovered
losslessly from a resulting watermarked image by using the corresponding
reverse mappings.
1.2 SCOPE OF THE SYSTEM
In this paper, a new method for lossless visible watermarking is proposed by using
appropriate compound mappings that allow mapped values to be controllable. The mappings are
proved to be reversible for lossless recovery of the original image. The approach is generic,
leading to the possibility of embedding different types of visible watermarks into cover images.
Two applications of the proposed method are demonstrated, where opaque monochrome
watermarks and no uniformly translucent full-color ones are respectively embedded into color
images. More specific compound mappings are also created and proved to be able to yield
visually more distinctive visible watermarks in the watermarked image. To the best knowledge
of the authors, this is the first method ever proposed for embedding removable translucent full-
color watermarks which provide better advertising effects than traditional monochrome ones.
1.3 OBJECTIVES AND SUCCESS CRITERIA
In this paper, a new method for reversible visible watermarking with
lossless image recovery capability has been proposed. The method uses one-
to-one compound mappings that can map image pixel values to those of the
desired visible watermarks. Relevant lemmas and theorems are described
and proved to demonstrate the reversibility of the compound mappings for
lossless reversible visible watermarking. The compound mappings allow
different types of visible watermarks to be embedded, and two applications
have been described for embedding opaque monochrome watermarks as
well as translucent full-color ones. A translucent watermark is clearly visible
and visually appealing, thus more appropriate than traditional transparent
binary watermarks in terms of advertising effect and copyright declaration.
The two-fold monotonically increasing property of compound mappings was
defined and an implementation proposed that can provably allow mapped
values to always be close to the desired watermark if color estimates are
accurate. Also described are parameter randomization and mapping
randomization techniques, which can prevent illicit recoveries of original
images without correct input keys. Experimental results have demonstrated
the feasibility of the proposed method and the effectiveness of the proposed
security protection measures.
SYSTEM ANALYSIS
2.1 Existing system
Embedding of watermarks, either visible or invisible, degrade the quality of the host
media in general. A group of techniques, named reversible watermarking, allow legitimate users
to remove the embedded watermark and restore the original content as needed. However, not all
reversible watermarking techniques guarantee lossless image recovery, which means that the
recovered image is identical to the original, pixel by pixel. Lossless recovery is important in
many applications where serious concerns about image quality arise. Some examples include
forensics, medical image analysis, historical art imaging, or military applications. Compared
with their invisible counterparts, there are relatively few mentions of lossless visible
watermarking in the literature. Several lossless invisible watermarking techniques have been
proposed in the past. The most common approach is to compress a portion of the original host
and then embed the compressed data together with the intended payload into the host. Another
approach is to superimpose the spread-spectrum signal of the payload on the host so that the
signal is detectable and removable. A third approach is to manipulate a group of pixels as a unit
to embed a bit of information. Although one may use lossless invisible techniques to embed
removable visible watermarks, the low embedding capacities of these techniques hinder the
possibility of implanting large-sized visible watermarks into host media. As to lossless visible
watermarking, the most common approach is to embed a monochrome watermark using
deterministic and reversible mappings of pixel values or DCT coefficients in the watermark
region. Another approach is to rotate consecutive watermark pixels to embed a visible
watermark. One advantage of these approaches is that watermarks of arbitrary sizes can be
embedded into any host image. However, only binary visible watermarks can be embedded using
these approaches, which is too restrictive since most company logos are colorful.
2.3 Proposed System:
In this project, a new method for lossless visible watermarking is proposed by using
appropriate compound mappings that allow mapped values to be controllable. The mappings are
proved to be reversible for lossless recovery of the original image. The approach is generic,
leading to the possibility of embedding different types of visible watermarks into cover images.
Two applications of the proposed method are demonstrated, where opaque monochrome
watermarks and nonuniformly translucent full-color ones are respectively embedded into color
images. More specific compound mappings are also created and proved to be able to yield
visually more distinctive visible watermarks in the watermarked image. To the best knowledge
of the authors, this is the first method ever proposed for embedding removable translucent full-
color watermarks which provide better advertising effects than traditional monochrome ones.
PROBLEM
FORMULATION
3.1HARDWARE REQUIREMENTS:
Processor : Intel Pentium IV Processor
Ram : 512MB.
Hard Disk : 40 GB.
Compact Disk : 650 MB.
Input device : Standard Keyboard and Mouse.
Output device : VGA and High Resolution Monitor.
3.2 SOFTWARE REQUIREMENTS:
Operating System : Windows XP.
Techniques : JDK 1.6
Front End : Java
Back End : Ms-Access
3.3 SOFTWARE AND TECHNOLOGIES DESCRIPTION:
3.3 Java
Java is an object-oriented programming language developed by Sun
Microsystems, Inc. It is modeled after C++, and was designed to be small, simple, and portable
across platforms and operating systems at the source level and at the binary level. Java programs,
which include applets and applications, can therefore run on any machine that has the Java
Virtual Machine, JVM, installed.
3.3.1 Advantages of Java
Java has significant advantages over other languages and environments that make it
suitable for just about any programming task.The advantages of Java are as follows:
Java is easy to learn.
Java was designed to be easy to use and is therefore easy to write, compile, debug, and
learn than other programming languages.
Java is object-oriented.
This allows you to create modular programs and reusable code.
Java is platform-independent.
One of the most significant advantages of Java is its ability to move easily from one
computer system to another. The ability to run the same program on many different systems is
crucial to World Wide Web software, and Java succeeds at this by being platform-independent at
both the source and binary levels.
Because of Java's robustness, ease of use, cross-platform capabilities and security
features, it has become a language of choice for providing worldwide Internet solutions.
3.3.2 JDBC API:
JDBC is a set of java API for executing SQL statements. This API consists of a set of
classes and interfaces to enable programmers to write pure Java Database applications. Java
Database Connectivity (JDBC) provides a database-programming API for Java programs. Java
Soft created the JDBC-ODBC bridge driver that translates the JDBC API to the ODBC API. It is
used with ODBC drivers.
The JDBC API is a java API for accessing virtually any kind of tabular data. JDBC stands
for “Java Database Connectivity”. The JDBC API consists of a set of classes and interfaces
written in the java programming language that provides a standard API for tool/database
developers and makes it possible to write industrial strength database applications using an all-
java API.
The JDBC API makes it easy to send SQL statements to relational database systems and
supports all dialects of SQL. But the JDBC 2.0 goes beyond SQL, also making it possible to
interact with other kinds of data sources, such as files containing tabular data. The value of the
JDBC API is that an application can access virtually any data source and run on any platform
with a java virtual machine. In other words, with the JDBC API, it isn’t necessary to write one
program to access a Sybase database, another program to access on Oracle database, another
program to access an IBM DB2 database and so on. One can write a single program using the
JDBC API and the program will be able to send SQL or other statements to the appropriate data
source. And, with an application written in the java programming language, one doesn’t have to
worry about writing different applications to run on different platforms.
The combination of the Java platform and the JDBC API lets a programmer write once
and run anywhere, anytime.
3.3.3 Functionality of JDBC API
The JDBC API supports three-tier model for database access. In the three-tier model,
commands are sent to a “middle tier” of services, which then sends the commands to the data
source. The data source processes the commands and sends the results back to the middle tier,
which then sends them to the user.
JDBC URLs allow driver writers to encode all necessary connection information within
them. This makes it possible, for example, for an applet that wants to talk to a given database to
open the database connection without requiring the user to do any system administration chores.
JDBC URLs allow a level of indirection. This means that the JDBC URL may refer to a
logical host or database name that is dynamically translated to the actual name by a network
naming system. This allows system administrators to avoid specifying particular hosts as part of
the JDBC name. There are a number of different network name services such as DNS, NIS and
DCE and there is no restriction about which ones can be used.
3.3.4 Different Types of Driver Managers:
Jdbc driver manager is used to connect java application to the correct JDBC driver. JDBC
driver test suite is used to ensure that the installed JDBC driver is JDBC Compliant. There are
four different types of JDBC drivers. They are as follows:
The JDBC-ODBC Bridge plus ODBC driver
Native-API partly-Java driver
JDBC-Net pure Java driver
Native-protocol pure Java driver
JDBC – ODBC Bridge Driver
The JDBC-ODBC Bridge plus ODBC driver
Sun Microsystems provides a driver to access ODBC data sources from JDBC. This
driver is called the JDBC-ODBC Bridge. The JDBC ODBC Bridge plus ODBC driver is a Java
Soft Bridge product that provides JDBC access via ODBC drivers.
Figure 7.1 JDBC Driver Manager
ResultSet
A Result Set is a Java object that contains the results of executing an SQL query. In other
words, it contains the rows that satisfy the conditions of the query. The data stored in a Result
Set object is retrieved through a set of get methods that allow access to the various columns of
the current row. The ResultSet.next method is used to move to the next row of the Result Set.
3.3.5 Features of JAVA
Platform – Independent
Changes and upgrades in operating systems, processors and system resources will not force any
change in java programs. This is the reason why Java has become a popular language for
programming on Internet.
Portable
Java ensures portability in two ways. First, java compiler generates bytecode instructions that
can be implemented on any machine. Secondly, the size of the primitive data types are machine
independent.
Object oriented
Java is a true objected oriented language. Almost everything in java is an object. All program
code and data must reside within objects and classes. Java comes with an extensive set of classes
arranged in packages, that we can use in out programs by inheritance. The object model in java
is simple and easy to extend.
Distributed
Java is designed as a distributed language for creating applications on networks. It has the
ability to share both date and programs.
Dynamic
Java is a dynamic language. Java is capable of dynamically linking new class, libraries, methods
and objects.
Secure
Since java supports applets which are programs that are transferred through internet, there may
arise a security threat. But java overcomes this problem by confining the applets to the runtime
package or JVM and thus it prevents infections and malicious contents.
Robust
Java is said to be robust in two ways Java allocates and deallocates its dynamic memory on its
own. Java provides exception.
Multithreaded
Java supports a multithreaded program which allows you to write programs that do many things
simultaneously. This is used in interactive network programs.
Interpreted
The bytecode is interpreted by JVM. Even though interpreted, Java provides high performance.
The byte code generated by the Java compiler for translating to native machine code with high
performance but the Just In Time (JIT) compiler in java.
3.3.6 JAVA components
Swing
Swing is a set of classes that provides more powerful and flexible components that are possible
with AWT and hence we adapted swing. In addition to normal components such as buttons,
check box, labels swing includes tabbed panes, scroll panes, trees and tables. It provides extra
facilities than the normal AWT components.
Layout manager
Containers use layout managers to determine the size and position of the components they
contain. Borders affect the layout of swing GUIs by making swing components larger. You can
also use invisible components to affect layout.
Event Handling
Event handling is how programs respond to external events, such as the user pressing a mouse
button. Swing program performs all their painting and event handling in the event-dispatching
thread.
Threads
If you do something to a visible component that might depend on or affect its state, then you
need to do it from the event-dispatching thread. This isn’t an issue for many simple programs,
which generally refer to components only in event-handling code. However, other programs need
to use the invoke later method to execute component-related calls in the event-dispatching
thread.
J FRAME:
Like AWT’s frame class, the J Frame class can generate events when things happen to the
window, such as the window being closed, activated, iconified or opened. These events can be
sent to a window Listener if one is registered with the frame.
J File Chooser:
It provides a simple mechanism for the user to choose a file. Here it points the users default
directory.
PL/SQL
PL/SQL is an extension of SQL.PL/SQL block can contain any number of SQL statements
integrated with flow of control statements. Thus PL/SQL combines the data manipulating power
of SQL with data processing power of procedural languages.
Forms
This is a graphical tool used for generating and executing Forms based applications. A form
basically comprises blocks and fields. Multiple tables can be accessed over a single form, based
on the application with the help of transaction commands. Oracle Forms Builder is the design
component of Oracle Forms. We can build, generate and run an Oracle Forms application from
the builder.
JAVA ENVIRONMENT
Figure 1
SYSTEM DESIGN
4.1 SYSTEM ARCHITECTURE:
4.2 USECASE DIAGRAM
4.3 Class Diagram:
SWING
JFrameJPanelJButtonJLabelJTextfieldJScrollbar
Objects
New JFrame()New JPanel()New JButton()New JLabel()New JTextfield()New JScrollbar()
METHODS
Getcontentpane()Setvisible()Add Actionlistener
JDBC
Driver Connection
Execute Query
4.4 Dataflow Diagram:
MODULES
Reversible One-to-One Compound Mapping:
Press Image Module
In this project, we are going to use two images to the
watermark procedure.
Copyright protection applications investigated is done in this
module by converting numerical values into pixel values.
Lossless Visible Watermarking Scheme:
Press Text Module
We will now derive the proposed generic lossless visible
watermarking scheme in the form of a class of one-to-one compound
mappings, which can be used to embed a variety of visible watermarks
into images. The embedding is reversible, that is, the watermark can be
removed to recover the original image lossless.
Security Considerations:
Resize Module
We do not want an attacker to be able to do the same. We propose
some security protection measures against illicit recoveries of original
images.
SYSTEM TESTING
PROCESS:
It provides a way to check the functionality of components, sub assemblies, assemblies and/or a
finished product it is the process of exercising software with the intent of ensuring that the
Software system meets its requirements and user expectations and does not fail in an
unacceptable manner.
There are various types of test. Each test type addresses a specific testing requirement.
Functional testing is centered on the following items:
Valid Input : Two Images, one Text.
Invalid Input : Instead of images if you give text file.
Functions : Watermarking procedure.
Output : Watermarked image.
7.1 UNIT TESTING:
Unit testing is usually conducted as part of a combined code and unit test phase of the software
lifecycle, although it is not uncommon for coding and unit testing to be conducted as two distinct
phases.
Test strategy and approach
Field testing will be performed manually and functional tests will be written in detail.
Test objectives: All field entries had been tested with multiple values.
Whether the message packet had been spoofed or not, checking by the capturing the packet in
each level of network.
7.2 INTEGRATION TESTING:
Software integration testing is the incremental integration testing of two or more integrated
software components on a single platform to produce failures caused by interface defects. Here
the each and every module had been tested individually. Once finish the unit wise testing the all
modules will added and build together and check with different parameter.
Test Results: All the test cases mentioned above passed successfully. No defects encountered.
7.3 ACCEPTANCE TESTING:
User Acceptance Testing is a critical phase of any project and requires significant participation
by the end user. It also ensures that the system meets the functional requirements.
Test Results: All the test cases mentioned above passed successfully. No defects encountered.
IMPLEMENTATION
Implementation process:
Implementation is the stage of the project when the theoretical design is turned out into a
working system. Thus it can be considered to be the most critical stage in achieving a successful
new system and in giving the user, confidence that the new system will work and be effective.
The implementation stage involves careful planning, investigation of the existing system
and it’s constraints on implementation, designing of methods to achieve changeover and
evaluation of changeover methods.
Implementation is the process of converting a new system design into operation. It is the
phase that focuses on user training, site preparation and file conversion for installing a candidate
system. The important factor that should be considered here is that the conversion should not
disrupt the functioning of the organization.
The implementation can be preceded through Socket in java but it will be considered as
one to all communication .For proactive broadcasting we need dynamic linking. So java will be
more suitable for platform independence and networking concepts. For maintaining route
information we go for MS-Access as database back end.
CONCLUSION
In this project, a new method for reversible visible watermarking with lossless image
recovery capability has been proposed. The method uses one-to-one compound mappings that
can map image pixel values to those of the desired visible watermarks. Relevant lemmas and
theorems are described and proved to demonstrate the reversibility of the compound mappings
for lossless reversible visible watermarking. The compound mappings allow different types of
visible watermarks to be embedded, and two applications have been described for embedding
opaque monochrome watermarks as well as translucent full-color ones. A translucent watermark
is clearly visible and visually appealing, thus more appropriate than traditional transparent binary
watermarks in terms of advertising effect and copyright declaration. The two-fold monotonically
increasing property of compound mappings was defined and an implementation proposed that
can provably allow mapped values to always be close to the desired watermark if color estimates
are accurate. Also described are parameter randomization and mapping randomization
techniques, which can prevent illicit recoveries of original images without correct input keys.
Experimental results have demonstrated the feasibility of the proposed method and the
effectiveness of the proposed security protection measures.
APPENDICES
9 .APPENDIX 1: SCREEN SHOTS:
SCREEN SHOT 1:
SCREEN SHOT 2
SCREEN SHOT 3
SCREEN SHOT 4
SCREEN SHOT 5
CREEN SHOT 6
SCREEN SHOT 7
SCREEN SHOT 8
SCREEN SHOT 9
SCREEN SHOT 10
SCREEN SHOT 11
SCREEN SHOT 12
APPENDIX 2: Coding
/////////////////////////////////////////////// MainFrame.java////////////////////////////////////////////////////////
public class MainFrame extends javax.swing.JFrame
{
/** Creates new form MainFrame */
public MainFrame() {
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
//<editor-folddefaultstate="collapsed" desc="Generated Code">
//GEN-BEGIN:initComponents
private void initComponents()
{
jButton1 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Generic Lossless Visible Watermarking—A New Approach");
jButton1.setText("Start Watermarking");
jButton1.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
jButton1ActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(148, 148, 148)
.addComponent(jButton1)
.addContainerGap(167, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(122, 122, 122)
.addComponent(jButton1)
.addContainerGap(155, Short.MAX_VALUE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-
FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:
new InputWindow().show();
}//GEN-LAST:event_jButton1ActionPerformed
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new MainFrame().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton1;
// End of variables declaration//GEN-END:variables
}
///////////////////////////////////////Input Window.java////////////////////////////////////////////////////////
import javax.swing.JOptionPane;
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.geom.AffineTransform;
import java.awt.image.AffineTransformOp;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.swing.*;
import javax.imageio.ImageIO;
public class InputWindow extends javax.swing.JFrame {
public InputWindow()
{
initComponents();
jLabel7.setVisible(false);
}
private void initComponents()
{
jDialog1 = new javax.swing.JDialog();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jButton4 = new javax.swing.JButton();
jButton5 = new javax.swing.JButton();
jButton6 = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jTextField1 = new javax.swing.JTextField();
jTextField2 = new javax.swing.JTextField();
jTextField3 = new javax.swing.JTextField();
jTextField4 = new javax.swing.JTextField();
jTextField5 = new javax.swing.JTextField();
jDialog1.setTitle("Image Viewer");
javax.swing.GroupLayout jDialog1Layout = new
javax.swing.GroupLayout(jDialog1.getContentPane());
jDialog1.getContentPane().setLayout(jDialog1Layout);
jDialog1Layout.setHorizontalGroup(
jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jDialog1Layout.createSequentialGroup()
.addGap(43, 43, 43)
.addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 298,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(59, Short.MAX_VALUE))
);
jDialog1Layout.setVerticalGroup(
jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jDialog1Layout.createSequentialGroup()
.addContainerGap(35, Short.MAX_VALUE)
.addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 254,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Input Window");
jLabel1.setText("Press Image");
jLabel2.setText("Press Text");
jLabel3.setText("Resize");
jButton1.setText("Watermark");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jButton6.setText("Lossless");
jButton6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton6ActionPerformed(evt);
}
});
jLabel4.setFont(new java.awt.Font("Tahoma", 1, 14));
jLabel4.setText("Enter the Inputs to Watermark");
jButton2.setText("Choose File");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
jButton3.setText("Choose File");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
jButton4.setText("Choose File");
jButton4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton4ActionPerformed(evt);
}
});
jButton5.setText("Choose File");
jButton5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton5ActionPerformed(evt);
}
});
jLabel7.setFont(new java.awt.Font("Tahoma", 3, 14));
jLabel7.setForeground(new java.awt.Color(255, 0, 0));
jLabel7.setText("LossLess Visible Watermarking Output");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(24, 24, 24)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN
G)
.addGroup(layout.createSequentialGroup()
.addGap(49, 49, 49)
.addComponent(jLabel4)
.addGap(30, 30, 30))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA
DING)
.addComponent(jLabel1)
.addComponent(jLabel2)
.addComponent(jLabel3))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 31,
Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA
DING, false)
.addComponent(jTextField3)
.addComponent(jTextField2)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE,
112, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA
DING)
.addComponent(jButton2)
.addComponent(jButton3))
.addGap(0, 0, 0)))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN
G)
.addGroup(layout.createSequentialGroup()
.addGap(29, 29, 29)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA
DING)
.addGroup(layout.createSequentialGroup()
.addComponent(jTextField4,
javax.swing.GroupLayout.PREFERRED_SIZE, 110,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATE
D)
.addComponent(jButton4))
.addGroup(layout.createSequentialGroup()
.addComponent(jTextField5,
javax.swing.GroupLayout.PREFERRED_SIZE, 110,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATE
D)
.addComponent(jButton5))))
.addGroup(layout.createSequentialGroup()
.addGap(38, 38, 38)
.addComponent(jButton1)
.addComponent(jButton6)))
.addGap(303, 303, 303))
.addGroup(layout.createSequentialGroup()
.addGap(271, 271, 271)
.addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 474,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(80, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addContainerGap(413, Short.MAX_VALUE)
.addComponent(jLabel7)
.addGap(257, 257, 257))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(22, 22, 22)
.addComponent(jLabel4)
.addGap(34, 34, 34)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN
G)
.addGroup(layout.createSequentialGroup()
.addGap(8, 8, 8)
.addComponent(jLabel1)
.addGap(40, 40, 40)
.addComponent(jLabel2)
.addGap(42, 42, 42)
.addComponent(jLabel3))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRA
ILING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.
BASELINE)
.addComponent(jTextField1,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton2))
.addGap(40, 40, 40)
.addComponent(jTextField2,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.L
EADING)
.addGroup(layout.createSequentialGroup()
.addGap(60, 60, 60)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.BASELINE)
.addComponent(jTextField5,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton5)))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignme
nt.BASELINE)
.addComponent(jTextField4,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton4))
.addGap(60, 60, 60))))
.addGap(42, 42, 42)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BAS
ELINE)
.addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton3)
.addComponent(jButton1)
.addComponent(jButton6))
.addGap(4, 4, 4)))
.addGap(10, 10, 10)
.addComponent(jLabel7)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 366,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(100, 100, 100))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-
FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:
JOptionPane.showMessageDialog(null, "You are about to watermark");
/* pressImage("G:\\imgtest\\sy.jpg", "G:\\imgtest\\test1.jpg", 0, 0, 0.5f);
pressText("bonton", "G:\\imgtest\\test1.jpg", "", 36, Color.white, 80, 0, 0, 0.3f);
resize("G:\\imgtest\\test1.jpg", 500, 500, true);*/
pressImage(jTextField1.getText(), jTextField4.getText(), 0, 0, 0.5f);
pressText(jTextField2.getText(), jTextField5.getText(), "", 36, Color.white, 80, 0,
0, 0.3f);
resize(jTextField3.getText(), 500, 500, true);
JOptionPane.showMessageDialog(null, "1 second...");
JOptionPane.showMessageDialog(null, "Watermarking Done. Please view the images
inside the specified folder");
jLabel7.setVisible(true);
String s=jTextField3.getText();
jLabel6.setIcon(new ImageIcon(s));
}//GEN-LAST:event_jButton1ActionPerformed
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-
FIRST:event_jButton2ActionPerformed
// TODO add your handling code here:
JFileChooser chooser = new JFileChooser();
chooser.setSize(400, 300);
chooser.showOpenDialog(this);
File file=chooser.getSelectedFile();
jTextField1.setText(file.getAbsolutePath());
}//GEN-LAST:event_jButton2ActionPerformed
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-
FIRST:event_jButton4ActionPerformed
// TODO add your handling code here:
JFileChooser chooser = new JFileChooser();
chooser.setSize(400, 300);
chooser.showOpenDialog(this);
File file=chooser.getSelectedFile();
jTextField4.setText(file.getAbsolutePath());
}//GEN-LAST:event_jButton4ActionPerformed
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-
FIRST:event_jButton5ActionPerformed
// TODO add your handling code here:
JFileChooser chooser = new JFileChooser();
chooser.setSize(400, 300);
chooser.showOpenDialog(this);
File file=chooser.getSelectedFile();
jTextField5.setText(file.getAbsolutePath());
}//GEN-LAST:event_jButton5ActionPerformed
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-
FIRST:event_jButton3ActionPerformed
// TODO add your handling code here:
JFileChooser chooser = new JFileChooser();
chooser.setSize(400, 300);
chooser.showOpenDialog(this);
File file=chooser.getSelectedFile();
jTextField3.setText(file.getAbsolutePath());
//jLabel5.setIcon(new ImageIcon(s));
// jDialog1.setVisible(true);
}//GEN-LAST:event_jButton3ActionPerformed
private void jButton6ActionPerformed(java.awt.event.ActionEvent evt)
{
JPanel panel = new JPanel();
String pic = "D:/Generic Lossless Visible Watermarking—A New
Approach/new src/JavaApplication6/src/watermark image/image backup/Lighthouse.jpg";
ImageLabel label = new ImageLabel(new ImageIcon(pic));
label.setLocation(29, 37);
panel.add(label);
JFrame frame = new JFrame();
frame.getContentPane().add(panel);
frame.pack();
frame.setVisible(true);
}
class ImageLabel extends JLabel
{
public ImageLabel(String img)
{
this(new ImageIcon(img));
}
public ImageLabel(ImageIcon icon)
{
setIcon(icon);
// setMargin(new Insets(0,0,0,0));
setIconTextGap(0);
// setBorderPainted(false);
setBorder(null);
setText(null);
setSize(icon.getImage().getWidth(null), icon.getImage().getHeight(null));
}
}
public final static void pressImage(String pressImg, String targetImg, int x, int y, float alpha) {
try {
File img = new File(targetImg);
Image src = ImageIO.read(img);
int wideth = src.getWidth(null);
int height = src.getHeight(null);
BufferedImage image = new BufferedImage(wideth, height,
BufferedImage.TYPE_INT_RGB);
Graphics2D g = image.createGraphics();
g.drawImage(src, 0, 0, wideth, height, null);
Image src_biao = ImageIO.read(new File(pressImg));
int wideth_biao = src_biao.getWidth(null);
int height_biao = src_biao.getHeight(null);
g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, alpha));
g.drawImage(src_biao, (wideth - wideth_biao) / 2, (height - height_biao) /
2, wideth_biao, height_biao, null);
g.dispose();
ImageIO.write((BufferedImage) image, "jpg", img);
} catch (Exception e) {
e.printStackTrace();
}
}
public static void pressText(String pressText, String targetImg, String fontName, int
fontStyle, Color color, int fontSize, int x, int y, float alpha) {
try {
File img = new File(targetImg);
Image src = ImageIO.read(img);
int width = src.getWidth(null);
int height = src.getHeight(null);
BufferedImage image = new BufferedImage(width, height,
BufferedImage.TYPE_INT_RGB);
Graphics2D g = image.createGraphics();
g.drawImage(src, 0, 0, width, height, null);
g.setColor(color);
g.setFont(new Font(fontName, fontStyle, fontSize));
g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, alpha));
g.drawString(pressText, (width - (getLength(pressText) * fontSize)) / 2 +
x, (height - fontSize) / 2 + y);
g.dispose();
ImageIO.write((BufferedImage) image, "jpg", img);
} catch (Exception e) {
e.printStackTrace();
}
}
public static void resize(String filePath, int height, int width, boolean bb) {
try {
double ratio = 0.0;
File f = new File(filePath);
BufferedImage bi = ImageIO.read(f);
Image itemp = bi.getScaledInstance(width, height, bi.SCALE_SMOOTH);
if ((bi.getHeight() > height) || (bi.getWidth() > width)) {
if (bi.getHeight() > bi.getWidth()) {
ratio = (new Integer(height)).doubleValue() /
bi.getHeight();
} else {
ratio = (new Integer(width)).doubleValue() / bi.getWidth();
}
AffineTransformOp op = new
AffineTransformOp(AffineTransform.getScaleInstance(ratio, ratio), null);
itemp = op.filter(bi, null);
}
if (bb) {
BufferedImage image = new BufferedImage(width, height,
BufferedImage.TYPE_INT_RGB);
Graphics2D g = image.createGraphics();
g.setColor(Color.white);
g.fillRect(0, 0, width, height);
if (width == itemp.getWidth(null))
g.drawImage(itemp, 0, (height - itemp.getHeight(null)) / 2,
itemp.getWidth(null), itemp.getHeight(null), Color.white, null);
else
g.drawImage(itemp, (width - itemp.getWidth(null)) / 2, 0,
itemp.getWidth(null), itemp.getHeight(null), Color.white, null);
g.dispose();
itemp = image;
}
ImageIO.write((BufferedImage) itemp, "jpg", f);
} catch (IOException e) {
e.printStackTrace();
}
}
public static int getLength(String text) {
int length = 0;
for (int i = 0; i < text.length(); i++) {
if (new String(text.charAt(i) + "").getBytes().length > 1) {
length += 2;
} else {
length += 1;
}
}
return length / 2;
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new InputWindow().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton4;
private javax.swing.JButton jButton5;
private javax.swing.JButton jButton6;
private javax.swing.JDialog jDialog1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField2;
private javax.swing.JTextField jTextField3;
private javax.swing.JTextField jTextField4;
private javax.swing.JTextField jTextField5;
// End of variables declaration//GEN-END:variables
}
//////////////////////////////////Image Viewer.java//////////////////////////////////////////////////////////////
public class ImageViewer extends javax.swing.JFrame {
/** Creates new form ImageViewer */
public ImageViewer() {
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-
BEGIN:initComponents
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Image Viewer");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 338,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(52, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addGap(34, 34, 34)
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 255,
Short.MAX_VALUE)
.addContainerGap())
);
pack();
}// </editor-fold>//GEN-END:initComponents
/**
* @param args the command line arguments
*/
public void view()
{
// String name = chooser.getSelectedFile().getName();
// InputWindow iw=new InputWindow();
//jLabel1.setIcon(new ImageIcon(name));
}
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new ImageViewer().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel jLabel1;
// End of variables declaration//GEN-END:variables
}
Bibliography
1) F. A. P. Petitcolas, R. J. Anderson, and M. G. Kuhn, “Information
hiding—A survey,” Proc. IEEE, vol. 87, no. 7, pp. 1062–1078, Jul.1999.
2) N. F. Johnson, Z. Duric, and S. Jajodia, Information Hiding.
Steganography and Watermarking—Attacks and Countermeasures.
Boston,MA: Kluwer, 2001.
3) I. J. Cox, J. Kilian, F. T. Leighton, and T. Shamoon, “Secure spread
spectrum watermarking for multimedia,” IEEE Trans. Image Process.,
vol. 6, no. 12, pp. 1673–1687, Jun. 1997.
4) M. S. Kankanhalli, Rajmohan, and K. R. Ramakrishnan, “Adaptive
visible watermarking of images,” in Proc. IEEE Int. Conf. Multimedia
Computing and Systems, 1999, vol. 1, pp. 568–573.
5)Y. Hu and S.Kwong,“Wavelet domain adaptive visiblewatermarking,”
Electron. Lett., vol. 37, no. 20, pp. 1219–1220, Sep. 2001.