Sunteți pe pagina 1din 51

Image Enhancement System 201

CHAPTER - 1
Introduction

1.1. Introduction to Digital Image Processing


Interest in digital image processing methods stems from two principal application
areas: improvement of pictorial information for human interpretation; and processing
of image data for storage, transformation, and representation for autonomous machine
perception.

An image may be defined as a two-dimensional function, f(x , y), where x and y


are spatial coordinates, and the amplitude of f at any pair of coordinates (x , y) is
called the intensity or gray level of the image at the point. When x, y, and the
amplitude values of f are all finite, discrete quantities, we call the image a digital
image. The field of digital image processing refers to processing digital images by
means of digital computer.

Digital image is composed of finite number of elements, each of which has a


particular location and value. These elements are referred to as picture elements,
image elements, pels, and pixels. Pixel is the term most widely used to denote the
elements of a digital image. Sometimes a distinction is made by defining image
processing as a discipline in which both the input and output of a process are images.

Filters are one of digital image enhancement technique used to sharp the image
and to reduce the noise in the image. There are two types of enhancement techniques
called Spatial domain and Frequency domain techniques which are categorized again
for smoothing and sharpening the images.

1.2 Challenges
One the major problem face during the development the project was to take the
random input from the system and then converting the inputed mage into the binary
image to apply the operation. Another problem which arrived during the development 63

[Department of Computer Science & Engineering] [ Ideal Institute of Technology, Ghaziabad] |


Image Enhancement System 201
6

the project was to save the changed image on to the systems. Digital image is
composed of finite number of elements, each of which has a particular location and
value. These elements are referred to as picture elements, image elements, pels, and
pixels. Pixel is the term most widely used to denote the elements of a digital image.

1.3 Motivation Thought


The basic motivation for this project came from the Difficulty which i face during
the 7th semester of my B.Tech were i was suppose to study Digital Image Processing
in which we use these techniques for enhancing the image as it came very difficult for
the student to understand the enchantment of the image as there was no system which
can be used by the teachers to give the live example of these techniques.

In imaging science, image processing is any form of signal processing for


which the input is an image, such as a photograph or video frame; the output of image
processing may be either an image or a set of characteristics or parameters related to
the image.

1.4 Problem Statement


This system was designed in order to overcome the difficulties faced by the
student to understand the enhancement techniques for the images. The enhancement
techniques are very difficult to understand without any live example as most image-
processing techniques involve treating the image as a two-dimensional signal and
applying standard signal-processing techniques to it. Image processing usually refers
to digital image processing, but optical and analog image processing also are possible.

1.5 Objectives of Filters

 Smoothing filters are used for blurring and for noise reduction.

63

[Department of Computer Science & Engineering] [ Ideal Institute of Technology, Ghaziabad] |


Image Enhancement System 201
6

 Blurring is used in preprocessing steps, such as removal of small details from


an image prior to object extraction and bridging of small gaps in lines or
curves.
 Noise reduction can be accomplished by blurring with a linear filter and also
by linear and also by non linear filtering.
 The principal objective of sharpening is to highlight fine detail in image or
enhance detail that has been blurred, either in error or as a natural effect of a
particular method of image acquisition.
 Uses of image sharpening vary and include applications ranging from
electronic printing and medical imaging to industrial inspection and
autonomous guidance in military systems.

CHAPTER - 2
System Analysis and Timeline

2.1System Analysis 63

[Department of Computer Science & Engineering] [ Ideal Institute of Technology, Ghaziabad] |


Image Enhancement System 201
6

The system as the capability to investigate the crime scene by applying various
image enhancement operations. The system takes image as input directly and
performed various operation on it. This operation includes:-

 Gray Scale: Gray scale work on 8-bit representation.8-bit gray scale contain
256 shades of grey i.e. 28 =256(0-255) with 0 denoting Black colour & 255
denoting white colour with other values representing intermediate shades of
gray.

 Brightness: Brightness as an attribute of a visual sensation according to which


a given visual stimulus appears to be more or less intense; or, according to
which the areain which the visual stimulus is presented appears to emit more
or less light.

An image may be defined as a two dimensional function f(x,y), where x and y are
spatial(plane) coordinates and amplitude of 'f' at any pair of coordinates (x,y) is called
the intensity or gray level of the image at that point. When x,y are the amplitude
values of f are all finite, discrete quantities, then the image is a "digital image". The
field of digitial image processing refers to processing digital images by means of a
digital computer. Image processing is a general term for the wide range of techniques
that exits for manipulating and modifying images in various ways.

Steps in A Typical Image Possessing Sequence

Imaging Sample & Digital

System Quantize Storage

63

Display
Digital Online
[Department of Computer Science & Engineering] [ Ideal Institute of Technology, Ghaziabad] |
Buffer
Record
Image Enhancement System 201
6

Fig. 2.1 Steps in A Typical Image Possessing Sequence

2.2 Timeline of Project

Table 2.2: Timeline of Project

% of Time
Process
Planning the project 5%

Preliminary topic selection 5%

Topic formulation and focus 10%

Gathering information 25%

Design, configure and layout 45%

Testing 10%

Timeline for Various Modules

Table 2.2.2 Timeline for various modules

Modules Completed

Module Start Date End Date

Planning the project 01-09-2015 20-09-2015

Preliminary topic selection 21-09-2015 26-09-2015

Topic formulation and focus 27-09-2015 5-10-2015

Gathering information 06-10-2015 17-10-2015

Architectural Design 18-10-2015 20-10-2015

GUI Layout 22-10-2015 25-10-2015 63

[Department of Computer Science & Engineering] [ Ideal Institute of Technology, Ghaziabad] |


Image Enhancement System 201
6

Components and their activities 26-10-2015 31-10-2015

Components event handling 01-11-2015 10-11-2015

Modules to be Completed (Expected Time)

Module Start End

Weighted graph representation of sentences 06-01-2016 17-01-2016

Vector space model 18-01-2016 26-01-2016

Classic tf -idf weighting system 27-01-2016 14-02-2016

Baseline Algorithm, PageRank Algorithm 15-02-2016 04-03-2016

Summarizer Algorithm 05-03-2016 22-03-2016

Testing of various modules 23-03-2016 30-04-2016

2.3 Roles of Team Members


1-Mr. Pulak Mehrotra
Role: System Analysis, System Design, Configure and Code.
2-Mr. Shubham Gupta
Role: Documentation, Testing various modules.

CHAPTER - 3
Feasibility Study

Once the problem is clearly understood, the next step is to conduct feasibility
study, which is high-level capsule version of the entered systems and design process.
The objective is to determine whether or not the proposed system is feasible. The
following three tests of feasibility have been carried out in the system-
 Technical Feasibility.
 Economical Feasibility.
 Operational Feasibility.

Technical Feasibility:
In Technical Feasibility study, one has to test whether the proposed system can be
developed using existing technology or not. It is planned to implement the proposed
system using java technology. It is evident that the necessary hardware and software 63

[Department of Computer Science & Engineering] [ Ideal Institute of Technology, Ghaziabad] |


Image Enhancement System 201
6

are available for development and implementation of the proposed system. Hence, the
solution is technically feasible.

Economical Feasibility:
As part of this, the costs and benefits associated with the proposed system
compared and the project is economically feasible only if tangible or intangible
benefits outweigh costs. The system development costs will be significant. So the
proposed system is economically feasible.

Operational Feasibility:
It is a standard that ensures interoperability without stifling competition and
innovation among users, to the benefit of the public both in terms of cost and service
quality. The proposed system is acceptable to users. So the proposed system is
operationally feasible.

CHAPTER - 4
Literature Survey

4.1 What is Image Processing?


In imaging science, image processing is any form of signal processing for which
the input is an image, such as a photograph or video frame; the output of image
processing may be either an image or a set of characteristics or parameters related to
the image. Most image-processing techniques involve treating the image as a two-
dimensional signal and applying standard signal-processing techniques to it. Image
processing usually refers to digital image processing, but optical and analog image
processing also are possible. This article is about general techniques that apply to all
of them. The acquisition of images (producing the input image in the first place) is
referred to as imaging.

