100% found this document useful (3 votes)
7 views

Fuzzy Logic for Image Processing A Gentle Introduction Using Java SpringerBriefs in Electrical and Computer Engineering Caponetti Laura Castellano Giovanna pdf download

The document is a brief introduction to the book 'Fuzzy Logic for Image Processing: A Gentle Introduction Using Java' by Laura Caponetti and Giovanna Castellano, which focuses on the application of fuzzy logic in image processing. It covers both theoretical foundations and practical applications, including Java implementations of various image processing algorithms. The book is structured into two main parts: fundamentals of fuzzy image processing and specific applications, aiming to serve as a reference for students and researchers in the field.

Uploaded by

dossasdyettal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (3 votes)
7 views

Fuzzy Logic for Image Processing A Gentle Introduction Using Java SpringerBriefs in Electrical and Computer Engineering Caponetti Laura Castellano Giovanna pdf download

The document is a brief introduction to the book 'Fuzzy Logic for Image Processing: A Gentle Introduction Using Java' by Laura Caponetti and Giovanna Castellano, which focuses on the application of fuzzy logic in image processing. It covers both theoretical foundations and practical applications, including Java implementations of various image processing algorithms. The book is structured into two main parts: fundamentals of fuzzy image processing and specific applications, aiming to serve as a reference for students and researchers in the field.

Uploaded by

dossasdyettal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 68

Fuzzy Logic for Image Processing A Gentle

Introduction Using Java SpringerBriefs in


Electrical and Computer Engineering Caponetti
Laura Castellano Giovanna download
https://textbookfull.com/product/fuzzy-logic-for-image-
processing-a-gentle-introduction-using-java-springerbriefs-in-
electrical-and-computer-engineering-caponetti-laura-castellano-
giovanna/

Download more ebook from https://textbookfull.com


We believe these products will be a great fit for you. Click
the link to download now, or visit textbookfull.com
to discover even more!

Control Oriented Modelling of AC Electric Machines


SpringerBriefs in Electrical and Computer Engineering
Masmoudi

https://textbookfull.com/product/control-oriented-modelling-of-
ac-electric-machines-springerbriefs-in-electrical-and-computer-
engineering-masmoudi/

Modern Algorithms for Image Processing: Computer


Imagery by Example Using C# 1st Edition Vladimir
Kovalevsky

https://textbookfull.com/product/modern-algorithms-for-image-
processing-computer-imagery-by-example-using-c-1st-edition-
vladimir-kovalevsky/

Image Processing and Computer Vision in iOS Oge Marques

https://textbookfull.com/product/image-processing-and-computer-
vision-in-ios-oge-marques/

Java Image Processing Recipes: With OpenCV and JVM


Modrzyk

https://textbookfull.com/product/java-image-processing-recipes-
with-opencv-and-jvm-modrzyk/
Nonlinear Eigenproblems in Image Processing and
Computer Vision Guy Gilboa

https://textbookfull.com/product/nonlinear-eigenproblems-in-
image-processing-and-computer-vision-guy-gilboa/

Feature extraction and image processing for computer


vision Fourth Edition Aguado

https://textbookfull.com/product/feature-extraction-and-image-
processing-for-computer-vision-fourth-edition-aguado/

Metaheuristics and Optimization in Computer and


Electrical Engineering Navid Razmjooy

https://textbookfull.com/product/metaheuristics-and-optimization-
in-computer-and-electrical-engineering-navid-razmjooy/

Introduction to Visual Computing: Core Concepts in


Computer Vision, Graphics, and Image Processing 1st
Edition Aditi Majumder

https://textbookfull.com/product/introduction-to-visual-
computing-core-concepts-in-computer-vision-graphics-and-image-
processing-1st-edition-aditi-majumder/

Feature Extraction and Image Processing for Computer


Vision 4th Edition Mark Nixon

https://textbookfull.com/product/feature-extraction-and-image-
processing-for-computer-vision-4th-edition-mark-nixon/
SPRINGER BRIEFS IN
ELEC TRIC AL AND COMPUTER ENGINEERING

Laura Caponetti
Giovanna Castellano

Fuzzy Logic for


Image Processing
A Gentle
Introduction Using
Java

123
SpringerBriefs in Electrical and Computer
Engineering
More information about this series at http://www.springer.com/series/10059
Laura Caponetti Giovanna Castellano

Fuzzy Logic for Image


Processing
A Gentle Introduction Using Java

123
Laura Caponetti Giovanna Castellano
Dipartimento di Informatica Dipartimento di Informatica
Università degli Studi di Bari Aldo Moro Università degli Studi di Bari Aldo Moro
Bari Bari
Italy Italy

ISSN 2191-8112 ISSN 2191-8120 (electronic)


SpringerBriefs in Electrical and Computer Engineering
ISBN 978-3-319-44128-3 ISBN 978-3-319-44130-6 (eBook)
DOI 10.1007/978-3-319-44130-6

Library of Congress Control Number: 2016947389

© The Author(s) 2017