Image Processing
An image defined in the “real world” is considered to be a function of two real
variables, for example, a(x,y) with a as the amplitude (e.g. brightness) of the image at
the real coordinate position (x,y). In a sophisticated image processing system it should
be possible to apply specific image processing operations to selected regions. Thus
one part of an image (region) might be processed to suppress motion blur while
another part might be processed to improve color rendition. Modern digital 63

[Department of Computer Science & Engineering] [ Ideal Institute of Technology, Ghaziabad] |


Image Enhancement System 201
6

technology has made it possible to manipulate multi-dimensional signals with systems


that range from simple digital circuits to advanced parallel computers. The goal of this
manipulation can be divided into three categories: * Image Processing image in ->
image out * Image Analysis image in -> measurements out * Image Understanding
image in -> high-level description out Image processing is referred to processing of a
2D picture by a computer. Basic definitions: An image defined in the “real world” is
considered to be a function of two real variables, for example, a(x,y) with a as the
amplitude (e.g. brightness) of the image at the real coordinate position (x,y). An
image may be considered to contain sub-images sometimes referred to as regions-of-
interest, ROIs, or simply regions. This concept reflects the fact that images frequently
contain collections of objects each of which can be the basis for a region. In a
sophisticated image processing system it should be possible to apply specific image
processing operations to selected regions. Thus one part of an image (region) might be
processed to suppress motion blur while another part might be processed to improve
color rendition.

4.2Front End
For software applications, front-end is the same as user interface. Compilers, the
programs that translate source code into object code, are often composed of two parts:
a front-end and a back-end. The front-end is responsible for syntax checking and
detecting errors, whereas the back-end performs the actual translation into object
code. Here we use “Java Technology” as the front-end of the project. The brief
description of the technology is discussed below.

4.2.1 What is JAVA?


Java is an entire programming language resembling C or C++ introduced
in 1995 by Sun Microsystems. Its objective was to develop software for embedding in
consumer electronic devices. Initially JAVA was called ‘Oak. It takes a sophisticated
programmer to create Java code. And it requires a sophisticated programmer to
maintain it.With Java, you can create complete applications. Or you can attach a small
group of instructions, a Java "applet" that improves your basic HTML. A Java Applet
can also cause text to change color when you roll over it. A game, a calendar, a
scrolling text banner can all be created with Java Applets. There are sometimes
compatibility problems between Java and various browsers, operating systems or
computers, and if not written correctly, it can be slow to load. Java is a powerful 63

[Department of Computer Science & Engineering] [ Ideal Institute of Technology, Ghaziabad] |


Image Enhancement System 201
6

programming language with excellent security, but you need to be aware of the
tradeoffs.’

4.2.2 What is JVM?


At the heart of Java's network-orientation is the Java virtual machine,
which supports all three prongs of Java's network-oriented architecture: platform
independence, security, and network-mobility.A Java virtual machine's main job is to
load class files and execute the byte codes they contain. The Java virtual machine
contains a class loader, which loads class files from both the program and the Java

API. Only those class files from the Java API that are actually needed by a running
program are loaded into the virtual machine. The byte codes are executed in an
execution engine.

4.2.3 What is JDK?


JDK stands for JAVA DEVELOPMENT KIT that contains the software
and tools needed to compile, debug and execute applets and applications. Basically
JDK is a set of command line tools. JDK is freely available at Sun’s Official website.
There are three major releases of JDK that are:
 Java 1.0 -first release.
 Java 1.1 -1997 release.
 Java 7.0 - 2010 release.
 Java 8.0 - latest release.

4.2.4Why Software Developers Choose Java?

Java with its versatility, efficiency, and portability, Java has become
invaluable to developers by enabling:
“Write software on one platform and run it on virtually any other
platform. Create programs to run within a Web browser and Web services.”

Develop server-side applications for online forums, stores, polls, HTML


forms processing, and more. Combine applications or services using the Java
language to create highly customized applications. Write powerful and efficient
applications for mobile phones, remote processors, low-cost consumer products, and
practically any other device with a digital heartbeat.

4.3Back End
Front-end and back -end are terms used to characterize program interfaces and
63
services relative to the initial user of these interfaces and services.(The "user" may be

[Department of Computer Science & Engineering] [ Ideal Institute of Technology, Ghaziabad] |


Image Enhancement System 201
6

a human being or a program.)A "front-end" application is one that application users


interact with directly. A "back-end" application or program serves indirectly in
support of the front-end services, usually by being closer to the required resource or
having the capability to communicate with the required resource.
The back-end application may interact directly with the front-end or, perhaps
more typically, is a program called from an intermediate program that mediates front-
end and back-end activities. Here we use “Microsoft Access 2007” as the back-end or
database of the project. The brief description of the database is discussed below.

4.3.1 What is Oracle 10g?


The Oracle Database (commonly referred to as Oracle RDBMS or simply as
Oracle) is an object-relational database management system produced and marketed
by Oracle Corporation. Larry Ellison and two friends and former co-workers, Bob
Miner and Ed Oates, started a consultancy called Software Development Laboratories
(SDL) in 1977. SDL developed the original version of the Oracle software. The name
Oracle comes from the code-name of a CIA-funded project Ellison had worked on
while previously employed by Ampex.
An Oracle database system -identified by an alphanumeric system identifier or
SID -comprises at least one instance of the application, along with data storage. An
instance -identified persistently by an instantiation number (or activation id:
SYS.V_$DATABASE.ACTIVATION#) -comprises a set of operating-system
processes and memory-structures that interact with the storage. (Typical processes
include PMON (the process monitor) and SMON (the system monitor).) Oracle
documentation can refer to an active database instance as a "shared memory
realm".Users of Oracle databases refer to the server-side memory-structure as the
SGA (System Global Area). The SGA typically holds cache information such as data-
buffers, SQL commands, and user information. In addition to storage, the database
consists of online redo logs (or logs), which hold transactional history. Processes can
in turn archive the online redo logs into archive logs (offline redo logs), which
provide the basis (if necessary) for data recovery and for the physical-standby forms
of data replication using Oracle Data Guard.

4.4NetBeans IDE 63
The NetBeans IDE is an award-winning integrated development environment

[Department of Computer Science & Engineering] [ Ideal Institute of Technology, Ghaziabad] |


Image Enhancement System 201
6

available for Windows, Mac, Linux, and Solaris. The NetBeans project consists of
an open-source IDE and an application platform that enable developers to rapidly
create web, enterprise, desktop, and mobile applications using the Java platform, as
well as PHP, JavaScript and Ajax, Groovy and Grails, and C/C++.The NetBeans
project is supported by a vibrant developer community and offers
extensive documentation and training resources as well as a diverse selection of third-
party plug-ins.
NetBeans IDE 7.1 introduced support for JavaFX 2.0 and NetBeans IDE 7.1.2
introduces support for JavaFX 2.1 by enabling the full compile/debug/profile
development cycle for JavaFX 2.1 applications. The release also provides significant
Swing GUI Builder enhancements, CSS3 support, and tools for visual debugging of
Swing and JavaFX user interfaces. Additional highlights include Git support
integrated into the IDE, new PHP debugging features, various JavaEE and Maven
improvements, and more.
NetBeans IDE 7.1 is available in English, Brazilian Portuguese, Japanese, Russian
and Simplified Chinese

CHAPTER - 5
Implementation and System Requirements

5.1 Implementation
An image defined in the “real world” is considered to be a function of two real
variables, for example, a(x, y) with a as the amplitude (e.g. brightness) of the image at
the real coordinate position (x, y). In a sophisticated image processing system it
should be possible to apply specific image processing operations to selected regions. 63
Thus one part of an image (region) might be processed to suppress motion blur while

[Department of Computer Science & Engineering] [ Ideal Institute of Technology, Ghaziabad] |


Image Enhancement System 201
6

another part might be processed to improve color rendition. Modern digital


technology has made it possible to manipulate multi-dimensional signals with systems
that range from simple digital circuits to advanced parallel computers.
The goal of this manipulation can be divided into three categories:

 Image Processing image in -> image out


 Image Analysis image in -> measurements out
 Image Understanding image in -> high-level description out Image processing
is referred to processing of a 2D picture by a computer.
Most image-processing techniques involve treating the image as a two-
dimensional signal and applying standard signal-processing techniques to it. Image
processing usually refers to digital image processing, but optical and analog image
processing also are possible. This article is about general techniques that apply to all
of them. The acquisition of images (producing the input image in the first place) is
referred to as imaging.

5.2 Hardware and Software Requirement

Software Environment

Operating system: Windows 98/XP/7/8 and above.

Tool: Java Frames, Java Packets

Hardware Environment

Processor : Pentium III or above.

RAM : 64 MB

Harddisk : 2.1GB

Processor Speed : 512 MHZ 63

[Department of Computer Science & Engineering] [ Ideal Institute of Technology, Ghaziabad] |


Image Enhancement System 201
6

CHAPTER - 6
Filtering Techniques

Image enhancement approaches fall into two broad categories. Spatial domain
methods- Refers to the image plane itself and approaches in the category are based on
direct manipulation of pixels in an image.

Frequency domain methods:- Are based on modifying the Fourier transform of an


image. Enhancements by point operations:-Enhancement at any point in an image
depends only on the gray level at that point techniques in this category often are
referred to as point processing.

6.1 EDGE DETECTION


Edge detection is the name for a set of mathematical methods which aim at
identifying points in a digital image at which the image brightness changes sharply
or, more formally, has discontinuities. The points at which image brightness changes
sharply are typically organized into a set of curved line segments termed edges. The
63

[Department of Computer Science & Engineering] [ Ideal Institute of Technology, Ghaziabad] |


Image Enhancement System 201
6

purpose of detecting sharp changes in image brightness is to capture important events


and changes in properties of the world.

The Canny edge detector is still a state-of-the-art edge detector. Unless the
preconditions are particularly suitable, it is hard to find an edge detector that performs
significantly better than the Canny edge detector.

6.2 CONTRAST STRETCHING


The contrast of an image is a measure of its dynamic range, or the "spread" of its
histogram. The dynamic range of an image is defined to be the entire range of
intensity values contained within an image, or put a simpler way, the maximum pixel
value minus the minimum pixel value

Contrast stretching (also called Normalization) attempts to improve an image by


stretching the range of intensity values it contains to make full use of possible values.
Contrast stretching is restricted to a linear mapping of input to output values. The
result is less dramatic, but tends to avoid the sometimes artificial appearance of
equalized images.

6.3 FILERTING
Filtering is one of the Image Enhancement Techniques used for sharpening and
smoothening the image thereby removing the noise from it.

6.3.1 HIGH PASS FILTER

A high-pass filter can be used to make an image appear sharper. These filters
emphasize fine details in the image – exactly the opposite of the low-pass filter. High-
pass filtering works in exactly the same way as low-pass filtering; it just uses a
different convolution kernel. In the example below, notice the minus signs for the
adjacent pixels. If there is no change in intensity, nothing happens. But if one pixel is
brighter than its immediate neighbors, it gets boosted.

0 -1/4 0
63
- +2 -1/4

[Department of Computer Science & Engineering] [ Ideal Institute of Technology, Ghaziabad] |


Image Enhancement System 201
6

1/4
0 -1/4 0

Fig. 6.3 High Pass Filter (Matrix)

6.3.2 LOW PASS FILTER

The most basic of filtering operations is called "low-pass". A low-pass filter,


also called a "blurring" or "smoothing" filter, averages out rapid changes in intensity.
The simplest low-pass filter just calculates the average of a pixel and all of its eight
immediate neighbors. The result replaces the original value of the pixel. The process
is repeated for every pixel in the image.

6.4 SHARPENING
Sharpening of digital image files is one of the most important aspects of image
quality and arguably one of the least understood. Sharpening brings out detail and
gives an image presence, but not all images should be sharpened the same and even
areas within an image often need a specific sharpening treatment.

6.5 HISTOGRAM AND HISTOGRAM EQUILIZATION


6.5.1 HISTOGRAM

A histogram is a graphical representation of the distribution of numerical


data. It is an estimate of the probability distribution of a continuous variable
(quantitative variable) and was first introduced by Karl Pearson. To construct a
histogram, the first step is to "bin" the range of values-that is, divide the entire range
of values into a series of intervals-and then count how many values fall into each
interval.

6.5.2 HISTOGRAM EQUILIZATION


63

[Department of Computer Science & Engineering] [ Ideal Institute of Technology, Ghaziabad] |


Image Enhancement System 201
6

Histogram equalization is a method in image processing of contrast


adjustment using the image's histogram.

(a)Before (b) After

Fig. 6.5 Histogram’s of an Image Before and After Equalization.

6.6 THRESHOLDING
Image thresholding is a simple, yet effective, way of partitioning an image into a
foreground and background

The simplest thresholding methods replace each pixel in an image with a black

pixel if the image intensity is less than some fixed constant T (that is, ),
or a white pixel if the image intensity is greater than that constant.

Colour images can also be threshold. One approach is to designate a separate


threshold for each of the RGB components of the image and then combine them with
an AND operation. This reflects the way the camera works and how the data is
stored in the computer, but it does not correspond to the way that people recognize
colour

6.7 NEGATIVE
A negative is an image, is a technique in which the lightest areas of the
photographed subject appear darkest and the darkest areas appear lightest.
63

[Department of Computer Science & Engineering] [ Ideal Institute of Technology, Ghaziabad] |


Image Enhancement System 201
6

Image negative is obtained by reversing of the grey level intensities of the


image thereby producing a negative like image.

6.8 GREY LEVEL SLICING


Highlighting a specific range of gray levels in an image often is desired.
Applications include enhancing features such as masses of water in satellite imagery
and enhancing flows in X-rays images. There are several ways of doing level slicing
one approach is to display a high value for all gray levels in the range of interest and a
low value for all other gray levels.

CHAPTER - 7
System Design with Data Flow Diagram

7.1 Context level Diagram


The User selects the image on which enhancements are to be performed. The
result after enhancements goes to the User

Image
User enhancemen User
t techniques

Fig. 7.1 Context level Diagram

7.2 FIRST LEVEL DIAGRAM


63

Exit

Menus File
[Department of Computer Science & Engineering] [ Ideal Institute of Technology, Ghaziabad] User
|
User Ope Imag
n e
Image Enhancement System 201
6

Fig. 7.2 First level diagram

The Menu contains two options File and Image.

The File contains two options Open to select an image and Exit to come out from
the window.

After opening an image, the Image option is selected to perform enhancements

7.3 Second Level Diagram

Negate

Rotate

Image
User Gray User
Scale

Contras
t

Histogra
m
Fig. 7.3 Second Level Diagram

The Image Menu contains operations of enhancements such as Negate the image,
rotate the image, Gray Scale image, perform Contrast Stretching and finally
Histogram Techniques

63

[Department of Computer Science & Engineering] [ Ideal Institute of Technology, Ghaziabad] |


Image Enhancement System 201
6

CHAPTER - 8
Code and Implementation

8.1 Image Enhancement System


a. Take the input of the image.
b. Apply the technique to be implemented.
c. Save the changed image.

8.2 Project Code


Some of the important packets used in this project
java.applet.*;
java.awt.*;
java.awt.Event;
java.awt.image.BufferedImage;
java.awt.image.*;
javax.swing.*;
java.awt.Graphics2D;
java.awt.image.ConvolveOp;
java.io.IOException;
javax.imageio.ImageIO;
java.io.File;
java.nio.file.Path;

8.2.1 Main code


public class pck extends myframe
{
Insets insets;
Image src,dst;
ImageProducer filtered;
String filename=null;
public pck()
{}

public void paint(Graphics g)


{
if(filename!=null)
g.drawImage(dst,insets.left+50,insets.top+50,this);
}
public static void main(String a[])
{
pck f=new pck();
f.show();
}

public void abc() 63


{

[Department of Computer Science & Engineering] [ Ideal Institute of Technology, Ghaziabad] |


Image Enhancement System 201
6

if(filename!=null)
{
src=Toolkit.getDefaultToolkit().getImage(filename);
MediaTracker mt=new MediaTracker(this);
mt.addImage(src,0);
try
{
mt.waitForID(0);
}catch(Exception e)
{
System.out.println("Image Loading Error!"+e);
System.exit(0);
}
dst=src;
repaint();
}
}
public void addNotify()
{
super.addNotify();
insets=getInsets();
setBounds(50,50,500+insets.left,350+insets.top);
}
public void open()
{
FileDialog fd=new FileDialog(this,"Open",FileDialog.LOAD);
fd.setVisible(true);
String dir=fd.getDirectory();
String fname=fd.getFile();
filename=dir+fname;
abc();
}
public void org()
{
if(filename!=null)
{
dst=src;
repaint();
}
}
public void cs()
{
if(filename!=null)
{
int iw,ih;
int j1,j2,j3,j4;
int pixels[];
int out[];
int errflag=0; 63
iw=dst.getWidth(null);

[Department of Computer Science & Engineering] [ Ideal Institute of Technology, Ghaziabad] |


Image Enhancement System 201
6

ih=dst.getHeight(null);
pixels=new int[iw*ih];
try
{
PixelGrabber pg=new PixelGrabber(dst,0,0,iw,ih,pixels,0,iw);
pg.grabPixels();
}catch(InterruptedException e){};
mydialog md=new mydialog(this,"Contrast Stretching",true,2);
md.setSize(250,180);
md.setVisible(true);
if((md.val1!=null)&&(md.val2!=null)&&(md.val3!=null)&&(md.val4!=null))
{
j1=Integer.parseInt(md.val1);
if((j1<0)||(j1>255))
errflag=1;
j2=Integer.parseInt(md.val2);
if((j2<0)||(j2>255))
errflag=1;
j3=Integer.parseInt(md.val3);
if((j3<0)||(j3>255))
errflag=1;
j4=Integer.parseInt(md.val4);
if((j4<0)||(j4>255))
errflag=1;
if(errflag==0)
{
contrast c=new contrast(j1,j2,j3,j4);
out=c.csimage(pixels,iw,ih);
dst=createImage(new MemoryImageSource(iw,ih,out,0,iw));
}
else
{
errdialog ed=new errdialog(this,"Error!",true);
ed.setSize(200,100);
ed.setVisible(true);
}
}
repaint();
}
}
public void lp()
{
if(filename!=null)
{
int[ ] filter={1,1,1,
1,1,1,
1,1,1};
double multiplier=0.11111;
convfilter cv=new convfilter(filter); 63
filtered=cv.filteredImage(dst,multiplier);

[Department of Computer Science & Engineering] [ Ideal Institute of Technology, Ghaziabad] |


Image Enhancement System 201
6

dst=createImage(filtered);
repaint();
}
}
public void hp()
{
if(filename!=null)
{
int[ ] filter={-1,-1,-1,
-1,8,-1,
-1,-1,-1};
double multiplier=1;
convfilter cv=new convfilter(filter);
filtered=cv.filteredImage(dst,multiplier);
dst=createImage(filtered);
repaint();
}
}
public void hb()
{
if(filename!=null)
{
int[] filter={-1,-1,-1,
-1,9,-1,
-1,-1,-1};
double multiplier=1;
convfilter cv=new convfilter(filter);
filtered=cv.filteredImage(dst,multiplier);
dst=createImage(filtered);
repaint();
}
}
public void hist()
{
if(filename!=null)
{
int iw,ih;
int pixels[];
int out[];
iw=dst.getWidth(null);
ih=dst.getHeight(null);
pixels=new int[iw*ih];
try
{
PixelGrabber pg=new PixelGrabber(dst,0,0,iw,ih,pixels,0,iw);
pg.grabPixels();
}catch(InterruptedException e){};
Histogram h=new Histogram(this,"Histogram");
h.set(pixels,iw,ih); 63
h.setSize(320,480);

[Department of Computer Science & Engineering] [ Ideal Institute of Technology, Ghaziabad] |


Image Enhancement System 201
6

h.setVisible(true);
}
}
public void thr()
{
if(filename!=null)
{
int iw,ih;
int pixels[];
int out[];
int j1;
iw=dst.getWidth(null);
ih=dst.getHeight(null);
pixels=new int[iw*ih];
try
{
PixelGrabber pg=new PixelGrabber(dst,0,0,iw,ih,pixels,0,iw);
pg.grabPixels();
}catch(InterruptedException e){};
mydialog md=new mydialog(this,"Thresholding",true,0);
md.setSize(200,130);
md.setVisible(true);
if(md.val1!=null)
{
j1=Integer.parseInt(md.val1);
if((j1<0)||(j1>255))
{
errdialog ed=new errdialog(this,"Error!",true);
ed.setSize(200,100);
ed.setVisible(true);
}
else
{
thresholding level=new thresholding(j1);
out=level.tsimage(pixels,iw,ih);
dst=createImage(new MemoryImageSource(iw,ih,out,0,iw));
}
}
repaint();
}

}
public void heq()
{
if(filename!=null)
{
int iw,ih;
int pixels[];
int out[]; 63
iw=dst.getWidth(null);

[Department of Computer Science & Engineering] [ Ideal Institute of Technology, Ghaziabad] |


Image Enhancement System 201
6

ih=dst.getHeight(null);
pixels=new int[iw*ih];
try
{
PixelGrabber pg=new PixelGrabber(dst,0,0,iw,ih,pixels,0,iw);
pg.grabPixels();
}catch(InterruptedException e){};
he heq=new he();
out=heq.equalize(pixels,iw,ih);
dst=createImage(new MemoryImageSource(iw,ih,out,0,iw));
repaint();
}
}
public void neg()
{
if(filename!=null)
{
int iw,ih;
int pixels[];
int out[];
iw=dst.getWidth(null);
ih=dst.getHeight(null);
pixels=new int[iw*ih];
try
{

PixelGrabber pg=new PixelGrabber(dst,0,0,iw,ih,pixels,0,iw);


pg.grabPixels();
}catch(InterruptedException e){};
Negator negator=new Negator();
out=negator.negatepixels(pixels,iw,ih);
dst=createImage(new MemoryImageSource(iw,ih,out,0,iw));
repaint();
}
}

public void gs()


{
if(filename!=null)
{
int iw,ih;
int pixels[];
int out[];
iw=dst.getWidth(null);
ih=dst.getHeight(null);
pixels=new int[iw*ih];
try
{
PixelGrabber pg=new PixelGrabber(dst,0,0,iw,ih,pixels,0,iw); 63
pg.grabPixels();

[Department of Computer Science & Engineering] [ Ideal Institute of Technology, Ghaziabad] |


Image Enhancement System 201
6

}catch(InterruptedException e){};
grey g=new grey();
out=g.greyimage(pixels,iw,ih);
dst=createImage(new MemoryImageSource(iw,ih,out,0,iw));
repaint();
}
}
}

8.2.2 CONTRAST STRECHING


Low contrast images can result from poor illumination, lack of dynamic range in
the imaging sensor, or even wrong setting of a lens aperture during image acquisition.
The idea behind contrast stretching is to increase the dynamic range of the gray levels
in the image being processed.

public class contrast


{
int r1,s1,r2,s2;
int slp1,slp2,slp3;
public int outpixels[];
public contrast(int sd1,int sd2,int sd3,int sd4)
{
r1=sd1;
s1=sd2;
r2=sd3;
s2=sd4;
slp1=(int)(s1/r1);
slp2=(int)((s2-s1)/(r2-r1));
slp3=(int)((255-s2)/(255-r2));
System.out.println("the value of spl1 is" +slp1);
System.out.println("the value of spl2 is" +slp2);
System.out.println("the value of spl3 is" +slp3);
}
public int[] csimage(int[] inpixels,int width,int height)
{
outpixels=new int[width*height];
for(int i=0;i<(width*height);i++)
{
int p=inpixels[i];
int r=0xff&(p>>16);
if((r>0)&&(r<=r1))
r=(int)(slp1*r);
else

if((r>r1)&&(r<r2))
r=(int)(slp2*(r-r1)+s1);
else
63
if((r>=r2)&&(r<=255))

[Department of Computer Science & Engineering] [ Ideal Institute of Technology, Ghaziabad] |


Image Enhancement System 201
6

r=(int)(slp3*(r-r2)+s2);
int g=0xff&(p>>8);
if((g>=0)&&(g<=r1))
g=(int)(slp1*g);
else
if((g>r1)&&(g<r2))
g=(int)(slp2*(g-r1)+s1);
else
if((g>=r2)&&(g<=255))
g=(int)(slp3*(g-r2)+s2);
int b=0xff&(p);
if((b>=0)&&(b<=r1))
b=(int)(slp1*b);
else
if((b>r1)&&(b<r2))
b=(int)(slp2*(b-r1)+s1);
else
if((b>=r2)&&(b<=255))
b=(int)(slp3*(b-r2)+s2);
outpixels[i]=(255<<24)|(r<<16)|(g<<8)|b;
}
return outpixels;
}
}

8.2.3 FILTERIN
Filtering is one of the Image Enhancement Techniques used for sharpening and
smoothening the image thereby removing the noise from it. It is done by removing the
noise of the image, by applying the low pass filter for smoothing or high pass filter for
sharpening the image.

class convfilter implements ImageObserver


{
int[] oldpixels,newpixels;
int w,h;
PixelGrabber pg;
MemoryImageSource mis;
int index=0;
int i00,i01,i02,i10,i11,i12,i20,i21,i22;
int p00,p01,p02,p10,p11,p12,p20,p21,p22;
int w00,w01,w02,w10,w11,w12,w20,w21,w22;
public convfilter(int[] matrix)
{
63
w00=matrix[0];

[Department of Computer Science & Engineering] [ Ideal Institute of Technology, Ghaziabad] |


Image Enhancement System 201
6

w01=matrix[1];
w02=matrix[2];
w10=matrix[3];
w11=matrix[4];
w12=matrix[5];
w20=matrix[6];
w21=matrix[7];
w22=matrix[8];
}
public boolean imageUpdate(Image img,int infoflags,int x,int y,int width,int
height)
{
w=width;
h=height;
if(w!=-1&&h!=-1)
{
return false;
}
return true;
}
public ImageProducer filteredImage(Image source,double mult)
{
boolean success;
w=source.getWidth(null);
h=source.getHeight(null);
oldpixels=new int[w*h];
newpixels=new int[w*h];
pg=new PixelGrabber(source.getSource(),0,0,w,h,oldpixels,0,w);
try
{
success=pg.grabPixels(0);
}catch(Exception e)
{
System.out.println("Error in grabbing"+e);
}
index=w+1;
for(int y=1;y<h-1;y++)
{
calc3x3offsets();
for(int x=1;x<w-1;x++)
{
p00=oldpixels[i00];
p01=oldpixels[i01];
p02=oldpixels[i02];
p10=oldpixels[i10];
p11=oldpixels[i11];
p12=oldpixels[i12];
p20=oldpixels[i20];
63
p21=oldpixels[i21];

[Department of Computer Science & Engineering] [ Ideal Institute of Technology, Ghaziabad] |


Image Enhancement System 201
6

p22=oldpixels[i22];
int newRed=applyWeights(16,mult);
int newGreen=applyWeights(8,mult);
int newBlue=applyWeights(0,mult);
newpixels[index++]=255<<24|newRed|newGreen|newBlue;
i00++;
i01++;
i02++;
i10++;
i11++;
i12++;
i20++;
i21++;
i22++;
}
index+=2;
}
mis=new MemoryImageSource(w,h,newpixels,0,w);
return mis;
}
final void calc3x3offsets()
{
i00=index-w-1;
i01=i00+1;
i02=i00+2;
i10=index-1;
i11=index;
i12=index+1;
i20=index+w-1;
i21=i20+1;
i22=i20+2;
}
final int applyWeights(int shift,double multfactor)
{
double total=0;
total+=((p00>>shift)&0xFF)*w00;
total+=((p01>>shift)&0xFF)*w01;
total+=((p02>>shift)&0xFF)*w02;
total+=((p10>>shift)&0xFF)*w10;
total+=((p11>>shift)&0xFF)*w11;
total+=((p12>>shift)&0xFF)*w12;
total+=((p20>>shift)&0xFF)*w20;
total+=((p21>>shift)&0xFF)*w21;
total+=((p22>>shift)&0xFF)*w22;
total=total*multfactor;
if(total>255)
total=255;
if(total<0)
total=0; 63
return((int)total)<<shift;

[Department of Computer Science & Engineering] [ Ideal Institute of Technology, Ghaziabad] |


Image Enhancement System 201
6

}
}

8.2.4 HISTOGRAM
The histogram of a digital image with gray levels in the range[0,L-1] is a
discrete function. The probability of a gray level is the ratio of number of pixels at
that gray level to the total number of pixels.

public class Histogram extends Dialog implements WindowListener


{
int max_hist=0;
int hist[]=new int[256];
public Histogram(Frame p,String title)
{
super(p,title,false);
addWindowListener(this);
}
public void set(int[] inpixels,int w,int h)
{
for(int i=0;i<h*w;i++)
{
int p=inpixels[i];
int r=0xff&(p>>16);
int g=0xff&(p>>8);
int b=0xff&(p);
int y=(int)(.33*r+.56*g+.11*b);
hist[y]++;
}
for(int i=0;i<256;i++)
{
if(hist[i]>max_hist)
max_hist=hist[i];
}
}
public void paint(Graphics g)
{
int x=25;
g.setColor(Color.blue);
g.drawLine(25,250,280,250);
g.setColor(Color.red);
for(int i=0;i<256;i++)
{
int p=200*hist[i]/max_hist;
int y=250-p;
g.fillRect(x,y,1,p);
x++;
} 63
}

[Department of Computer Science & Engineering] [ Ideal Institute of Technology, Ghaziabad] |


Image Enhancement System 201
6

public void windowClosed(WindowEvent we)


{}
public void windowDeiconified(WindowEvent we)
{}
public void windowIconified(WindowEvent we)
{}
public void windowActivated(WindowEvent we)
{}
public void windowDeactivated(WindowEvent we)
{}
public void windowOpened(WindowEvent we)
{}
public void windowClosing(WindowEvent we)
{
dispose();
}
}

8.2.5 Histogram Equalization


public class he
{
int dest[];
public int[] equalize(int src[],int w,int h)
{
dest=new int[w*h];
int result;
float a1,a2,a3;
int array[]=new int[256];
int rgb;
for(int i=0;i<256;i++)
array[i]=0;
for(int i=0;i<w*h;i++)
{
rgb=src[i]&0x000000ff;
array[rgb]++;
}
for(int i=0;i<w*h;i++)
{
rgb=src[i]&0x000000ff;
a3=0;
for(int j=0;j<(rgb+1);j++)
{
a1=(float)array[j];
a2=(float)(w*h);
a3=a3+(a1/a2);
}
result=(int)(a3*255);
if(result>255)
result=255; 63

[Department of Computer Science & Engineering] [ Ideal Institute of Technology, Ghaziabad] |


Image Enhancement System 201
6

if(result<0)
result=0;
dest[i]=0xff000000|(result+(result<<16)+(result<<8));
}
return dest;
}
}

8.2.6 GREY LEVEL SLICING


Highlighting a specific range of gray levels in an image often is desired.
Applications include enhancing features such as masses of water in satellite imagery
and enhancing flows in X-rays images. There are several ways of doing level slicing,
one approach is to display a high value for all gray levels in the range of interest and a
low value for all other gray levels.

public class LevelSlicing


{
int vs1,vs2,vs3,vs4;
public int outpixels[];
public LevelSlicing(int sd1,int sd2,int sd3,int sd4)
{
vs1=sd1;
vs2=sd2;
vs3=sd3;
vs4=sd4;
}
public int[] slicedImage(int[] inpixels,int width,int height)
{
outpixels=new int[width*height];
for(int i=0;i<(width*height);i++)
{
int p=inpixels[i];
int r=0xff&(p>>16);
//MODIFIED
if((r>=vs1)&&(r<=vs2))
r=vs4;
else
r=vs3;
int g=0xff&(p>>8);
if((g>=vs1)&&(g<=vs2))
g=vs4;
else
g=vs3;
int b=0xff&(p);
if((b>=vs1)&&(b<=vs2)) 63
b=vs4;

[Department of Computer Science & Engineering] [ Ideal Institute of Technology, Ghaziabad] |


Image Enhancement System 201
6

else
b=vs3;
outpixels[i]=(255<<24)|(r<<16)|(g<<8)|b;
}
return outpixels;
}
}

8.2.7 NEGATIVE
Negatives of digital images are useful in numerous applications, such as
displaying medical images and photographing a screen with monochrome positive
film with the idea of using the resulting negatives as normal slides. A negative image
can be obtained by reverse scaling of the gray level.

public class Negator


{
int outpixels[];
public void Negator()
{}

public int[] negatepixels(int inpixels[],int width,int height)


{
outpixels=new int[width*height];
for(int i=0;i<(width*height);i++)
{
int p=inpixels[i];

int r=0xff&(p>>16);
r=(int)255-r;

int g=0xff&(p>>8);
g=(int)255-g;

int b=0xff&(p);
b=(int)255-b;
outpixels[i]=(255<<24)|(r<<16)|(g<<8)|b;
}
return outpixels;
}
}

8.2.8 THRESHOLDING
Colour images can also be thresholded. One approach is to designate a separate
threshold for each of the RGB components of the image and then combine them with 63

[Department of Computer Science & Engineering] [ Ideal Institute of Technology, Ghaziabad] |


Image Enhancement System 201
6

an AND operation. This reflects the way the camera works and how the data is
stored in the computer, but it does not correspond to the way that people recognize
colour

public class thresholding


{
int outpixels[];
int thr;
public thresholding(int th)
{
thr=th;
}
public int[] tsimage(int[] inpixels,int width,int height)
{
outpixels=new int[width*height];
for(int i=0;i<(width*height);i++)
{
int p=inpixels[i];
int r=0xff&(p>>16);
if(r>=thr)
r=255;
else
r=0;
int g=0xff&(p>>8);
if(g>=thr)
g=255;
else
g=0;
int b=0xff&(p);
if(b>=thr)
b=255;
else
b=0;
outpixels[i]=(255<<24)|(r<<16)|(g<<8)|b;
}
return outpixels;
}
}

8.2.9 EDGE DETECTION


The points at which image brightness changes sharply are typically organized
into a set of curved line segments termed edges. The purpose of detecting sharp
changes in image brightness is to capture important events and changes in properties
of the world.The Canny edge detector is still a state-of-the-art edge detector. Unless 63

[Department of Computer Science & Engineering] [ Ideal Institute of Technology, Ghaziabad] |


Image Enhancement System 201
6

the preconditions are particularly suitable, it is hard to find an edge detector that
performs significantly better than the Canny edge detector.

public class edge


{
int outpixels[];
public void edge()
{}

private final int clamp(int c) {


return (c>255 ? 255 : (c<0 ? 0:c));}
int r0=0,g0=0,b0=0;
public int [] edgeimage(int[] inpixels,int width,int height) {
outpixels=new int[width*height];
for(int y=1;y<height-1;y++) {
for(int x=1;x<width-1;x++) {
int rs=0;
int gs=0;
int bs=0;
for(int k=-1;k<=1;k++) {
for(int j=-1;j<=1;j++) {
int rgb=inpixels[(y+k)*width+x+j];
int r=(rgb>> 16) & 0xff;
int g=(rgb>> 8) & 0xff;
int b=rgb& 0xff;
if(j==0 && k==0) {
r0=r;
g0=g;
b0=b;
}else {
rs=rs-r;
gs=gs-g;
bs=bs-b;
}}}
outpixels[y*width+x]=(0xff000000|clamp(8*r0+rs)<<16|clamp(8*g0+gs)<<8|
clamp(8*b0+bs));
}
}
return outpixels;

}
}

8.2.10 USER INTERFACE


abstract class myframe extends JFrame implements
ActionListener,WindowListener 63

[Department of Computer Science & Engineering] [ Ideal Institute of Technology, Ghaziabad] |


Image Enhancement System 201
6

{Toolkit tk=Toolkit.getDefaultToolkit();
MenuItem op,cls;
MenuItem org,neg,ls,lp,hp,hb,hist,thr,gs,cs,rot,heq,ed,sv;
public myframe()
{
super("Image Enhancement");
JButton b1 = new JButton("OPEN");
b1.setBounds(600, 650, 150, 60);
add(b1);
setSize(150, 60);
setLayout(null);
setVisible(true);
b1.addActionListener(this);
b1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
open();
throw new UnsupportedOperationException("Not supported yet."); //To
change body of generated methods, choose Tools | Templates.
}
});