This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part
of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations,
recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission
or information storage and retrieval, electronic adaptation, computer software, or by similar or
dissimilar methodology now known or hereafter developed.
The use of general descriptive names, registered names, trademarks, service marks, etc. in this
publication does not imply, even in the absence of a specific statement, that such names are exempt
from the relevant protective laws and regulations and therefore free for general use.
The publisher, the authors and the editors are safe to assume that the advice and information in this
book are believed to be true and accurate at the date of publication. Neither the publisher nor the
authors or the editors give a warranty, express or implied, with respect to the material contained
herein or for any errors or omissions that may have been made.

Printed on acid-free paper

This Springer imprint is published by Springer Nature


The registered company is Springer International Publishing AG Switzerland
To Alfred, Philip and Vito and all my
friends

Laura Caponetti

To David and Serena, improved images


of me

Giovanna Castellano
Preface

The secret to getting ahead is getting started.

Mark Twain

This book is the result of many years of teaching image processing and fuzzy logic
taught by the authors for undergraduate courses. Most of the material used is also
the result of fertile interactions with the students whose case studies contributed a
lot in the Java implementation of algorithms and methods. The volume has been
conceived as a gentle introduction to fuzzy logic approaches useful in image pro-
cessing tasks.
First we describe image processing algorithms based on fuzzy logic under a
methodological point of view. Then, we provide some practical applications
without passing over the important formal details. We tried to identify the most
important works that researchers have done in the area of fuzzy image processing,
and we described and illustrated them through Java examples that the interested
readers can easily follow.
The book covers both theoretical and practical applications of fuzzy techniques
in image processing. Accordingly, the chapters have been grouped into two parts:
Fundamentals of Fuzzy Image Processing and Applications to Image Processing.
In the first part, we explain how image processing can take advantage of fuzzy
logic, giving basic theoretical aspects of both fuzzy logic and image processing
through five chapters. Chapter 1 is devoted to the basics of image representation
using Java. Chapter 2 deals with low-level image processing. In Chap. 3 the reader
will find the basic concepts of fuzzy logic, starting from fuzzy set theory up to fuzzy
systems. Chapter 4 discusses the issue of vagueness in digital images, that is the
motivation of using fuzzy techniques to process images. Finally, Chap. 5 introduces
the Java language and its use for image processing.
In the second part, we present four chapters covering different image processing
tasks, namely color contrast enhancement, image segmentation, morphological
analysis, and image thresholding. For each task an example of practical application

vii
viii Preface

is described. Some examples are presented in the medical domain, using light
microscope images provided by the Dipartimento di Endocrinologia ed Oncologia
Molecolare e Clinica of the University “Federico II” of Naples, Italy. Lastly, the
appendix provides some Java code examples that the user can easily run which will
help create a concrete feeling of the potential fuzzy image processing.
We believe that this volume will provide a state-of-art coverage of various
aspects related to fuzzy image processing and show the potential of fuzzy tech-
niques in solving image processing problems. We hope this book will serve as a
reference for scientists and students in this area, as well as a means to stimulate
some new ideas for researchers.
We are grateful to a number of people from academic circles as well as from
domestic environments who have contributed to the writing of this book in many
different ways. In particular, we thank all the members of the CILab (Computational
Intelligence Laboratory) of the Department of Informatics at the University of Bari
“Aldo Moro” for giving answers to our questions at the right time. We thank
Menina Di Gennaro for reading the first draft of some chapters and giving helpful
suggestions at the early stages of the work. Our special thanks go to Mara Basile
and Vito Corsini who gave their contribution to the research on morphology and
segmentation applied to the medical domain. We also thank our Ph.D. student
Przemyslaw Gorecky for his contribution on document analysis by fuzzy approa-
ches. Finally, we thank our students Antonio Vergaro, Francesco Tangari, Gabriella
Casalino, Marco Lucarelli, and Massimo Minervini for developing some Java
examples cited in this book. The contribution of everyone is truly appreciated.

Bari, Italy Laura Caponetti


June 2016 Giovanna Castellano
Contents

Part I Fundamentals of Fuzzy Image Processing


1 Image Representation Using Java . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2 Gray-Level Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.3 Color Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.4 Color Image Representation Using Java . . . . . . . . . . . . . . . . . . . . . 10
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2 Low-Level Image Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.2 Contrast Enhancement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2.2.1 Gray-Level Transformation . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.2.2 Thresholding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.2.3 Histogram Transformation . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.3 Image Smoothing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
2.4 Edge Detection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
2.4.1 Canny Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
2.4.2 Optimization-Based Operators . . . . . . . . . . . . . . . . . . . . . . . 36
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
3 Basics of Fuzzy Logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
3.2 Fuzzy Set Theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
3.3 Fuzzy Rule-Based Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
3.3.1 Fuzzification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
3.3.2 Fuzzy Rule Base and Inference Engine . . . . . . . . . . . . . . . . 43
3.3.3 Defuzzification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
3.4 Fuzzy Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
3.4.1 Design of Fuzzy Rule-Based Systems . . . . . . . . . . . . . . . . . 46
3.4.2 Neuro-Fuzzy Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51

ix
x Contents

4 Fuzzy Image Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53


4.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
4.2 Image Fuzzification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
4.2.1 Fuzzy Image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
4.3 Image Defuzzification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
4.4 Fuzziness Measures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
5 Java for Image Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
5.1 Basic Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
5.2 Java for Image Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
5.3 Applet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
5.4 ImageJ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
5.4.1 Macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
5.4.2 Plugins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
5.5 Fuzzy Systems in Java . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81