JButton b2 = new JButton("NEGATIVE");


b2.setBounds(1170,60, 150, 60);
add(b2);
setSize(150, 60);
setLayout(null);
setVisible(true);
b2.addActionListener(this);
b2.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
neg();
throw new UnsupportedOperationException("Not supported yet."); //To
change body of generated methods, choose Tools | Templates.
}
});

JButton b3 = new JButton("GREY SCALE");


b3.setBounds(1170,140, 150, 60);
add(b3);
setSize(150, 60);
setLayout(null);
setVisible(true);
b3.addActionListener(this);
b3.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) { 63
gs();

[Department of Computer Science & Engineering] [ Ideal Institute of Technology, Ghaziabad] |


Image Enhancement System 201
6

throw new UnsupportedOperationException("Not supported yet."); //To


change body of generated methods, choose Tools | Templates.
}
});

JButton b4 = new JButton("ROTATE");


b4.setBounds(1170, 220, 150, 60);
add(b4);
setSize(150, 60);
setLayout(null);
setVisible(true);
b4.addActionListener(this);
b4.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
rotate();
throw new UnsupportedOperationException("Not supported yet."); //To
change body of generated methods, choose Tools | Templates.
}
});

JButton b5 = new JButton("LEVEL SLICING");


b5.setBounds(1170, 300, 150, 60);
add(b5);
setSize(150, 60);
setLayout(null);
setVisible(true);
b5.addActionListener(this);
b5.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
ls();
throw new UnsupportedOperationException("Not supported yet."); //To
change body of generated methods, choose Tools | Templates.
}
});

JButton b6 = new JButton("LOW PASS FILTER");


b6.setBounds(1170, 380, 150, 60);
add(b6);
setSize(150, 60);
setLayout(null);
setVisible(true);
b6.addActionListener(this);
b6.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
63
lp();

[Department of Computer Science & Engineering] [ Ideal Institute of Technology, Ghaziabad] |


Image Enhancement System 201
6

throw new UnsupportedOperationException("Not supported yet."); //To


change body of generated methods, choose Tools | Templates.
}
});

JButton b13 = new JButton("HISTOGRAM EQUALIZING");


b13.setBounds(1170,460, 150, 60);
add(b13);
setSize(150, 60);
setLayout(null);
setVisible(true);
b13.addActionListener(this);
b13.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
heq();
throw new UnsupportedOperationException("Not supported yet."); //To
change body of generated methods, choose Tools | Templates.
}
});

JButton b14 = new JButton("EDGE DETECT ");


b14.setBounds(50,60, 150, 60);
add(b14);
setSize(150, 60);
setLayout(null);
setVisible(true);
b14.addActionListener(this);
b14.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
ed();
throw new UnsupportedOperationException("Not supported yet."); //To
change body of generated methods, choose Tools | Templates.
}
});

JButton b15 = new JButton("EXIT");


b15.setBounds(800,650, 150, 60);
add(b15);
setSize(150, 60);
setLayout(null);
setVisible(true);
b15.addActionListener(this);
b15.addActionListener(new ActionListener() {
@Override
63
public void actionPerformed(ActionEvent e) {

[Department of Computer Science & Engineering] [ Ideal Institute of Technology, Ghaziabad] |


Image Enhancement System 201
6

dispose();
System.exit(0);

throw new UnsupportedOperationException("Not supported yet."); //To


change body of generated methods, choose Tools | Templates.
}
});