Part II Application to Image Processing


6 Color Contrast Enhancement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
6.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
6.2 Multichannel Image Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
6.3 Fuzzy Techniques for Color Enhancement . . . . . . . . . . . . . . . . . . . 86
6.4 A Fuzzy Rule-Based System for Color Enhancement . . . . . . . . . . . 87
6.5 Example: Natural Image Enhancement . . . . . . . . . . . . . . . . . . . . . . 88
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
7 Image Segmentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
7.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
7.2 The Segmentation Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
7.3 Methods for Segmentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
7.3.1 Crisp Clustering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
7.3.2 Fuzzy Clustering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
7.3.3 Spatial Fuzzy Clustering . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
7.4 Example: Color Segmentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
7.5 Example: Texture Segmentation . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
8 Morphological Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
8.1 Mathematical Morphology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
8.1.1 Morphological Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
8.2 Fuzzy Morphology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
8.3 Example: Biological Image Segmentation . . . . . . . . . . . . . . . . . . . . 113
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
Contents xi

9 Image Thresholding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121


9.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
9.2 Otzu Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
9.3 Fuzzy Thresholding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
9.4 Example: Document Image Analysis . . . . . . . . . . . . . . . . . . . . . . . 127
9.4.1 Document Segmentation . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
9.4.2 Region Classification. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
Appendix A: Java Code References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
About the Authors