JButton b7 = new JButton("ORIGINAL");


b7.setBounds(400, 650, 150, 60);
add(b7);
setSize(150, 60);
setLayout(null);
setVisible(true);
b7.addActionListener(this);
b7.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
org();
throw new UnsupportedOperationException("Not supported yet."); //To
change body of generated methods, choose Tools | Templates.
}
});

JButton b8 = new JButton("HIGH PASS FILTER");


b8.setBounds(50, 220, 150, 60);
add(b8);
setSize(150, 60);
setLayout(null);
setVisible(true);
b8.addActionListener(this);
b8.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
hp();
throw new UnsupportedOperationException("Not supported yet."); //To
change body of generated methods, choose Tools | Templates.
}
});

JButton b9 = new JButton("SHARPEN");


b9.setBounds(50,300 , 150, 60);
add(b9);
setSize(150, 60);
setLayout(null);
setVisible(true);
63
b9.addActionListener(this);

[Department of Computer Science & Engineering] [ Ideal Institute of Technology, Ghaziabad] |


Image Enhancement System 201
6

b9.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
hb();
throw new UnsupportedOperationException("Not supported yet."); //To
change body of generated methods, choose Tools | Templates.
}
});

JButton b10 = new JButton("HISTOGRAM");


b10.setBounds(50, 380, 150, 60);
add(b10);
setSize(150, 60);
setLayout(null);
setVisible(true);
b10.addActionListener(this);
b10.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
hist();
throw new UnsupportedOperationException("Not supported yet."); //To
change body of generated methods, choose Tools | Templates.
}
});
JButton b11 = new JButton("THRESHOLDING");
b11.setBounds(50, 460, 150, 60);
add(b11);
setSize(150, 60);
setLayout(null);
setVisible(true);
b11.addActionListener(this);
b11.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
thr();
throw new UnsupportedOperationException("Not supported yet.");
}
});
JButton b12 = new JButton("CONTRAST STRECHING");
b12.setBounds(50, 140, 150, 60);
add(b12);
b12.setSize(150, 60);
b12.setLayout(null);
b12.setVisible(true);
b12.addActionListener(this);
b12.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) { 63
cs();

[Department of Computer Science & Engineering] [ Ideal Institute of Technology, Ghaziabad] |


Image Enhancement System 201
6

throw new UnsupportedOperationException("Not supported yet.");


}
});
}