Laura Caponetti received her degree in Physics at the University of Bari, Italy,
in 1972. She is Associate Professor (retired) at the Computer Science Department
of the University of Bari “A. Moro”, where she has been working from 1982 as
Assistant Professor. Her research interests are in image processing and computer
vision. Her research (https://www.researchgate.net/profile/Laura_Caponetti) spans a
range of topics including image segmentation, 3D object recognition, 3D scene
analysis, fuzzy and image processing. She has published over eighty papers and she
is a referee of international journals and conferences. She has been a member of the
scientific committee of the Master in Remote Sensing Techniques and a member
of the Council of Ph.D. in Computer Science at the Bari University. She has been a
lecturer of Information Processing Systems (Sistemi di Elaborazione della infor-
mazione) for the degree course in Computer Science and Computer System
Foundations (Fondamenti di Informatica) for the degree course in Civil
Engineering. Moreover, she has been a lecturer of Image Processing for the degree
course in Computer Science and for the Master in Remote Sensing Techniques.
Currently she is a referee of the “Ministero dell’Istruzione, dell’Università e della
Ricerca” (http://www.istruzione.it/). Also, she is a member of many scientific
associations such as IAPR (Italian Chapter), AICA, and AIIA.
Giovanna Castellano is Associate Professor at the Computer Science Department
of the University of Bari “A. Moro”, Italy. In 1993 she received her degree in
Informatics from the University of Bari. From 1993 to 1995 she was a fellow
researcher at the CNR Institute for Signal and Image Processing in Bari, Italy. In
2001 she got a Ph.D. in Informatics from the University of Bari, where she became
Assistant Professor in 2002. Her research interests are mainly focused on compu-
tational intelligence, with special focus on fuzzy systems, neural networks,
neuro-fuzzy modeling, fuzzy clustering, granular computing, and fuzzy image
processing. Her current research activity concerns the application of fuzzy tech-
niques in image processing and retrieval. Within these research areas, she has been
co-author of more than 170 papers published on scientific journals, book

xiii
xiv About the Authors

collections, and international conference proceedings. Working on these topics she


joined a number of research projects and she organized a number of special sessions
and workshops in international conferences. She is Associate Editor of the journal
Information Sciences (ISSN:0020-0255) and a member of the editorial board of
several international journals.
Part I
Fundamentals of Fuzzy
Image Processing

The first part of the book introduces the fundamental concepts of fuzzy image
processing; namely, we provide basic concepts of low-level image processing and
fundamental principles of fuzzy logic. These concepts are equipped with a basic
introduction to the Java programming language.
Chapter 1
Image Representation Using Java

Intelligence is not to make no mistakes, but quickly to see how to


make them good.
Bertolt Brecht

Abstract This chapter covers some basic concepts of gray-level and color image
representation. Digital images are logically represented using a matrix of elements,
each element having a single value in case of gray-level images and three/four values
in case of color images. The chapter also introduces the most used color models and
the representation of images provided by Java.

1.1 Introduction

A digital image is a two-dimensional representation of an object or a three-


dimensional scene resulting from a digitalization process (see Fig. 1.1). An image
can be considered as a two-dimensional digital signal acquired by means of two
basic processes: sampling in the spatial domain and quantization in the value/level
domain. In other words, a digital image is defined as a two-dimensional digital func-
tion f (x, y) that is a mapping from a spatial coordinate domain D into an intensity
value domain D  :
f : D → D

where D is a finite domain consisting of pairs of discrete coordinates (x, y) and D  is


the discrete domain of values called gray levels. Typically the domain D  is the range
[0, 255]. A digital image consists of a finite set of elements having a location (x, y)
and a value denoted by l. Each element f (x, y) is called pixel—picture element.

© The Author(s) 2017 3


L. Caponetti and G. Castellano, Fuzzy Logic for Image Processing,
SpringerBriefs in Electrical and Computer Engineering,
DOI 10.1007/978-3-319-44130-6_1
4 1 Image Representation Using Java

Fig. 1.1 Image acquisition and digitalization process

Digital image processing refers to all those tasks that involve processing a digital
image by a computer. We can distinguish among low-level, medium-level, and high-
level processing. In low-level processing tasks we have a digital image as input and
a digital image as output—for example an image improved for the visualization. In
high-level processing the outcome is a description of the content of the input image.
In medium-level processing some features are obtained from the input image, for
examples edges or regions. This book mainly focuses on low-level and medium-
level image processing.
This chapter provides a brief introduction to digital image processing. The aim is
to introduce the fundamentals of gray-level and color image processing, with special
focus on the tasks considered as applications of fuzzy techniques in the second part
of the volume. For further details about the basics of image processing, the reader is
referred to specific bibliography [1, 3].

1.2 Gray-Level Images

A digital image f having a finite number of non negative values—typically in the


range [0, 255]—is called gray-level image. It can be represented by a matrix of
N × M elements, where N is the row number and M the column number. Each
element f ( j, k) for 0 ≤ j ≤ N and 0 ≤ k ≤ M is a pixel having abscissa x = k
and ordinate y = − j. Then a digital image can be represented using the logical
coordinate system (x, y) or the image coordinate system ( j, k), where x = k is the
column and y = − j is the row (see Fig. 1.2).
1.2 Gray-Level Images 5

Fig. 1.2 Image coordinate system

Fig. 1.3 A gray-level image with a high dynamic range and b low dynamic range

A digital image can be described by means of some features such as


• dimension: the number of pixels in the image.
• size: the number of rows and columns of the image or also the size (width and
height) expressed in cm/inch.
• spatial resolution: the number of pixels for size unity expressed in dot per inch
(dpi).
• dynamic range or resolution in the gray-level range: the number of different gray
levels actually used in the image. For example if the range is [0, 255], an image
using all 256 levels presents a high dynamic range. Conversely, an image using
only few levels presents a very low dynamic range (Fig. 1.3).

1.3 Color Models

There are basically two ways to specify colors in a computer. The RGB (Red Green
Blue) definition is the more natural approach in terms of the human visual system
and it is also the approach used to drive computer monitors. In fact the RGB system
6 1 Image Representation Using Java

matches with the fact that the human eye is strongly perceptive to red, green, and
blues primaries.
The secondary colors CMY (Cyan Magenta Yellow) are used for printing and are
basically complementary to RGB. However, the RGB and CMY color models are not
well suited for describing color for human interpretation. Defining a specific color
using a RGB set of numbers is very difficult, unless it is one of the end members.
Indeed, one does not refer to the color of an object by giving the percentage of each
primary component.
For these reasons other color representations are adopted, such as the HSB rep-
resentation where the features used to distinguish one color from another are Hue,
Saturation, and Brightness. Hue is an attribute associated with the dominant wave-
length in a mixture of light waves. Hue represents dominant color as perceived by an
observer. Saturation refers to the relative purity or the amount of white light mixed
with the hue. The pure spectrum colors are fully saturated and the degree of saturation
being inversely proportional to the amount of light added. Brightness embodies the
chromatic notion of intensity. Hue and saturation together are called chromaticity so
a color can be represented by its brightness and chromaticity.
A color model or color system is a subspace of a three-dimensional coordinate
system in which each color is represented by a single point. Generally a color model is
oriented either toward hardware (as for monitor and printers) or toward applications.
The most common hardware-oriented color models are
• the RGB model for color monitor and color video cameras;
• the CMY model for color printers;
By contrast, the HSV (Hue, Saturation, and Value) and HSI (Hue, Saturation,
and Intensity) color models, referred to the HSB representation, are user/application
oriented and correspond to the way humans perceive and describe color using the
words tint, shade, and tone.

RGB Color Model


In the RGB system each color is represented by its primary components relative to
Red, Green, and Blue. The model is based on a Cartesian coordinate system. The
RGB space is represented by a cube (see Fig. 1.4), in which the primary colors are at
three corners; cyan, magenta, and yellow are at the three opposite corners. Black is at
the origin and white is at the corner farthest from the origin. The gray scale—points
of equal RGB values—extends from the black point to white point along the line
joining these two points. The different colors in this model are points on or inside the
cube. They are defined by vectors extending from the origin of the Cartesian system.

HSV Color Model


The HSV color system, also called HSB (B for Brightness) is closer than RGB
system to the way human describe color sensations. In artistic terminology hue,
1.3 Color Models 7

Fig. 1.4 RGB color model (taken from [3])

Fig. 1.5 HSV-HSB color


model

saturation, and value refer to tint, shade, and tone. The HSV model is defined in a
subspace represented by a hexacone or six-sided cone (Fig. 1.5). The HSV is based
on cylindrical coordinate. A cylindrical coordinate system is a three-dimensional
coordinate system (ρ, φ, z) that specifies point positions by the distance ρ from a
chosen reference axis, the direction φ from the axis relative to a chosen reference
direction, and the distance z from a chosen reference plane perpendicular to the axis.
Hue, corresponding to φ, is expressed as an angle around a color hexagon using the
red axis as the 0 axis. Value, corresponding to z, is measured along the axis of the
cone lying in the center of the color hexagon. The end of the axis V = 0 represents
black, while the end V = 1 is white. Thus the cone axis represents all shades of gray.
Saturation, corresponding to ρ, is measured as the distance from the V axis.
The conversion from a RGB value to a HSV value is given in the following [2].
We define Δ = max(R, G, B) − min(R, G, B). As concerns the Hue component,
there are two cases. If R = G = B then Δ = 0 and the Hue is undefined. If Δ > 0
then we compute
8 1 Image Representation Using Java

R ∗ = (max(R, G, B) − R)/Δ
G ∗ = (max(R, G, B) − G)/Δ
B ∗ = (max(R, G, B) − B)/Δ

and then
⎧ ∗
⎨ B − G∗ if R = max(R, G, B)

H = R ∗ − B ∗ + 2 if G = max(R, G, B)
⎩ ∗
G − R ∗ + 4 if B = max(R, G, B)

Finally, by normalizing, we have


1
(H ∗ + 6) for H ∗ < 0
H= 6 (1.1)
H∗ otherwise

The S and V components are defined as follows:



max(R, G, B)/Δ if Δ > 0
S= (1.2)
0 otherwise

V = max(R, G, B)/Cmax (1.3)

where Cmax is the maximum value in the RGB scale (generally Cmax = 255).

HSI Color Model


The HSI color model is based on triangular and circular planes, as depicted in Fig. 1.6.
The triangles and circles are perpendicular to the vertical intensity axis. The Hue (H)
is measured by the angle around the vertical axis and has a range of values between
0◦ and 360◦ beginning with red at 0◦ . It gives a measure of the spectral composition
of a color. The saturation (S) is a ratio that ranges from 0 (i.e. on the I axis) extending
radially outwards to a maximum value of 1 on the surface of the cone. This component
refers to the proportion of pure light of the dominant wavelength and indicates how
far a color is from a gray of equal brightness. The intensity (I) also ranges between
0 and 1 and measures the relative brightness. At the top and bottom of the cone,
where I = 0 and I = 1, respectively, H and S are undefined and meaningless. At any
point along the I axis the saturation component is zero and the Hue is undefined.
This singularity occurs whenever R = G = B.
 
−1
1
(R − G) + (R − B)
H = cos  2
(1.4)
(R − G)2 + (R − B)(R − G)
3
S = 1− [min(R, G, B)] (1.5)
R+G+B
1
I = (R + G + B) (1.6)
3
1.3 Color Models 9

Fig. 1.6 HSI color model (taken from [3])

The HSV/HSI systems provide a more natural way to define a color: the value
of hue sets the color according to the colors of the rainbow red, orange, yellow,
green, blue, violet, and back to red. Decreasing the value of brightness moves the
color toward black and decreasing the saturation moves the color toward white. The
10 1 Image Representation Using Java

reason is that HSV/HSI systems allow movements in color space which correspond
more closely to what we mean by tint and shade. An instruction like add white is
easy in HSI but not so obvious in RGB. The HSV color system is somewhat similar
to HSI system, but its aim is to present colors that are meaningful when interpreted
in terms of a color artist palette.

1.4 Color Image Representation Using Java

To represent a color image it is necessary to define the color model. Then a color
pixel can be represented directly by means of three components (e.g., Red, Green,
Blue). If a byte is used to represent each component, it is possible to represent
256 × 256 × 256 different colors (about 16 millions). The BitMaP format uses the
direct representation of the color, also known as true color representation. Often to
limit the memory size a number of four or eight bits are used for each pixel. In this
case it is necessary to use also a palette or colormap, that is a look-up table in which
every element contains a tuple of three values RGB. In this case each pixel value
is an entry in the look-up table. Then this representation is an indirect or indexed
representation of the color value. The GIF, TIF, and PNG formats use an indexed
representation of the color and use a look-up table of 4 or 8 bit, hence each pixel is
an index into a palette of 16 or 256 colors.
Java permits to memorize and process a color image by means of the package
image. In Chap. 5 an introduction to Java and ImageJ plugin for image processing
is presented.
Java represents a RGB color image by an array of pixels. Each color pixel is
represented in a packed mode using a 32 bit integer value, where the high order byte
represents the alpha component followed by the Red, Green, and Blue components.
The alpha value represents the level of transparency of the pixel varying from 0
(transparent pixel, i.e., invisible) to 255 (opaque pixel). In a gray-level image the
three components (R, G, B) have the same value. To transform a color pixel into a
gray-level one we can use the following formulas:

I = (R + G + B) (1.7)

Since the eye is more sensible to Green and Red than to Blue color, usually a
weighted sum that takes in account the different perception of the human eye for the
three fundamental colors, is used

I = 0.299R + 0.587G + 0.114B (1.8)

Java supports several image formats for RGB true color images, such as TIFF,
BMP, JPEG, PNG, and RAW. Moreover it supports formats for RGB indexed
color images such as GIF, PNG, BMP, and TIFF. In particular the Java class
ColorProcessor provides a support to process easily color images in RGB and
HSB spaces by offering the following functions:
1.4 Color Image Representation Using Java 11

1. creation of a new image


2. conversion from RGB to HSB and vice versa
3. splitting or merging the color components
4. managing a stack of components or slides by adding a slice or deleting, merging
slides into an image.
The Listing 1.1 shows a Java plugin to convert a color image from RGB to a HSB
(HSV) stack using the Eqs. (1.1), (1.2) and (1.3).
Listing 1.1 A Java program to convert RGB to HSI.
i m p o r t ij .*;
i m p o r t ij . p l u g i n . f i l t e r . P l u g I n F i l t e r ;
i m p o r t ij . p r o c e s s .*;
i m p o r t ij . gui .*;
i m p o r t java . awt .*;
/* S p l i t s an RGB i m a g e into three 8 - bit g r a y s c a l e c o m p o n e n t s
( hue , s a t u r a t i o n and b r i g h t n e s s ) */
public class RGB_Splitter_into_HSI_components
implements PlugInFilter {
I m a g e P l u s imp ;
p u b l i c int s e t u p ( S t r i n g arg , I m a g e P l u s imp ) {
this . imp = imp ;
return DOES_RGB + NO_UNDO ;
}
p u b l i c v o i d run ( I m a g e P r o c e s s o r ip ) {
int w = imp . g e t W i d t h ();
int h = imp . g e t H e i g h t ();
I m a g e S t a c k h s b S t a c k = imp . g e t S t a c k ();
I m a g e S t a c k h u e S t a c k = new I m a g e S t a c k (w , h );
I m a g e S t a c k s a t S t a c k = new I m a g e S t a c k (w , h );
I m a g e S t a c k b r i g h t S t a c k = new I m a g e S t a c k (w , h );
byte [] hue ,s , b ;
C o l o r P r o c e s s o r cp ;
int n = h s b S t a c k . g e t S i z e ();
for ( int i =1; i <= n ; i ++) {
IJ . s h o w S t a t u s ( i + " / " + n );
hue = new byte [ w * h ];
s = new byte [ w * h ];
b = new byte [ w * h ];
cp = ( C o l o r P r o c e s s o r ) h s b S t a c k . g e t P r o c e s s o r (1);
cp . g e t H S B ( hue , s , b );
h s b S t a c k . d e l e t e S l i c e (1);
// S y s t e m . gc ();
h u e S t a c k . a d d S l i c e ( null , hue );
s a t S t a c k . a d d S l i c e ( null , s );
b r i g h t S t a c k . a d d S l i c e ( null , b );
IJ . s h o w P r o g r e s s (( d o u b l e ) i / n );
}
S t r i n g t i t l e = imp . g e t T i t l e ();
imp . hide ();
new I m a g e P l u s ( " ( hue ) " + title , h u e S t a c k ). show ();
new I m a g e P l u s ( " ( s a t u r a t i o n ) " + title , s a t S t a c k ). show ();
new I m a g e P l u s ( " ( b r i g h t n e s s ) " + title , b r i g h t S t a c k ). show ();
}
}
12 1 Image Representation Using Java

Listing 1.2 Color inverter Java plugin.


i m p o r t ij .*;
i m p o r t ij . gui .*;
i m p o r t java . awt .*;
i m p o r t ij . p l u g i n . f i l t e r . P l u g I n F i l t e r ;
i m p o r t ij . p r o c e s s .*;
/* C o l o r I n v e r t e r
* I n v e r t s the p i x e l s in the ROI of a RGB i m a g e .
* T h i s is an e x a m p l e f r o m the I m a g e J p l u g i n w r i t i n g t u t o r i a l :
* http :// www . fh - h a g e n b e r g . at / mtd / d e p o t / i m a g i n g / i m a g e j
*/
public class ColorInverter_ implements PlugInFilter {
p u b l i c int s e t u p ( S t r i n g arg , I m a g e P l u s imp ) {
if ( arg . e q u a l s ( " a b o u t " ))
{ s h o w A b o u t (); r e t u r n DONE ;}
return DOES_RGB + NO_CHANGES ;
}
//
p u b l i c v o i d run ( I m a g e P r o c e s s o r ip ) {
// get width , h e i g h t and the r e g i o n of i n t e r e s t
int w = ip . g e t W i d t h ();
int h = ip . g e t H e i g h t ();
R e c t a n g l e roi = ip . g e t R o i ();
// c r e a t e a new i m a g e with the same size
// and c o p y the p i x e l s of the o r i g i n a l image
ImagePlus inverted = NewImage . createRGBImage (
" I n v e r t e d image " , w , h , 1 , N e w I m a g e . F I L L _ B L A C K );
I m a g e P r o c e s s o r i n v _ i p = i n v e r t e d . g e t P r o c e s s o r ();
i n v _ i p . c o p y B i t s ( ip ,0 ,0 , B l i t t e r . COPY );
int [] p i x e l s = ( int []) i n v _ i p . g e t P i x e l s ();
// i n v e r t the p i x e l s in the ROI
for ( int i = roi . y ; i < roi . y + roi . h e i g h t ; i ++) {
int o f f s e t = i * w ;
for ( int j = roi . x ; j < roi . x + roi . width ; j ++) {
int pos = o f f s e t + j ;
int c = p i x e l s [ pos ];
int r = ( c &0 x f f 0 0 0 0 ) > >16; // e x t r a c t red c o m p o n e n t
int g = ( c &0 x 0 0 f f 0 0 ) > >8; // e x t r a c t g r e e n c o m p o n e n t
int b = ( c &0 x 0 0 0 0 f f ); // e x t r a c t blue c o m p o n e n t
r =255 - r ;
g =255 - g ;
b =255 - b ;
p i x e l s [ pos ] = ( ( r & 0 xff ) < <16)+(( g & 0 xff ) < < 8)+( b & 0 xff );
}
}
i n v e r t e d . show ();
i n v e r t e d . u p d a t e A n d D r a w ();
}
void s h o w A b o u t () {
IJ . s h o w M e s s a g e ( " C o l o r I n v e r t e r " ," i n v e r t s ROI of a RGB image " );
}
}

The Listing 1.2 shows an example of Java plugin to convert a RGB value, packed
in an integer c, into the three fundamental components [r g b] and then to invert
each component and produce a new image with the color scale inverted. To isolate
each color component, for each pixel [u,v] a bit-wise AND operation is applied
to an appropriate bit mask expressed in hexadecimal notation. After the extracted
1.4 Color Image Representation Using Java 13

bits are shifted right 16 bit positions for the r component, and right 8 positions for
the g component, as shown in the Listing 1.2. The details of the code can be better
understood by reading Chap. 5 about Java introduction for image processing.

References

1. Burger, W., Burge, M.J.: Digital Image Processing: An Algorithmic Introduction Using Java.
Springer Science & Business Media, Heidelberg (2009)
2. Foley, J.D., Van Dam, A.: Fundamentals of Interactive Computer Graphics, vol. 2. Addison-
Wesley, Reading (1982)
3. Gonzalez, R.C., Woods, R.E.: Digital Image Processing. Prentice Hall, Upper Saddle River
(2008)
Chapter 2
Low-Level Image Processing

As regards obstacles, the shortest distance between two points


can be a curve.
Bertolt Brecht

Abstract This chapter covers some basic concepts of low-level image processing.
It introduces fundamental methods for two primary image processing tasks, namely
contrast enhancement, image smoothing, and edge detection. The chapter also intro-
duces methods of function optimization for searching the optimal configuration of
edge points.

2.1 Introduction

In the previous chapter, we have introduced the concept of low-level, medium-level,


and high-level digital image processing. In low-level processing tasks a digital image
is used as input and another digital image is obtained as output (e.g., an image
improved for the visualization). In high-level processing the outcome is a description
of the content of the input image. In the medium-level processing some features are
obtained from the input image, such as edges or regions.
Different operators are adopted for low-level processing. Usually, we distinguish
among the following operators:
1. Point operators that produce a single output pixel by processing each pixel inde-
pendently of the other pixels.
2. Local operators that produce a single output pixel by processing a neighborhood
of that pixel.
3. Global operators that produce a single output pixel by processing the entire image.

© The Author(s) 2017 15


L. Caponetti and G. Castellano, Fuzzy Logic for Image Processing,
SpringerBriefs in Electrical and Computer Engineering,
DOI 10.1007/978-3-319-44130-6_2
16 2 Low-Level Image Processing

Generally the aim of low-level operators is to improve the visual quality of the input
image by means of enhancement or noise removal processes. In this chapter we
introduce two fundamental image processing tasks that are contrast enhancement
and edge detection. To this aim, some notations are given in the following.
Let f (x, y) a gray-level image of M × N pixels with L gray levels. We introduce
the following definitions:
• the level scale or dynamic range of image f (x, y) is the range [a, b] of values such
that a ≤ f (x, y) ≤ b for each (x, y);
• the histogram h(i), i = 0, . . . , L − 1 of image f (x, y) denotes the occurrence fre-
quency of each level.
In Listing 2.1, we provide a simple applet to compute the histogram of a gray-level
image. The applet can be executed using the HTML code listed in 2.2. To run the
applet it is necessary to create a Java project with the files HistogramApplet.java and
HistogramApplet.html, then include in the same directory an image named im.png
to be processed.
In the RGB color space, individual histograms of each component can be com-
puted. In [5] we find a plugin to compute the histogram of each R, G, B component
given an input color image.
Listing 2.1 HistogramApplet.java: a Java applet for histogram visualization.

i m p o r t java . awt .*;


i m p o r t java . awt . image .*;
import java . applet . Applet ;
public class HistogramApplet extends Applet {
private Image image ;
private ImageCanvas imageCanvas ;
private Panel panel ;
p r i v a t e T e x t A r e a text ;

p u b l i c v o i d init () {
S t r i n g i m a g e _ f i l e = g e t P a r a m e t e r ( " I M A G E F I L E " );
i m a g e = g e t I m a g e ( g e t D o c u m e n t B a s e () , i m a g e _ f i l e );
w h i l e ( i m a g e . g e t W i d t h ( this ) <0);
D i m e n s i o n i m a g e S i z e = new D i m e n s i o n (
i m a g e . g e t W i d t h ( this ) , i m a g e . g e t H e i g h t ( this ));
i m a g e C a n v a s = new I m a g e C a n v a s ( image , i m a g e S i z e );
int [] p i x e l s = I m a g e C a n v a s . g r a b I m a g e ( image , i m a g e S i z e );
p a n e l = new P a n e l ( new G r i d L a y o u t (1 ,2 ,10 ,10));
text = new T e x t A r e a (20 ,5);
p a n e l . add ( i m a g e C a n v a s );
panel . add ( text );
add ( p a n e l );
text . s e t T e x t (( new H i s t o g r a m ( p i x e l s )). t o S t r i n g ());
}
}
class Histogram {
p r i v a t e int h i s t o [] = new int [ 2 5 6 ] ;
p u b l i c S t r i n g t o S t r i n g () {
String text = "";
for ( int i =0; i < 2 5 6 ; i ++) {
text += i + " " + h i s t o [ i ]+ ’ \ n ’ ;
}
2.1 Introduction 17

r e t u r n text ;
}
p u b l i c H i s t o g r a m ( int [] rgb ) {
for ( int i =0; i < rgb . l e n g t h ; i ++) {
int tmp = ( int ) (
((( rgb [ i ] & 0 x f f 0 0 0 0 ) > >16) * 0 . 2 9 9 ) +
((( rgb [ i ] & 0 x 0 0 f f 0 0 ) > >8 ) * 0 . 5 8 7 ) +
((( rgb [ i ] & 0 x 0 0 0 0 f f ) ) * 0 . 1 1 4 ) );
histo [ tmp ]++;
}
}
p u b l i c int g e t V a l u e A t ( int i n d e x ) {
r e t u r n h i s t o [ i n d e x ];
}
}
class ImageCanvas extends Canvas {
s t a t i c f i n a l int M I N _ W I D T H = 64;
s t a t i c f i n a l int M I N _ H E I G H T = 64;
private Image image ;
p r i v a t e D i m e n s i o n size ;

p u b l i c I m a g e C a n v a s ( I m a g e img , D i m e n s i o n dim ) {
s u p e r ();
i m a g e = img ;
size = dim ;
}
p u b l i c D i m e n s i o n g e t M i n i m u m S i z e () {
r e t u r n new D i m e n s i o n ( MIN_WIDTH , M I N _ H E I G H T );
}
p u b l i c D i m e n s i o n g e t P r e f e r r e d S i z e () {
r e t u r n new D i m e n s i o n ( size );
}

public void paint ( Graphics g) {


g . d r a w I m a g e ( image , 0 , 0 , g e t B a c k g r o u n d () , this );
}
s t a t i c p u b l i c int [] g r a b I m a g e ( I m a g e image , D i m e n s i o n size ) {
int [] data = new int [ size . width * s i z e . h e i g h t ];
P i x e l G r a b b e r pg = new P i x e l G r a b b e r (
image , 0 , 0 , size . width , size . height , data , 0 , size . width );

try {
pg . g r a b P i x e l s ();
}
catch ( InterruptedException e) {
S y s t e m . err . p r i n t l n (
" I m a g e S a m p l e r : i n t e r r u p t e d w h i l e g r a b b i n g p i x e l s " );
return null ;
}
if (( pg . s t a t u s () & I m a g e O b s e r v e r . A B O R T ) != 0) {
S y s t e m . err . p r i n t l n (
" I m a g e S a m p l e r : p i x e l grab a b o r t e d or e r r o r e d " );
return null ;
}
r e t u r n data ;
}
}
18 2 Low-Level Image Processing

Listing 2.2 HistogramApplet.html: Html code to run HistogramApplet.java.


< html >
< head > < title > Histogram </ title > </ head >
< body >
<H1 > Histogram </ H1 >
< applet
name = " H i s t o g r a m A p p l e t "
code = " H i s t o g r a m A p p l e t . c l a s s "
w i d t h = " 800 "
h e i g h t = " 500 "
alt = " If you have a Java - e n a b l e d browser ,
you w o u l d see an a p p l e t here . " >
< param name = " I M A G E F I L E " v a l u e = " im . png " >
</ applet >
</ body >
</ html >

Generally, to define each low-level operator, a mapping T that transforms an input


image f (x, y) into an output image g(x, y) has to be defined over some neighborhood
of each pixel. Namely

g(x, y) = T (f (x, y)) (2.1)

where T is a linear or nonlinear function defined on the dynamic range [a, b].

2.2 Contrast Enhancement

The contrast of an image refers to the range of gray levels used in the image—the
dynamic range. It refers to the intensity variation of the pixels, defined by the mini-
mum and maximum intensity value. Contrast resolution is the ability to distinguish
between differences in intensity. For example, low contrast image values may be
concentrated near a few values of the gray scale (e.g., mostly dark, or mostly bright,
or mostly medium values). One definition of image contrast is the following:
SA − SB
C=
SA + SB

where SA and SB are intensity average values computed on pixels of two different
regions A and B (for example background and object).
Low contrast images can result from poor illumination, lack of dynamic range
in the imaging sensor, or even wrong set up during image acquisition. A funda-
mental low-level task is to improve the contrast in an image, by means of contrast
enhancement operators.
To improve the contrast it is necessary to transform the levels of the image into
the range of all the levels available for visualization (typically the range [0, 255]).
Specifically, a contrast stretching, that means highlighting a specific range of gray
levels in an image, is performed. The idea behind contrast stretching is to increase
Random documents with unrelated
content Scribd suggests to you:
back
back
back
back
back
back
back
back
back
back
back
back
back
back
back
back
back
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

textbookfull.com

You might also like