public void actionPerformed(ActionEvent ae)


{Button source=(Button)ae.getSource();

if(source.getLabel().equals("open")){
open();}
else if (source.getLabel().equals("neg")){
neg();
}
else if (source.getLabel().equals("Grey Scale")){
gs();
}
else if (source.getLabel().equals("Rotate")){
rotate();
}
else if (source.getLabel().equals("Level Slicing")){
ls();
}
else if (source.getLabel().equals("Low Pass Filter")){
lp();
}
else if (source.getLabel().equals("Original")){
org();
}
else if (source.getLabel().equals("High Pass Filter")){
hp();
}
else if (source.getLabel().equals("Sharpen")){
hb();
}
else if (source.getLabel().equals("Histogram")){
hist();
}
else if (source.getLabel().equals("Thresholding")){
thr();
}
else if (source.getLabel().equals("Constrast Stretching")){
cs();
}
else if (source.getLabel().equals("Histogram Equalizing")){
heq();
}
else if (source.getLabel().equals("Edge Detect")){
ed();
} 63
else if (source.getLabel().equals("Edge Detect")){

[Department of Computer Science & Engineering] [ Ideal Institute of Technology, Ghaziabad] |


Image Enhancement System 201
6

save();
}
else if (source.getLabel().equals("Exit")){
dispose();
System.exit(0);

}
}

public void windowClosed(WindowEvent we)


{}
public void windowDeiconified(WindowEvent we)
{}
public void windowIconified(WindowEvent we)
{}
public void windowActivated(WindowEvent we)
{}
public void windowDeactivated(WindowEvent we)
{}
public void windowOpened(WindowEvent we)
{}
public void windowClosing(WindowEvent we)
{
dispose();
System.exit(0);
}

abstract void open();


abstract void org();
abstract void neg();
abstract void gs();
abstract void ls();
abstract void cs();
abstract void lp();
abstract void hp();
abstract void hb();
abstract void hist();
abstract void thr();
abstract void heq();
abstract void rotate();

63

[Department of Computer Science & Engineering] [ Ideal Institute of Technology, Ghaziabad] |


Image Enhancement System 201
6

CHAPTER - 9
PROJECT SCREEN SHOTS

9.1 PROJECT U I

Fig 9.1 Project U I

9.2 OPENING OF IMAGE

Fig 9.2 Opening of Image


9.3 ORIGINAL IMAGE
63

[Department of Computer Science & Engineering] [ Ideal Institute of Technology, Ghaziabad] |


Image Enhancement System 201
6

Fig9.3 Original Image

9.4 EDGE DETECTION

Fig 9.4 Edge Detection

9.5 HISTOGRAM EQUALIZATION

63

[Department of Computer Science & Engineering] [ Ideal Institute of Technology, Ghaziabad] |


Image Enhancement System 201
6

Fig 9.5 Histogram Equalization

9.6 HISTOGRAM

Fig 9.6 Histogram

9.7 NEGATIVE OF THE IMAGE

63

[Department of Computer Science & Engineering] [ Ideal Institute of Technology, Ghaziabad] |


Image Enhancement System 201
6

Fig 9.7 Negative of the Image

9.8 LOW PASS FILTER (SMOOTHING)

Fig 9.8 Low Pass Filter (Smoothing)

9.9 SAVING OF THE ENHANCHED IMAGE

63

[Department of Computer Science & Engineering] [ Ideal Institute of Technology, Ghaziabad] |


Image Enhancement System 201
6

Fig 9.9 Saving of the Enhanced Image

CHAPTER - 10

Conclusion and Future Scope

10.1 Conclusion
The objective of the project is to smooth and sharp the images by using various
Filtering techniques. Where Filtering techniques are on of the enhancement
techniques in the Digital image processing. 63
Here in the project I had implemented few spatial domain filters and frequency

[Department of Computer Science & Engineering] [ Ideal Institute of Technology, Ghaziabad] |


Image Enhancement System 201
6

domain filters. Where spatial domain filters removes the noise and blurs the image.
And frequency domain filters are used to sharpen the inside details of an image.
Filters are useful in many application areas as medical diagnosis, Army and Industrial
areas.

10.1 Future Scope


As in future this software can be combined with any other software or any order
system ever the image enhancement is needed, like in the criminal investigation
system the proposed system can be combined in order to investigate the crime seen ,
more properly and the investigation team. Like this it can be used by the teachers
to illustrate the digital image processing more easily to the students.

Research Publication

Research Paper on Image Enhancement and Its


Various Techniques
Image Enhancement and Its Various Techniques

Pulak Mehrotra1, Shubham Gupta 2, Dr. Sudhir Dawra 3, and Mr. Amit Kumar Jaiswal4
1, 2
Research Scholar at Ideal Institute of Technology, Ghaziabad
3, 4
Research Guide in Department of Computer Science and Engineering at
Ideal Institute of Technology, Ghaziabad

Abstract- Image enhancement is the way of applying some alterations to an input image to
obtain a more visually correct image. Image enhancement is used to improve the image
quality so that the resultant image is better than the original image for a specific application or
set of tasks. The transform domain enables operation on the frequency content of the image, 63
and therefore high frequency content such as edges and other hidden information can easily

[Department of Computer Science & Engineering] [ Ideal Institute of Technology, Ghaziabad] |


Image Enhancement System 201
6

be enhanced. However, these techniques bring about some changes in the images and can also
generate unwanted artifacts in many cases, as it is not possible to enhance all parts of the
image in balanced manner.

Keywords— Image Enhancement, spatial domain techniques, frequency domain techniques

I. INTRODUCTION enhancement techniques is


Digital image processing is to bring out detail that is
a science characterized by hidden [2]. Enhancement is
use of extensive used to restore an image that
experimental work to
has suffered some kind of
establish the ability of
proposed solutions to a destruction due to the
given problem. Image optics, electronics and/or
processing technology is environment or to enhance
used by planetary scientists some features of an image.
to enhance images of Mars, The motive of image
Venus or other planets. The enhancement depend on the
image processing system
application context, and the
includes image
enhancement techniques. criteria for enhancement are
Image Enhancement means often subjective or too
to improve the digital image complex to be easily
quality, without knowledge changed to useful objective
about the source of measures, image
debasement. Image enhancement algorithms are
Enhancement techniques are
designed to be simple,
used to improve the chance
of accessing of information qualitative, and ad hoc. In
in images for human addition, an image
viewers [1]. It is to increase enhancement algorithm that
the image quality so that the performs well for one class
outputted image is better of images may not perform
than the original image for a same for other classes.
specific application. The
Spatial domain techniques
main purpose of image
enhancement is to increase like the logarithmic
the visibility of the detail transforms, power law
that is hidden in an image or transforms, histogram
to increase contrast in a low equalization, are based on
contrast image. Whenever the direct change of the
an image is changed from
pixels in the image plane,
one form to other such as
digitizing the image, there while the transform
are some form of (frequency) domain
degradation occurs at techniques are based on the
output. manipulation of the
Image enhancement is one orthogonal projection of the
of the simplest and most image rather than the image
important areas of digital itself [4].
image processing. Basically,
II. RELATED WORK 63
the main function of

[Department of Computer Science & Engineering] [ Ideal Institute of Technology, Ghaziabad] |


Image Enhancement System 201
6

Image enhancement process Agaian [7] suggested that


consists of a combination of the similar no transform-
techniques that are used to based enhancement
improve the visual technique is global
appearance of an image or histogram equalization,
to change the image to a which attempts to change
form better suited for the spatial histogram of an
analysis by a human or image to match a uniform
machine. The main distribution. Histogram
objective of image equalization suffers from the
enhancement is to modify problem of being poorly
attributes of an image to suited for retaining small
make it more accurate for a detail because of this global
given task and a specific treatment of the image. It is
observer. During this also common that the
process, more than one equalization will over
attributes of the image are enhance the image, resulting
modified. Digital Image in an undesired loss of
enhancement techniques visual data, of quality, and
provide a multiple choices of intensity scale.
for improving the visual
quality of images. Proper III. IMAGE
choice of techniques is ENHANCEMENT
greatly influenced by the TECHNIQUES
imaging modality, task at Image enhancement
hand and viewing techniques can be divided
conditions [6]. It is into two broad categories:-
important to keep in mind 3.1 Spatial Domain
that enhancement is a very Techniques:
important area of image Spatial domain techniques
processing. Improvement in deal with the image pixels.
quality of these degraded The pixel values are change
images can be achieved by to achieve desired
using these enhancement enhancement. Spatial
techniques [2]. domain techniques like the
logarithmic transforms,
The work done by various power law transforms and
researchers for Image histogram equalization use
Enhancement are discussed to directly manipulate the
as follows pixels in the image. Spatial
Madhu [4] has concluded techniques are particularly
that the Adaptive histogram useful for directly changing
equalization produced a the gray level values of very
better result, but the image single pixels and hence the
is still not free from washed contrast of the entire image.
out appearance. The But they usually enhance
sharpness is dull and the the whole image in a
background information uniform manner which in
together with the plane is many cases produces
still fogged and poor in unwanted results. It is not
contrast. Even the outline of possible to selectively
the clouds which was visible enhance edges and other
in case of histogram required information 63
equalization is lost. effectively. Techniques like

[Department of Computer Science & Engineering] [ Ideal Institute of Technology, Ghaziabad] |


Image Enhancement System 201
6

histogram equalization are the image back to the spatial


effective in many cases. domain [4]. The usual
3.1. 1 Point Operation orthogonal transforms are
Point operations / image discrete cosine transform,
processing operations are discrete Fourier transform,
applied to particular pixels Hartley Transform etc. The
only. The point operation is transform domain allows
represented by operation on the frequency
g(x, y)= T[f(x, y)] part of the image, and
Where f(x, y) represent the therefore high frequency
input image, g(x, y) is the area such as edges and other
output image, and T is the hidden information can
operator defining the easily be acquired.
modification function which
operates on one pixel. IV. APPLICATIONS
3.1.2 Mask Operation
In mask operation, very Image enhancement is used
pixel is changed according for increasing a quality of
to values in a small images. The applications of
neighborhood. image enhancement are
3.1.3. Global Operation Digital camera application,
In global operation, all Remote sensing, Aerial
pixels values in the image imaging, Satellite imaging
are taken into consideration and Medical imaging.
for performing operation.
3.2 Frequency Domain V. CONCLUSION
Techniques Most of the techniques are
Frequency domain useful for change the gray
techniques mainly focus on level values of single pixels
the change of the orthogonal and hence the total contrasts
transform of the image of the entire image. But they
instead of the image itself. mainly enhance the whole
Frequency domain image in a uniform manner
techniques are mainly used which in many cases
for processing the image produces unwanted results.
according to the frequency There are various
content . The logic behind techniques available which
the frequency domain give highly balanced and
methods for image visually appealing results
enhancement consists of for a different type of
computing a 2D discrete images with different
unitary transform of the qualities of contrast and
image, for instance the 2-D edge information and it will
DFT, changing the produce optimal output.
transform coefficients by an
operator N, and then REFERENCES
performing the inverse [1] Raman Maini and
transform. The orthogonal Himanshu Aggarwal, “A
transform of the image has 2 Comprehensive Review of
components magnitude and Image Enhancement
phase. The magnitude Techniques”, Journal of
covers the frequency Computing, Vol. 2, Issue 3,
content of the image. The March 2010, ISSN 2151-
63
phase is used to returning 9617.

[Department of Computer Science & Engineering] [ Ideal Institute of Technology, Ghaziabad] |


Image Enhancement System 201
6

[5] Komal Vij, Yaduvir


[2] Rajesh Garg, Bhawna Singh, “Comparison
Mittal, Sheetal Garg, between Different
“Histogram Equalization Techniques of Image
Techniques for Image Enhancement” International
Enhancement”, IJECT Vol. Journal of VLSI and Signal
2, Issue 1, March2011, Processing
ISSN 2230-9543.

[3] Gonzalez, Rafael C.,


Richard E. Woods. : Digital
Image Processing. Ed III,
Pearson Education Asia,
New Delhi, 2007.

[4]S Jayaraman,S
Esakkirajan,T
Veerakima:Digital Image
Processing, Ed III, Tata
McGraw Hill Education
private limited, New Delhi.

References

[1.] http://www.sun.com

[2.] http://www.javalessons.com

[3.] http://www.javalobby.com

[4.] Volume 2, Issue 4, April 2012 ISSN: 2277 128X International Journal of
Advanced Research in Computer Science and Software Engineering.
[5.] International Journal of Advanced Research in Computer and
Communication Engineering Vol. 2, Issue 3, March 2013Various Image
Enhancement Techniques- A Critical Review
.

63

[Department of Computer Science & Engineering] [ Ideal Institute of Technology, Ghaziabad] |

S-ar putea să vă placă și