You are on page 1of 123

TABLE OF CONTENTS

Table of Contents 1

Authors Note 3

Subject Requirements 4

Rules and Regulations Inside the Computer Laboratory 5

Introduction to Medical Electronics

Introduction to Medical Electronics 6

Medical Electronics Equipments 8

Laboratory Exercise No.1

Introduction to LabVIEW and IMAQ Vision 14

Laboratory Exercise No.2

Basic Image Processing of Digital Images 24

Laboratory Exercise No.3

Image Enhancement Point Operation 47

Laboratory Exercise No.4

Image Enhancement- Spatial Operation 56

Laboratory Exercise No.5

Color Images 67

Laboratory Exercise No.6

Image Processing in the Frequency Domain 78

Laboratory Exercise No.7

Region of Interest and Look-Up Transformation 91

Laboratory Exercise No.8

Morphological Image Processing 99

1|Page
References 120

2|Page
AUTHORS NOTE

First of all we would like to give praise and thanks to the Almighty God for blessing us
with knowledge, perseverance and good people who helped us in finishing this manual. We
would also like to thank our parents not only for the financial support but also for encouraging
us to do better, and giving us moral support. We would also like to extend our deepest
gratitude to our thesis adviser, Engr. Lean Karlo Tolentino, with his guidance and suggestions to
improve our thesis. Lastly, we also like to thank our panelists and the whole ECE Faculty for
sharing with us their knowledge and expertise, and for helping us all the way to accomplish our
thesis.

-The Authors

3|Page
SUBJECT REQUIREMENTS

Listed below are the requirements needed in order to accomplish the laboratory
exercises included in laboratory manual.

1. Computer or Laptop
2. LabVIEW 2013 Workbench
3. IMAQ Vision Toolkit
4. Sample Images to be Provided by the Instructor

4|Page
RULES & REGULATION IN THE COMPUTER LABORATORY

1. The computer laboratory facilities are available to students and staffs of the College of
Engineering and intended for the academic use.

2. Smoking, eating, and drinking are strictly prohibited inside the laboratory.

3. Mobile phones must be switched off or put to silent mode at all times.

4. Users are expected to conduct themselves in a responsible and courteous manner while in
Computer Lab.

5. Games are strictly prohibited on all Computer Labs resources.

6. Users should not prevent or disrupt another user from using of any computer and other
facility in the computer lab.

7. Running is prohibited inside the laboratory.

8. Unauthorized copying of copyrighted software is illegal and is prohibited in the academic


computing facilities or elsewhere on campus.

9. Kindly approach the instructor for any malfunction on the computer immediately.

10. The user is strictly advised to take care of their personal belonging all the time. The College
of Engineering is not responsible and liable to any loss of personal belonging in the
laboratory.

11. Clean your workstation before leaving the computer laboratory.

5|Page
INTRODUCTION TO MEDICAL ELECTRONICS

What is Medical Electronics?


Medical electronics is a branch of electronics
which focuses on the use of electronic instruments,
devices, apparatuses, equipments and systems in the
field of medicine. Medical electronics is commonly
applied in diagnosis, therapy, research, anesthesia
control, cardiac control and surgery.

The field of medical electronics also refers to


the design, theory, development and improvement of
existing instruments, apparatuses, equipment and
systems.

Medical Electronics Engineers


A medical electronics engineers can be described as
the doctor of equipments. They have the knowledge on the
machines mechanisms, operations and maintenance. They
also design devices and solve problems regarding medical
equipments and apparatuses.

Medical electronics engineers combine theories on


medicine, biology and principles of electronics engineering.
They create, evaluate and develop systems and products such
as artificial organs, prostheses, instrumentations, medical
information systems, health management and care delivery
systems.

Medical electronics engineers also develop and create devices used in various medical
procedures, imaging systems like magnetic resonance imaging (MRI), and devices that can be
used for the automation of medical systems such as insulin injections for diabetic patients and
controlling body functions. The specialty of medical electronics engineers includes biomaterials,
biomechanics and medical imaging, rehabilitation engineering and orthopedic engineering.

6|Page
A. Job Profiles for Medical Electronics Engineers

1. Clinical Engineers
2. Biomaterials Engineers
3. Patent Analyst
4. Professors
5. Research Scientist
6. Technical Writers
7. Biomechanics Engineers
8. Bioinstrumentation Engineer

7|Page
MEDICAL ELECTRONICS EQUIPMENT

In the continuous and fast paced change of technology, medical electronics and medical
treatments and technologies has been greatly advancing. Medical electronics allowed easy
monitoring of health problems and made it easy for the medical field to identify diseases in a
very simple process and implement treatment. Medical electronics provides sophisticated
equipments which are very precise and can do perfect identification of diseases.

A. Medical Electronics Equipment

1. Blood Gas Analyzer

Blood gas analyzer is used to calculate the pressure of chemical elements such as
carbon monoxide, oxygen and nitrogen in the blood. The blood collected is placed in a
chemical device strip which is made up of electrodes, through the exploitation of the
amplifiers and analog electronic device; the results are displayed digitally in a monitor in
terms of millimeters of mercury (mmHg) and kilopascals (kPa).The normal values of
carbon monoxide and dioxide ranges from 34 mmHg to 35 mmHg and for oxygen it
ranges from 80 mmHg to 90 mmHg

Figure 1 Blood Gas analyzer

2. Blood Glucose Monitor

A blood glucose monitor is very useful to those who suffer diabetes. It is used to
measure the level of glucose (sugar) in the blood. A little drop of blood is placed in the
chemical strip; the strip is made up of sensors which calculate the amount of various

8|Page
chemical components. The blood glucose meter can calculate the amount of glucose in
the blood within seconds and the result is shown in a LED display.

Figure 2 Blood Glucose Monitor

3. Brain Wave Machine

A brain wave machine is an instrument which records the electrical activity of


the scalp through the aide of electroencephalography by firing neurons within the brain.
The data that has been taken from the electrodes placed on the scalp are processed and
displayed in a screen. Brain wave machines are very helpful in the treatment of some
brain disorders such as sleeping disorders, brain death and unhealthiness of the brain.

Figure 3 Brain Wave Machine

9|Page
4. Electronic Cardiac Monitor

Electronic cardiac monitors are used to display electrical and pressure


waveforms of the cardiac system. Electrodes are placed in specific parts of the body and
these electrodes gather electrical impulses which are processed and the output is
displayed in a monitor. Electronic Cardiac Monitor helps in observing irregular activities
occurring in the cardiac system and heart issues. It is used throughout medical
treatment especially during operation and surgery.

Figure 4 Electronic Cardiac Monitor

5. Digital Thermometers

Digital thermometer is the most common medical electronic device used in the
field of medicine. It is also the most common device found in households. Digital
thermometers are used to measure the bodys temperature.

Figure 5 Digital Thermometers

10 | P a g e
6. Infrared (IR) Thermometers

IR thermometers are used to detect temperature by sensing the radiation


generated by the body. The difference between IR thermometers and Digital
thermometers is the proximity that it can be used. Digital thermometers must be placed
in armpits but IR thermometers can measure temperature from a distance. It is most
commonly used in airports to quarantine passengers who experience fever. Passengers
are quarantined and are observed to determine the cause of fever. This procedure is
vital to prevent the spread of viral diseases such as EBOLA and other hemorrhagic fever
diseases. IR thermometers have lenses which focus infrared energy onto a target body;
it then detects the energy and display the result in a form of electrical signal which is
then shown in a LED display in units of temperature.

Figure 6 IR Thermometer

7. Defibrillator

Defibrillators are used in emergency instances like heart attacks. Defibrillators


deliver electric shock to the heart which causes depolarization of the muscles of the
heart. This process regenerates normal conduction of the electrical pulse of the heart.

Figure 7 Defibrillator

11 | P a g e
8. Sphygmomanometer

The device used to measure blood pressure is known as a sphygmomanometer.


It uses an inflatable cuff to control blood flow and mercury to measure the pressure in
terms of mmHg.

Figure 8 Sphygmomanometer

9. X-ray Machine

X-ray machine are used to create an image of the inside of ones body. It produces a
controlled beam of radiation directed to the area being examined. After passing through
the body, the beam falls into an x-ray plate where it casts a shadow. The white parts on
the film signify that the radiation went through a dense tissue such as a bone. The
darker parts indicate that the radiation went through soft or less dense tissues. The
images obtained during an exam may be viewed on film or could be digitized so that it
can be viewed in a monitor or computer screen. X-ray machines are very helpful in
determining fractures and broken bones or cartilages.

Figure 9 X-ray Machine

12 | P a g e
10. MRI (Magnetic Resonance Imaging) Machine

Magnetic resonance imaging is a technique used in radiology. MRI has a wide


scope of application. Magnetic resonance imaging does not use any radiation that is why
it is recommended in preference to CT scan.

Figure 10 Magnetic Resonance Imaging Machine

13 | P a g e
Laboratory Exercise No. 1
INTRODUCTION TO LABVIEW AND IMAQ VISION

I. OBJECTIVES
1. To familiarize the block diagrams and tool palettes introduced by the IMAQ Vision
toolkit.
2. To create basic VIs related to image processing, such as creating, acquiring, displaying,
and saving images.

II. THEORY
LabVIEW, which stands for Laboratory
Virtual Instrument Engineering Workbench, is
a platform and development environment for
a visual programming language. It was
originally released for the Apple Macintosh
by National Instruments in 1986. LabVIEW is made for a wide variety of applications and
industries such as science and engineering. Specifically, it is commonly used in data acquisition,
instrument control, and industrial automation. It can also be used on a variety of platforms
including Windows, Linux and Mac OS X.

LabVIEW uses data programming language referred to as G. The files saved in


LabVIEW have the extension .vi, which is an abbreviation for Virtual Instrument.LabVIEW is
made up of libraries such as the IMAQ Vision that could be used for image acquisition.

A. IMAQ Vision

The NI Vision Acquisition software is the basic software needed to create Vision
applications for LabVIEW or the .NET platform. The NI Vision Acquisition software includes the
necessary drivers, such as NI-IMAQ and NI-IMAQdx.

IMAQ Vision is a library of LabVIEWVIs used to create machine vision and scientific
imaging application. IMAQ stands for image acquisition; therefore the primary application of
IMAQ Vision is image processing and acquisition. IMAQ Vision is composed of control and
function palettes to process and acquire data from the images.

14 | P a g e
1. IMAQ Vision Control Palette

a. IMAQ IMAGE. CTL


IMAQ IMAGE.CTL describes the data type of the image. This is used to
characterize the image data type in the front panel of a VI.

b. IMAGE DISPLAY CONTROL


The image display control is used to display the images on the
front panel VI.

2. IMAQ Function Palette

a. IMAGE MANAGEMENT
Image Management is a group VIs primarily concerned in the
management of images. It is used to create and remove images, set and red the
images attributes and copy one image to another.

b. FILES
This is made up of a group of VIs which read the images from files and
writes images to files in different image formats. It can also retrieve the
information of the image inside a file.

c. EXTERNAL DISPLAY
External display is a group of VIs which manages the display of images in
the external image window. The function of this control is get and set window
attributes, assign color palettes to image windows, sense draw events and
retrieve information about ROIs.

d. REGION OF INTEREST
The region of interest is a group of VIs used to define ROIs and convert the
ROIs to image masks and vice versa.

15 | P a g e
e. IMAGE MANIPULATION
Image Manipulation is made up of a group of VIs which changes the
spatial content of images. This is used to resample, extract parts, rotate, shift,
and unwrap images. It is a subpalette which also contains Vis which could copy
images to and from the clipboard.

f. PIXEL MANIPULATION
Pixel manipulation is a group of VIs that is used to read and change
individual pixels in a particular image. This could be used in changing the pixel
value and to modify an image to 2D LabVIEW array and back to the original
format.

g. OVERLAY

Overlay control is a group of VIs that covers graphics on the image display
environment without particularly changing the values of the pixel. This is
primarily used for image inspection applications.

h. CALIBRATION

Calibration control is composed of a group of VIs that dimensionally


calibrates an image to take specific, real-world measurements; this is regardless
of camera perspective and lens distortions.

i. COLOR UTILITIES
It is a group of Vis that access data from color images. This is used to
extract and get the different color planes from a particular image. This is also
used to alter the planes of a color image using a new data and change a color
image to and from a 2d array.

j. IMAQ RT

IMAQ RT or IMAQ Real Time control provides functionality when using NI


IMAQ and IMAQ Vision with LabVIEW RT. This is used to showcase images to
Video Out in the RT system and control the compression setting for transferring
and sending images over a particular network.

16 | P a g e
3. Most Commonly Used Block in IMAQ RT Vision

a. IMAQ Create
Creates an image buffer that can be input into any of the acquisition functions
of your IMAQ device

b. IMAQ Dispose
IMAQ dispose is used to remove an image and frees the memory allocated for
the image.

c. IMAQ Status
IMAQ Status lists information about all the image structures created
by IMAQ Create and about the memory space they occupy.

4
d. IMAQ GetFileInfo
It obtains information regarding the contents of the file. This information is
supplied for standard file formats only: BMP, TIFF, JPEG, PNG, or AIPD.

e. IMAQ ReadFile
IMAQ ReadFile is block used to read an image file.

17 | P a g e
f. IMAQ WriteFile
The block IMAQ WriteFile is used to inscribe an image to a file.

g. IMAQ GetPalette
IMAQ GetPalette selects a display palette to be used.

h. IMAQ WindClose
The block called IMAQ WindClose is used to close an image window.

i. IMAQ WindDraw
IMAQ WindDraw displays an image in an image window.

III. PROCEDURE

A. Loading and Opening an Image File in the Front Panel Window

1. Launch the LabVIEW application and create a new blank VI. (Desktop >LabVIEW
2013> Blank VI)
2. On the Block Diagram Window Panel, use IMAQ Load Image Dialog (Right click on
the block diagram panel > File I/O >Adv File Funcs> File Dialog) and create a constant
in its Prompt node, name it Select an Image File.
3. From the Path node of IMAQ Load Image Dialog, connect it to the File Path node
of the IMAQ GetFileInfo (Right click on the block diagram panel > Vision and Motion
> Vision Utilities > Files >IMAQ GetFileInfo).
4. Use IMAQ Create (Right click on the block diagram panel > Vision and Motion >
Vision Utilities > Image Management > IMAQ Create) and connect the Error Out

18 | P a g e
node of the IMAQ GetFileInfo to its Error In node. Create also an Image Name by
creating a constant; name it as Read Image Source. Also, interconnect the Image
Type node of both IMAQ Create and IMAQ GetFileInfo.
5. Use an IMAQ ReadFile (Right click on the block diagram panel > Vision and Motion >
Vision Utilities > File > IMAQ ReadFile) and connect its File Path node to the Path
node of IMAQ Load Image Dialog. From the New Image node of the IMAQ Create,
connect it to the Image node of the IMAQ ReadFile block. Connect also the error
ins and outs of IMAQ Create and ReadFile.
6. Then, create an Image Indicator on the Image Out node of the IMAQ ReadFile.
7. Use IMAQ Dispose (Right click on the block diagram panel > Vision and Motion >
Vision Utilities > Image Management > IMAQ Dispose) and connect IMAQ ReadFiles
Image Out to its Image node. Connect also the error ins and outs of IMAQ
ReadFile and IMAQ Dispose. Connect its Error out node to a Simple Error Handler
(Right click on the block diagram panel >Dialog & User Interface>Simple Error
Handler).
8. Go to the Front Panel View and replace the Image Out indicator. (Right-click on the
indicator, then replace. Go to Vision, and choose any Image Display block shown).
9. Run the program, choose Image 1 from the folder X-RAYS located at Digital
Image Processing Using LabVIEW Images folder and take note of the output image.

Figure 1.1 Loading an image in the Front Panel Window VI

B. Opening and Loading a File into a New Window

1. Create another blank VI in LabVIEW. (Desktop >LabVIEW 2013> Blank VI)


2. Use File Dialog block (Right click on the block diagram panel > File I/O >Adv File
Funcs> File Dialog). Theres a window that will appear, click File or Folder and
New and/or existing. Create a name for its Prompt node, Select an Image File.
3. From the Selected Path node of the File Dialog, connect it to the File Path node
of the IMAQ ReadFile (Right click on the block diagram panel > Vision and Motion >
Vision Utilities > Files> IMAQ ReadFile).
4. Using the New Image node of the IMAQ Create (Right click on the block diagram
panel > Vision and Motion > Vision Utilities > Image Management > IMAQ Create),

19 | P a g e
connect it to the Image node of the IMAQ ReadFile. Create an Image Name for
the selected image file as shown below.
5. Connect the Image Out node of the IMAQ ReadFile to the Image node of the
IMAQ WindDraw (Right click on the block diagram panel > Vision and Motion >
Vision Utilities > External Display > IMAQ WindDraw).
6. Run the program, choose Image 3 from the folder X-RAYS located at Digital
Image Processing Using LabVIEW Images folder and take note of the output image.

Figure 1.2 Loading an image using another window VI

C. Saving a Standard Image File

1. Using Figure 1.2, save the selected standard image file into different image format
file by using IMAQ WriteFile (Right click on the block diagram panel > Vision and
Motion > Vision Utilities > Files> IMAQ WriteFile).
2. From the Image Out node of the IMAQ WindDraw (Right click on the block
diagram panel > Vision and Motion > Vision Utilities > External Display > IMAQ
WindDraw), connect it to the Image node of the IMAQ WriteFile.
3. Using a Flat Sequence Structure (Right click on the block diagram panel > Structures
>Flat Sequence Structure), contain it with another File Dialog (Right click on the block
diagram panel > File I/O >Adv File Funcs> File Dialog), where its Start Path node is
connected to the File Path node of the IMAQ WriteFile. Create also a prompt for
the File Dialog as shown below.
4. Lastly, connect the error out of IMAQ WindDraw to the error in of the File Dialog
inside the Flat Sequence Structure. This ensures that there will be a correct
sequence of tasks needed to be executed.
5. Run the program; choose Image 6 from the folder X-RAYS located at Digital
Image Processing using LabVIEW Images folder.
6. Another window will appear that will save the selected image. Save it on the same
folder as Left Wrist X-ray, and use different image file format (.png, .tiff, .bmp,
.jpg, etc.).
7. Check the folder if the Left Wrist X-ray image was saved, and differentiate the
images saved in different image file format.

20 | P a g e
8. Repeat Procedures 1-7 using Figure 1.1

Figure 1.3 Wiring Diagram of Saving a standard image file

IV. OBSERVATION
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________

V. DATA AND RESULTS


_________________________________________________________________________
_________________________________________________________________________
_________________________________________________________________________
_________________________________________________________________________

21 | P a g e
VII. TEST YOUR SKILLS
1. Create an application that contains two buttons, one for loading an image and the other
one for closing the application. The close button must release the memory area, to close
the window and to stop the application execution.

2. Modify Figure 1-.2 in order to be able to load color images.

3. Construct the VI given in Figure 1.4, and then differentiate it from the VI of Figure 1.2 in
terms of its function.

Figure 1.4 Loading an Image using another window

VIII. QUESTIONS AND ANSWERS


1. Which is a better way of displaying an image, using the front panel or using another
window? Explain.
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________

22 | P a g e
2. Why is it always necessary to dispose a previous function in a given diagram before
doing another? Is it also necessary to connect Simple Error Handler after finishing the
Vis? Explain.
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________

3. What are the differences between the Image Types used in IMAQ Vision toolkit?
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________

IX. CONCLUSION
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________

23 | P a g e
Laboratory Exercise No. 2
BASIC IMAGE PROCESSING OF DIGITAL IMAGES

I. OBJECTIVES
1. To differentiate a digital image from an ordinary image.
2. To familiarize basic image processing through the use of digital images.
3. To differentiate sampling and quantization based on their functions when used in basic
image processing.
4. To differentiate basic image processing and arithmetic image processing, and state their
importance.
5. To determine the applications of sampling, quantization, basic and arithmetic image
processing in biomedical engineering.

II. PRE-REQUISITE KNOWLEDGE


1. Knowledge on LabVIEW and IMAQ Vision.
2. Basic Knowledge on the Control and Function Palette of IMAQ Vision.

III. THEORY
An image in general is a picture or a visual representation of an
object, scene, person or abstraction formed on a surface. Image came from
the Latin word imitari which means to copy or imitate. It is also defined as
a two-dimensional function of x and y wherein x and y are spatial
coordinates. The amplitude of the function at any pair of coordinates x and
y is known as the intensity of the image at that level. An image can be
classified as a digital image if x, y and the value of its amplitude is finite
and discrete. Each digital image is made up of a finite number of elements
termed as pixels. Each pixel has a different and unique location and
particular value. The physical size of a pixel is known as spatial resolution.

The first ever digital


Image processing is done in order to get an enhanced image
image was a 176x176 pixel
and to extract information from a particular picture. It is classified
image made by Russell
under signal processing wherein the input is an image and the output
Kirsch in 1957. The image
can either be also an image or characteristics relevant to the input
was a scanned photograph
image. There are two types of image processing namely analogue and
of his then three-month old
digital image processing. Analogue image processing involves hard
son.
copies and image printouts inspected by image analysts in order to
garner information from the image. Digital Image Processing on the
other hand is a technique aided by computers. 24 | P a g e
A. Sampling and Quantization
The process of converting information into a digital format is called digitization. A
specific image, in order for it to be suitable for digital image processing, must be digitized
spatially and also in amplitude, there are two steps to digitize an image, these are sampling and
quantization.

1. SAMPLING
Digitizing the coordinates of a continuous image given by x and y is called sampling.
Sampling is the primary factor which defines image resolution and determines the number of
pixels in a given digital image. The sampling rate defines the spatial resolution of the digitized
image. The common broadcast video standard of an image is 640x480 pixel dimension.

Original Image (a) (b)

Figure 2.1 A 580 x 415 image resampled into (a) 400x284 image and (b) 50x 35 image.

The horizontal and vertical sampling rate determines the pixel dimension of the image.
Pixel dimension can be obtained by multiplying the physical width and height of the image by
the spatial resolution usually given in dots-per-inch (dpi) or pixels-per-inch.

pixel dimensions = physical dimensions resolution

Example:

A 10 by 14 image is scanned, determine the pixels dimension of the image at (a) 500
dpi and (b) 300 dpi. What will be the effect of a greater spatial resolution value?

Solution:

(a) At 500 dpi:


Pixel dimension = (10 (500)) x (14(500))
Pixel dimension = 5000x7000

25 | P a g e
The digital image that would be produced will have a dimension of 5000x7000 pixels.

(b) At 300 dpi:


Pixel dimension = (10(300)) x (14(300))
Pixel dimension = 3000 x 4200
The digital image that would be produced will have a dimension of 3000 x 4200
pixels.

Hence, greater dpi will result to a greater pixel dimension of the digital image.

2. QUANTIZATION

Digitizing the amplitude (intensity values) of an image is known as the process of


quantization. It is the principal factor in determining the grey-level resolution of a particular
image. In simple terms, quantization determines the limit or particular grey-level a particular
pixel can handle without changing or ruining the image. Insufficient image quantization results
into the occurrence of false contours which is classified as one of the most prevalent problem in
some images.

Original Image (a) (b) (d)

Figure 2.2 A grey-level 256 cranial skull x-ray image displayed into (a) grey-level 200 (b) 24 and
(c) 4 without changing its spatial resolution.

Grayscale is the collective term used to call all grey levels ranging from black to white.
Grayscale images do not convey any color information. The number of quantization is usually
given by the integral power of two.

The number of bits used to determine a pixel value is termed as bit depth. The typical
employed bit depth is 8. This is to ensure that 256 possible grey levels are used as pixel value.

26 | P a g e
Figure 2.3 Depth and Grey Levels in Digital Images

B. Basic Image Processing


Image processing is the process of manipulating images and the alterations are usually
done in digital domain by aid of computer. The easiest image processing can be done by
altering the physical location or coordinates of the pixels of a given digital image. There are
three common image processing that changes the physical location of pixels, these are Image
Shift, Image Symettry and Image Rotation. Image Symettry is the process of reversing the
location of pixels base on symettry locations. Image Shift is the shifting of all pixels to the right,
left, up or down without modifying the interconnection of the entire image.Image Rotation is
the processing of turning or rotationg the location of pixels from a given point of origin. The
usual point of origin if rotation of an image is its center.

Original Image (a)

(b) (c)

Figure 2.4 the image on the upper left is the original image of a normal childs heart x-ray.
Image (a) undergone image symmetry and is flipped horizontally. Image (b) is horizontally
shifted while (c) is rotated at a certain degree.

27 | P a g e
C. Arithmetic Image Processing
Not only the pixel location of a particular image could be varied, but also the value of
the pixel could also be changed by using arithmetic image processing, this process is called
Arithmetic Image Processing. This process is carried out by either adding or subtracting an
integer to / or from a pixel value or by either multiplying or dividing image pixels by a constant
value.

Orignal Image

(a) (b)

Figure 2.5 the image at the center is the original image, (a) shows a deduction of 50 in pixel
value while image (b) shows an addition of 50 in pixel value.

D. Blocks Used For Image Processing

1. ARITHMETIC OPERATORS
a. IMAQ Add
The IMAQ Add block adds two images or an image to a constant.

28 | P a g e
b. IMAQ Subtract
The IMAQ Subtract block subtracts one image from another or a constant from
an image.

c. IMAQ Multiply
The IMAQ Multiply block multiplies two images or an image and a constant

d. IMAQ Divide
The block IMAQ Divide is used to divide one image by another image or an image by
a constant

IV.PROCEDURE

A. Image Properties and Sampling

1. Launch LabVIEW application and create a new blank VI. (Desktop >LabVIEW 2013>
Blank VI)
2. On the block diagram window, use a File Dialog (Right click on the block diagram
panel > File I/O >Adv File Funcs> File Dialog) to browse image files. Connect the
Selected Path node of the File Dialog block to the File Path node of IMAQ ReadFile
(Right click on the block diagram panel > Vision and Motion > Vision Utilities > File >
IMAQ ReadFile). Create also a constant at the Prompt node of the File Dialog.

29 | P a g e
3. With IMAQ Create (Right click on the block diagram panel > Vision and Motion >
Vision Utilities > Image Management > IMAQ Create) labeled as shown in Figure 1,
connect the New Image node to the Image node of the IMAQ ReadFile, also the
error out to the error in of the same block. On the File Type out node of the IMAQ
ReadFile, create an indicator and view it as an icon and label it as File Format.
4. Connect the Image Out node of the IMAQ ReadFile to an IMAQ WindDrawblock
(Right click on the block diagram panel > Vision and Motion > Vision Utilities >
External Display > IMAQ WindDraw). Create also a constant at the Title node of the
same block.
5. Connect also the Image Out node of the IMAQ ReadFile to an IMAQ
GetImageInfoblock (Right click on the block diagram panel > Vision and Motion >
Vision Utilities >Image Management > IMAQ GetImageInfo), and the error out of the
IMAQ ReadFile to the error In of IMAQ GetImageInfo. Connect also the error out of
the same block to the error in of IMAQ WindDraw and then its error out to a Simple
Error Handler (Right click on the block diagram panel >Dialog & User
Interface>Simple Error Handler).
6. On the IMAQ GetImageInfo block, create an indicator for both the X and Y resolution
nodes and label it accordingly.
7. Create a case structure as shown below. Connect the Unit node of the IMAQ
GetImageInfo to the case selector node of the case structure (Right click on the block
diagram panel > Structures > Case Structure).
8. Inside the case structure, use two reciprocal blocks (Right click on the block diagram
panel >Numeric>Reciprocal), two number to decimal string blocks (Right click on the
block diagram panel >String>Number/ String Conversion > Number to Decimal
string), concatenate strings block(Right click on the block diagram panel
>String>Concatenate Strings), and an end-of-line constant block (Right click on the
block diagram panel >String>End-of-line constant). These will be the blocks to use
for the Inch Case at the case structure.
9. Drag-down the concatenate strings block to add another nodes for additional
strings, there must be seven nodes. Place the blocks accordingly as shown in Figure
1.
10. Connect the X Step node of the IMAQ GetImageInfo to the first reciprocal block and
connect it to the number node of the number to decimal string block.
11. Repeat step 10 using the Y Step node of the IMAQ GetImageInfo with the other
reciprocal and number to decimal string block.
12. At the first node of the concatenate strings block, create a constant and name it as X
Resolution.
13. Connect the decimal integer string node of the number to decimal string block to the
second node of the concatenate strings block.

30 | P a g e
14. Create another constant at the third node of the concatenate strings block and
name it pixels/inch.
15. Connect the End-of-line constant at the fourth node of the concatenate strings
block.
16. At the fifth node, create another constant and name it as Y Resolution.
17. Connect the decimal integer string of the second number to decimal string block to
the sixth node of the concatenate strings block.
18. Repeat step 14 but now using the last node of the same block.
19. Connect the concatenated string node of the same block at the wall of the case
structure, from that create an indicator for the concatenated string and label it as
Image Resolution.
20. Go to the Front Panel Window and place accordingly the indicators as shown in
Figure 2.6 (b).

31 | P a g e
(a)

(b)

Figure 2.6 (a) Image Properties Circuit Diagram and (b) Front Panel Window

21. Go back to the case structure and add another case for the unit centimeter.
22. Use again the blocks mentioned in step 8 and add two divide blocks (Right click on
the block diagram panel >Numeric>Divide) between the two reciprocal and number
to decimal string blocks as shown in Figure 3.
23. Repeat the connection of the X and Y Step nodes to the reciprocal block. In this case,
connect the reciprocal block to the x node of the divide block and on its y node,

32 | P a g e
create a constant and put 0.39. Connect the result of the divide block to the number
decimal string block and repeat steps 12 to 19.
24. Add another case on the case structure for the unit meter. Instead of using 0.39 as
constant on the divide block, use 39.3 at the y node.
25. Add another case structure when the unit is Undefined. Create a constant at the
Image Resolution node and type the constant as shown in Figure 3.
26. Run the program and use Image 3 and 6 at the X Rays folder and all the images in
the IMAGES IN DIFFERENT FILE FORMAT folder located at the Digital Image
Processing Folder.

Figure 2.7 Changing of Case Structures VI

B. Basic Image Processing


B.1. Image Symmetry
1. 1. Construct the given VI in Figure 2.8 (a) to simulate basic processing of digital
images by using File Dialog (Right click on the block diagram panel > File I/O >Adv
File Funcs> File Dialog), two IMAQ Create blocks (Right click on the block diagram
panel > Vision and Motion > Vision Utilities > Image Management > IMAQ Create),
IMAQ ReadFile (Right click on the block diagram panel > Vision and Motion > Vision
Utilities > File > IMAQ ReadFile), IMAQ WindDraw (Right click on the block diagram
panel > Vision and Motion > Vision Utilities > External Display > IMAQ WindDraw),
IMAQ WindMove (Right click on the block diagram panel > Vision and Motion >
Vision Utilities > External Display > IMAQ WindMove), a While Loop Structure, three
case structures (Right click on the block diagram panel > Structures > While loop/
Case Structure), IMAQ Dispose (Right click on the block diagram panel > Vision and
Motion > Vision Utilities > Image Management > IMAQ Dispose) and IMAQ
WindClose (Right click on the block diagram panel > Vision and Motion > Vision
Utilities > External Display > IMAQ WindClose).

33 | P a g e
2. Connect the File Dialogs selected path to the IMAQ ReadFiles File Path. Name the
prompt as Select an Image File. Connect the first IMAQ Create by connecting its New
Image node to the Image node of the IMAQ ReadFile, and name it as Source Image.
Connect also it error out to the IMAQ ReadFiles error in.
3. Connect the Image Out node of the IMAQ ReadFile to the Image node of the IMAQ
WindDraw named as Original Image and its error out is connected to IMAQ WindMove.
Number both of their window, 0. Create a constant for the coordinates of the screen at
IMAQ WindMove where the image will be displayed.
4. Create a constant the remaining IMAQ Create and name it as Destination Image and
connect its New Image at the wall of the while loop. Connect also the Image Out node
and error out of the IMAQ ReadFile at the wall of the while loop.
5. Inside the while loop, put a case structure, another case structure inside the first case
structure, and another case structure inside the second case structure, same as shown
in Figure 2.8 (a). Create a control for each case selector of each case structure inside the
while loop. Also change the statement block of the while loop to Continue if True and
create also a control for it.
6. Connect the two image nodes located at the wall of the while loop to the innermost
case structure and connect it to an IMAQ Symmetry block (Right click on the block
diagram panel > Vision and Motion > Vision Utilities >Image Manipulation> IMAQ
Symmetry). Source Image to Image Src node and Destination Image to Image Dst node.
Create a control for the Type of Symmetry node, then move it outside the second case
structure and reconnect it to the IMAQ Symmetry block.
7. Inside the second case structure, put an IMAQ WindDraw named as Processed Image
and will be shown in window number 1. Connect the IMAQ Symmetrys Image Out node
to it. Also, connect its error out to the IMAQ Dispose and IMAQ WindClose. Create a
constant in each block, All images node should be true, the same as the Close all
windows node.
8. Go to the front panel window and replace the control buttons of the three case
selectors in the block diagram window. First the case selector of the innermost case
structure, right-click it and replace, Ring &Enum, and choose Text Ring. Edit its item by
right-clicking it, edit items and input Original Image as its first item. Label the text ring
Image:
9. Second, the case selector at the middle, right-click it, replace, Boolean and choose OK
button. Rename it as TAKE SYMMETRY and make sure its Mechanical action is Latch
when released. Label it on the Block Diagram window as Sym Button
10. Lastly, the outermost case structure, right-click it then replace, Containers and
choose Tab Control. Rename the first tab as Symmetry and put all the controls that
have been created inside the tab as shown in Figure 2.8 (b).

34 | P a g e
11. Replace also the control of the while loop as a stop button.
12. Go to the block diagram window and connect the error out of the IMAQ ReadFile up
to the second case structure. Change the case to False and connect it also to the IMAQ
Dispose and IMAQ WindClose.
13. Create another item/case for the Image Symmetry simulation where the program
will process the PROCESSED image.

(a)

(b)

Figure 2.8 (a) Image Symmetry Simulation VI and (b) Front Panel View

35 | P a g e
B.2. Image Shift
1. From the Front Panel Window, rename the second tab as Shift.
2. Go to the block diagram window, change the case of the outermost case structure to
Shift. Inside the case structure put two case structures the same as the previous
image processing technique just as shown in Figure 2.9 (a).
3. Create a control for the case selectors of the two case structures. Connect the two
image nodes to the innermost case structure and connect to an IMAQ Shift (Right click
on the block diagram panel > Vision and Motion > Vision Utilities >Image
Manipulation> IMAQ Shift). Source Image to Image Src node and Destination Image to
Image Dst node.
4. On the IMAQ Shift block, create a control for the X and Y offset and move it outside
the innermost block and reconnect to the X and Y offset node then label it as
Horizontal and Vertical Shift, respectively.
5. Connect the Image Out node of the IMAQ Shift to an IMAQ WindDraw (Right click on
the block diagram panel > Vision and Motion > Vision Utilities > External Display >
IMAQ WindDraw) located also outside the innermost case structure. Name it as
Processed Image and numbered as window 1, with its error out connected to the
IMAQ Dispose (Right click on the block diagram panel > Vision and Motion > Vision
Utilities > Image Management > IMAQ Dispose) and IMAQ WindClose (Right click on
the block diagram panel > Vision and Motion > Vision Utilities > External Display >
IMAQ WindClose).
6. Go to the Front Panel Window, change the case selector of the innermost case
structure to a text ring and its first item is Original Image. The second case selector
should be replaced to an OK Button renamed as Shift Button and its mechanical action
should be latch when released.
7. Put accordingly inside the Shift tab control the created controls for this processing
technique as shown in Figure 2.9(b).
8. On the block diagram window, connect the error out of the IMAQ ReadFile (Right click
on the block diagram panel > Vision and Motion > Vision Utilities > File > IMAQ
ReadFile) to the second case structure. Change the case to False and connect it to the
IMAQ Dispose and IMAQ WindClose.
9. Create another item/case for the Image Shift simulation where the program will
process the PROCESSED image.

36 | P a g e
(a)

(b)

Figure 2.9 (a) Image Shift Simulation VI and (b) Front Panel View

B.3. Image Rotation


1. From the Front Panel Window, add another page after the second tab and name it as
Rotate.
2. Go to the block diagram window, change the case of the outermost case structure to
Rotate by adding a case after the Shift case. Inside the case structure put two case
structures the same as the previous image processing technique just as shown in
Figure 2.10 (a).
3. Create a control for the case selectors of the two case structures. Connect the two
image nodes to the innermost case structure and connect to an IMAQ Rotate (Right
click on the block diagram panel > Vision and Motion > Vision Utilities >Image
Manipulation > IMAQ Rotate). Source Image to Image Src node and Destination Image
to Image Dst node.
4. On the IMAQ Shift block (Right click on the block diagram panel > Vision and Motion >
Vision Utilities >Image Manipulation> IMAQ Shift), create a control for the Angle
(degrees) node and move it outside the innermost block and reconnect to its node
then label it Angle (degrees).

37 | P a g e
5. Connect the Image Out node of the IMAQ Rotate to an IMAQ WindDraw(Right click on
the block diagram panel > Vision and Motion > Vision Utilities > External Display >
IMAQ WindDraw) located also outside the innermost case structure. Name it as
Processed Image and numbered as window 1, with its error out connected to the
IMAQ Dispose (Right click on the block diagram panel > Vision and Motion > Vision
Utilities > Image Management > IMAQ Dispose) and IMAQ WindClose (Right click on
the block diagram panel > Vision and Motion > Vision Utilities > External Display >
IMAQ WindClose).
6. Go to the Front Panel Window, change the case selector of the innermost case
structure to a text ring and its first item is Original Image. The second case selector
should be replaced to an OK Button renamed as Rotate Button and its mechanical
action should be latch when released.
7. Put accordingly inside the Rotate tab control the created controls for this processing
technique as shown in Figure 2.10(b).
8. On the block diagram window, connect the error out of the IMAQ ReadFile (Right click
on the block diagram panel > Vision and Motion > Vision Utilities > File > IMAQ
ReadFile) to the second case structure. Change the case to False and connect it to the
IMAQ Dispose and IMAQ WindClose.
9. Create another item/case for the Image Rotate simulation where the program will
process the PROCESSED image.

(a)

38 | P a g e
(b)

Figure 2.10 (a) Image Rotation VI and (b) Front Panel View

B.4. Saving the Images

1. From the Front Panel Window, add another page after the third tab and name it as
Save Image.
2. At the block diagram window, change the case of the outermost case structure to
Save Image by adding a case after the Rotate case. Inside the case structure put
another case structure just as shown in Figure 2.11(a).
3. Create a control for the case selector of the case structure. Connect the Destination
Image node to the Image node of the IMAQ WriteFile (Right click on the block diagram
panel > Vision and Motion > Vision Utilities > Files> IMAQ WriteFile) and its File Path
node to selected path node of the File Dialog (Right click on the block diagram panel >
File I/O >Adv File Funcs> File Dialog). Name the prompt as Save File as , and
connect the error out of the IMAQ WriteFile to the IMAQ Dispose (Right click on the
block diagram panel > Vision and Motion > Vision Utilities > Image Management >
IMAQ Dispose)and IMAQ WindClose (Right click on the block diagram panel > Vision
and Motion > Vision Utilities > External Display > IMAQ WindClose).
4. Go to the Front Panel Window, change the case selector to an OK Button renamed as
SAVE PROCESSED IMAGE and its mechanical action should be latch when released.
5. Put accordingly inside the Save Image tab the created control for saving the processed
image shown in Figure 2.12(b).
6. On the block diagram window, connect the error out of the IMAQ ReadFile (Right click
on the block diagram panel > Vision and Motion > Vision Utilities > File > IMAQ
ReadFile) to the second case structure. Change the case to False and connect it to the
IMAQ Dispose and IMAQ WindClose.
7. Go to the Front Panel Window and click the Symmetry tab. Run the program and use
Image 3 at the X-Ray folder at Digital Image Processing Images folder. Take the

39 | P a g e
symmetry in all types, of Image 3 and save it on a folder named Basic Processed
Images - Symmetry. Run the program again, change the text ring to PROCESSED image
to process the processed image and save all the resulting images.
8. Go to the Front Panel Window and click the Shift tab. Run the program and use Image
8 at the X-Ray folder at Digital Image Processing Images folder. Take the 80 th
horizontal shift and 120th vertical shift of Image 8 and save it on a folder named Basic
Processed Images - Shift. Run the program again, change the text ring to PROCESSED
image to process the processed image and save all the resulting images.
9. Go to the Front Panel Window and click the Rotate tab. Run the program and use
Image 6 at the X-Ray folder at Digital Image Processing Images folder. Take the 90-
degree and 180-degree rotation of Image 6 and save it on a folder named Basic
Processed Images - Rotate. Run the program again, change the text ring to PROCESSED
image to process the processed image and save all the resulting images.

(a)

(b)
Figure 2.11 (a) Saving Images Simulation VI and (b) Front Panel View

40 | P a g e
C. Quantization

1. Construct the given VI In Figure 11 to change the bit-depth of digital images by using
File Dialog (Right click on the block diagram panel > File I/O >Adv File Funcs> File
Dialog), two IMAQ Create blocks (Right click on the block diagram panel > Vision and
Motion > Vision Utilities > Image Management > IMAQ Create), IMAQ ReadFile
(Right click on the block diagram panel > Vision and Motion > Vision Utilities > File >
IMAQ ReadFile), a while loop (Right click on the block diagram panel > Structures >
While loop), subtract and scale by power of 2 blocks (Right click on the block
diagram panel >Numeric >Subtract/ Scale by power of 2), IMAQ Divide and
Multiply(Right click on the block diagram panel > Vision and Motion >Image
Processing>Operators> IMAQ Divide/ Multiply), IMAQ WindDraw (Right click on the
block diagram panel > Vision and Motion > Vision Utilities > External Display > IMAQ
WindDraw), Simple Error Handler (Right click on the block diagram panel >Dialog &
User Interface >Simple Error Handler), IMAQ Dispose (Right click on the block
diagram panel > Vision and Motion > Vision Utilities > Image Management > IMAQ
Dispose) and IMAQ WindClose (Right click on the block diagram panel > Vision and
Motion > Vision Utilities > External Display > IMAQ WindClose).
2. Connect the File Dialogs selected path to the File Path node of the IMAQ ReadFile.
Name the prompt as Select an Image File.
3. From the first IMAQ Create named as source image, connect its New Image node to
the Image node of the IMAQ ReadFile. The Image Out node is connected to the
while loop. The second IMAQ Create named as Dest. Image is connected also to the
while loop.
4. Inside the loop, use a subtract block with a constant 8 in its x node and a control in
its y node named as the bit-depth. The difference is connected to the n node of the
scale by power of 2 block, and its x node has a constant of 1.
5. Connect the two image nodes to the IMAQ Divide, Source Image to the Image SrcA
node and Dest. Image at Image Dst node. The constant node of the IMAQ Divide is
connected to the result of the scale by power of 2 block.
6. Connect the Image Dst Out node of the IMAQ Divide to the Image Src A node of the
IMAQ Multiply and its constant node to the result of the scale by the power of 2
block.
7. Connect the Image Dst Out node of the IMAQ Multiply to an IMAQ WindDraw
named Bit-Depth Adjusted Image and numbered as window 0.
8. Connect the IMAQ WindDraw to a Simple Error Handler. The error handler is also
connected to an IMAQ Dispose and IMAQ WindClose located outside the loop.
9. The Image Out node of the IMAQ WindDraw is connected to the IMAQ Dispose.
10. Change the case statement to Continue if True and a control for the said condition
located inside the loop.
11. Run the program and use Cancer 4 Image located at Cancer Cells Folder inside the
Digital Image Processing Images. Change the bit-depth from 8 to 1-bit and snip all

41 | P a g e
the resulting images. Repeat this procedure using Image 8 located at X Ray Folder
inside the same folder.

Figure 2.12 Image Quantization VI

12. Change the bit depth and examine the changes in visual appearance. Display also
the images that undergo changing in bit depth.

D. Scalar Image Processing

1. Create a new blank VI for Scalar Arithmetic Image Processing using three case
structures inside a while loop. Outside the loop, put two IMAQ Create blocks (Right
click on the block diagram panel > Vision and Motion > Vision Utilities > Image
Management > IMAQ Create), IMAQ Dispose (Right click on the block diagram panel
> Vision and Motion > Vision Utilities > Image Management > IMAQ Dispose) and
IMAQ WindClose (Right click on the block diagram panel > Vision and Motion >
Vision Utilities > External Display > IMAQ WindClose) same as shown in Figure 2.13.
2. Name the IMAQ Create blocks Source Image and Dest Image, respectively, and
connect its New Image nodes and error out nodes on the loop.
3. Put a File Dialog (Right click on the block diagram panel > File I/O >Adv File Funcs>
File Dialog), IMAQ ReadFile (Right click on the block diagram panel > File I/O >Adv
File Funcs> File Dialog), IMAQ WindDraw (Right click on the block diagram panel >
Vision and Motion > Vision Utilities > External Display > IMAQ WindDraw) and IMAQ
WindMove(Right click on the block diagram panel > Vision and Motion > Vision
Utilities > External Display > IMAQ WindMove) inside the first case structure. Name
the prompt of the File Dialog and connect its selected path node to the File Path
node of the IMAQ ReadFile. Connect the Source Image node and its error out to the
IMAQ ReadFile. Connect its Image Out node to the IMAQ WindDraw and name and
number this window. Connect the error out of IMAQ WindDraw to the error in of

42 | P a g e
IMAQ WindMove and set the coordinate of the window to be shown at the screen,
identify the window to be coordinated.
4. Create a control for the first case structure and label it as Load Image Button.
5. On the second case structure, put another case structure inside it and create a
control for both of its case selector, label it as Process Button and Arithmetic
Operation, respectively. On the case structure inside the second case structure, put
an IMAQ Add block (Right click on the block diagram panel > Vision and Motion
>Image Processing>Operators> IMAQ Add) on the default case and connect its
Image Src A node to the Image Out node of the IMAQ ReadFile, and its Image Dst
node to the New Image node of the second IMAQ Create outside the loop. Create
also a control on its constant node, move it inside the while loop and reconnect it to
its original node. Connect the error out of the second IMAQ Create to the error ins
of IMAQ Dispose and IMAQ WindClose.
6. Inside the second case structure, put an IMAQ WindDraw, name and number the
block and connect its Image node to the Image Dst Out of IMAQ Add. Connect the
Image Out node of the IMAQ WindDraw to the Image node of an IMAQ WriteFile
(Right click on the block diagram panel > Vision and Motion > Vision Utilities > Files >
IMAQ WriteFile) located at the third case structure with a control labeled as Save
Button. Connect the File Path node of the IMAQ WriteFile to the selected path node
of another File Dialog and create a constant in its prompt node. Create a control for
the condition statement of the while loop structure.
7. On the false case of the first case structure, connect the source image node to the
Image Src A node of the IMAQ Add. On the false case of the second case structure,
connect the destination image node to the Image node of the IMAQ WriteFile.
8. Go to the front panel window and replace the controls created. First, the Load Image
Button, right-click, replace, Boolean and choose OK button, rename it as Load Image
and set its mechanical action to latch when released. Next, the process button of the
second case structure, replace it to an OK button, rename it as Process Image and
set also its mechanical action to latch when released. Then, the button for the case
structure inside the second case structure, right-click it, replace, list, table and tree
and choose listbox. On the listbox, edit its items and type Addition, Subtraction,
Multiplication and Division. Change the representation of the Scalar Constant
Control of the IMAQ Add to Byte. Finally, replace the save button control to an OK
button, rename it as SAVE PROCESSED IMAGE, and replace the stop control to a stop
button, change their mechanical action to latch when released. The front panel
window view is shown in Figure 2.14.

43 | P a g e
Figure 2.13 Scalar Arithmetic Process VI

Figure 2.14 Front Panel View of Scalar Arithmetic Process

9. Go back to the block diagram window and put an IMAQ Subtract(Right click on the
block diagram panel > Vision and Motion >Image Processing>Operators> IMAQ
Subtract) on the second case. Connect the nodes accordingly. Repeat this step by
creating another case after the previous case and put an IMAQ Multiply and the last
case is using IMAQ Divide(Right click on the block diagram panel > Vision and Motion
>Image Processing>Operators> IMAQ Multiply/ Divide).
10. Run the program and load an image and use Cancer Image 9 located at the Cancer
Cells Folder. Edit the scalar constant to 80 and process the image using addition and

44 | P a g e
subtraction operation. Edit the scalar constant to 4 and process the image using
multiplication and division operation. Save all of the processed images into a folder
named Scalar Arithmetic Processed Images.

V. OBSERVATIONS
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________

VI. DATA AND RESULTS


________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________

VII. TEST YOUR SKILLS

1. On the activity of Basic Image Processing, modify the program to image process also the
processed image.

2. Add also a Save Image tab, and modify the program in saving the previously processed
image.

VIII. QUESTIONS AND ANSWERS

1. Among the activities in this exercise, what is the most commonly used in the field of
biomedical engineering? Justify your answer.
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________

2. Why must the second case structure condition be false?


________________________________________________________________________
________________________________________________________________________

45 | P a g e
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________

IX. CONCLUSION
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________

46 | P a g e
Laboratory Exercise No. 3
IMAGE-ENHANCEMENT-POINT OPERATIONS

I.OBJECTIVES
1. To study about image negation, image threshold, image segmentation and image
histogram.
2. To familiarize the blocks in each specific topic for image analysis.
3. To study about the parameters needed to vary in order to manipulate the output image.
4. To determine the applications of image negation, threshold, segmentation and
histogram in biomedical engineering.

II. PREREQUISITE KNOWLEDGE


1. Knowledge on Basic Image Processing
2. Knowledge on Arithmetic Image Operations

III. THEORY
Image features such as edges boundaries
and contrast could be emphasized, the process of
accentuating these features is known as Image
Enhancement. It is done to develop and improve the
content and the images graphical form. One of the most
dominant techniques in image enhancement is called
Point Operation. This particular technique re-evaluates
the value of each pixel individually to a particular
alteration.

Point Operations are sometimes called contrast enhancement, contrast


stretching or grey-scale transformation for it constitutes to the change in the appearance of
the image and assimilated to the digitization of the image. Brightness and adjustments are the
usual techniques related to point operations. The images on the right side show some basic
point operation techniques. The first image is the original image while on its right is the image
sharpened by 50 percent. The bottom images show the change in contrast in the image. The
image on the left has a value of -40 % from the original brightness and contrast while the one
on the right has a contrast and brightness of 20% higher than the original picture.

47 | P a g e
A. Image Negation, Thresholding and Histogram

1. Image Negation - also often referred to as inversion is the application of a negative


gain factor to a particular digital image. It is usually performed by subtracting each
pixel from the maximum pixel value. Image negation is given by the formula:
g(x,y) = 255 f(x,y)

2. Image Thresholding - is a type of clipping wherein the image output is binary. Image
thresholding is conducted to locate specific points or objects in an image with
respect to a plane. Eight-bit images including those grey-levels and threshold are
pinned at 0 while grey levels above the threshold limit are pinned onto the 255
value

(a) (b)
Fig.3-1 The graphs above show the plot of (a) image thresholding and (b) image negation.

3. Image histogram- is a representation of the frequency of how many times grey


levels occur in an image. An 8- bit image will have a table of 256 entries, hence the
entries in a table is given by the formula:

Wherein: b is the number of bits

Another term for the number of entries in a table for an image histogram is bin. The
entries are indexed form 0 to 255, and this will record the frequency of each level in the image.
A histogram if an image is useful in determining the modification technique to be used for
brightness and contrast enhancement.

48 | P a g e
B. Blocks Used in Image Enhancement
a. IMAQ Histogram
This block provides a set of statistical measurements on its output related to the
grey levels distribution in the image.

b. IMAQ Inverse
It computes the negative of a greyscale image by replacing the brightness of the
pixels in the image with its complement in respect to white.

c. IMAQ Histogram
This function provides on the output the values of the linear histogram for any
grey level in a tabular form.

IV. PROCEDURES
1. Launch the LabVIEW application. (Desktop >LabVIEW 2013> Blank VI)
2. Construct a visual representation of Image Negation, Thresholding, Segmentation and
Image Histogram.

A. IMAGE NEGATION

1. First, create three (3) boolean OK button and name this blocks as load, process
and close. (Right click on the front panel > Boolean > OK button)
2. Second, create a while loop structure for the program. While loop makes the
program continuous even if the user changes the parameters inside the program.
After the while loop, create 3 case structures for your three (3) Boolean OK

49 | P a g e
buttons and put it all inside the while loop. (Right click on the block diagram panel >
Structures > While loop/ Case Structure)
3. Use the File Dialog (Right click on the block diagram panel > File I/O >Adv File Funcs>
File Dialog) and choose file or folder and new or existing, IMAQ Create (Right click
on the block diagram panel > Vision and Motion > Vision Utilities > Image
Management > IMAQ Create) and IMAQ Readfile (Right click on the block diagram
panel > Vision and Motion > Vision Utilities > File > IMAQ ReadFile) to establish the
program name, data type and the directory of the file. Provide two (2) IMAQ Create
for acquiring the input and output of the image. These two (2) IMAQ Create should
be put outside the while loop. Make sure to input an image name (name as input
image and output image) for the IMAQ Create to avoid errors in the program.
4. For the first case structure, connect the Load button to the case selector and then
put the file dialog and IMAQ ReadFile inside the case structure. IMAQ WindDraw
(Right click on the block diagram panel > Vision and Motion > Vision Utilities >
External Display > IMAQ WindDraw) can be used to show the original image in a
different panel. IMAQ WindMove (Right click on the block diagram panel > Vision
and Motion > Vision Utilities > External Display > IMAQ WindMove) can also be
added to manipulate the coordinates on the screen of this said panel. Try the
coordinates (500, 40) or (720, 40) to use the center of the screen. For the
connection, connect the selected path pin of the file dialog to the file path pin of the
IMAQ ReadFile. Then, connect the new image pin of one of the IMAQ Create (input
image) to the image pin of the IMAQ ReadFile. After that, image out pin of the IMAQ
ReadFile to the image pin of the IMAQ WindDraw. Make sure to create a constant
for the title (name it as Original Image) and window number for IMAQ
WindDrawto avoid errors. For the window number, the default is 0, if the user will
use another IMAQ WindDraw make sure to use different number.
5. For the next case structure, connect the Process button to the case selector. Inside
this case structure are the blocks that manipulate or change the image. These blocks
are the IMAQ Inverse (Right click on the block diagram panel > Vision and Motion >
Image Processing > Processing > IMAQ Inverse) and the IMAQ WindDraw (Right click
on the block diagram panel > Vision and Motion > Vision Utilities > External Display >
IMAQ WindDraw); for the IMAQ Inverse, connect the image out of the IMAQ
ReadFile block to the image pin of the IMAQ Inverse while for the IMAQ WindDraw,
connect the image out of the IMAQ Inverse to the image pin of IMAQ WindDraw to
show the processed image in different panel. Make sure that the window number of
the second IMAQ WindDraw is different from the first IMAQ WindDraw and also you
have to create a title for your IMAQ WindDraw (name it as Processed Image). If
the users notice some white box on the edge of the case structure try to connect the

50 | P a g e
new image pin of IMAQ Create (input image) to the image source pin of the IMAQ
Inverse for the false condition of the first case structure. The white block means that
the connection for the other condition is not yet connected.
6. For the last case structure, connect the Close button to the case selector. Inside
this case structure are the IMAQ WindClose (Right click on the block diagram panel
> Vision and Motion > Vision Utilities > External Display > IMAQ WindClose),
Unbundle by Name (Right click on the block diagram panel > Cluster, Class & Variant
> Unbundle by Name), Not button (Right click on the block diagram panel > Boolean
> Not), Stop button(Right click on the block diagram panel > Application Control >
Stop) and IMAQ Dispose (Right click on the block diagram panel > Vision and Motion
> Vision Utilities > Image Management > IMAQ Dispose). For the connection,
connect the error out pin of the IMAQ WindClose to the input cluster pin of the
unbundle by name. The unbundle by name status must be connected to the not
button. Then, the not button parallel with the all images pin of IMAQ Dispose and
Stop button. After that, parallel the not button and the continuous stop button
(Right click the loop condition button then check the continue if true status) from
the loop to the Close button so that the program will run continuously until the
close button has been clicked.
7. Try to familiarize the terminals on this block. All the functions and applications for
every terminal.
8. Lastly, press Load to choose image that you need and press Process if you want
to process that image and see the difference between the two.

Figure 3.2 Image Negation VI

51 | P a g e
B. IMAGE THRESHOLD

1. Repeat steps 1 - 4 from Image Negation.


2. For the next case structure, connect the Process button to the case selector. Inside
this case structure are the blocks that manipulate or change the image. These blocks
are the IMAQ Threshold (Right click on the block diagram panel > Vision and Motion
> Image Processing > Processing > IMAQ Threshold) and the IMAQ WindDraw (Right
click on the block diagram panel > Vision and Motion > Vision Utilities > External
Display > IMAQ WindDraw); for the IMAQ Threshold, connect the image out of the
IMAQ ReadFile block to the image pin of the IMAQ Threshold while for the IMAQ
WindDraw, connect the image out of the IMAQ Threshold to the image pin of IMAQ
WindDraw to show the processed image in different panel. Make sure that the
window number of the second IMAQ WindDraw is different from the first IMAQ
WindDraw and also you have to create a title for your IMAQ WindDraw (name it as
Processed Image). If the users notice some white box on the edge of the case
structure try to connect the new image pin of IMAQ Create (input image) to the
image source pin of the IMAQ Inverse for the false condition of the first case
structure. The white block means that the connection for the other condition is not
yet connected. And also create a constant for the range pin of the IMAQ Threshold
to avoid error.
3. Lastly, repeat steps 6 - 8 from Image Negation.

Figure 3.3 Image Threshold VI

52 | P a g e
C. IMAGE HISTOGRAM

1. Repeat steps 1-4 from Image Negation.


2. For the next case structure, connect the Process button to the case selector. Inside
this case structure are the blocks that manipulate or change the image. These block
is the IMAQ Histogram (Right click on the block diagram panel > Vision and Motion >
Image Processing > Analysis > IMAQ Histogram). For the IMAQ Histogram, connect
the image out of the IMAQ ReadFile block to the image pin of the IMAQ Histogram.
After that, create an indicator for the histogram graph to see the waveform of the
image. As you can see, the table that is shown can be used to determine the exact
components of the image histogram. If you want to change that to see a waveform,
just drag the whole table then right click, choose replace, go to the graph section
and pick waveform graph. If the users notice some white box on the edge of the
case structure try to connect the new image pin of IMAQ Create (input image) to the
image source pin of the IMAQ Inverse for the false condition of the first case
structure. The white block means that the connection for the other condition is not
yet connected.
3. Lastly, repeat steps 6 - 8 from Image Negation.

Figure 3.4 Image Histogram VI

53 | P a g e
V. OBSERVATION
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________

VI. DATA AND RESULTS


________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________

VII. TEST YOUR SKILLS


1. Create a program that presses the button to select, load and display an image. Set the
input grey level range that is to be mapped using the minimum and maximum values in
range (set minimum to 0 and maximum to 255 to map the entire range). Select the
mapping operator as linear, logarithmic, exponential, square, square-root, power X, or
power 1/X to define the mapping function. Note that it is required to set the X value if
power X or power 1/X mapping is desired. Put a process button and observe the
resultant images. Try various mapping functions for separate images and different
ranges and in each case observe the results.

2. Create a program that presses the button to select, load and display an image. Put a
negate button to display the negative image. For thresholding an image, put a
threshold range by setting the minimum and maximum values or using corresponding
sliders. It is possible to keep original pixel values within the range or replace pixel values
by 255 (white) using the slide switch. Try various thresholds for separate images and
observe results for keeping and replacing pixel values.

3. Create a program that presses the button to select, load and display an image. Put a
show histogram button to display the histogram of the image. Put a equalize
histogram button to observe the histogram equalized image, clicking the show
histogram button will now display the histogram of the histogram equalized result. Try

54 | P a g e
various mapping functions for separate images and observe their effect on the image
histogram.

VIII. QUESTIONS AND ANSWERS


1. In image thresholding, what is the difference between the original image if you change
the image type of the processed image into Complex (CSG) and HSL (U32)? Why?
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________

2. In image thresholding, the default Boolean for the thresholding block is true, what will
happen to the image if you change the logic into false? Justify your answer.
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
_____________________________________________________________________________

IX. CONCLUSION
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________

55 | P a g e
Laboratory Exercise No. 4
IMAGE ENHANCEMENT- SPATIAL OPERATION

I. OBJECTIVES
1. To understand the difference between the image enhancement - spatial and point
operations.
2. To familiarize the basic blocks needed in image enhancement spatial operations.
3. To determine the different methods used in spatial operations.
4. To understand the different parameters needed in each block.
5. To determine the applications of convolution, correlation, linear filtering, edge
detection and rank filtering.

II. PREREQUISITE KNOWLEDGE


1. Knowledge on basic image processing
2. Knowledge on arithmetic operations
3. Knowledge on basic image enhancement

III.THEORY
Spatial Image Processing commonly termed as Spatial Filtering is a process of changing
each pixel value given by I(x, y) by the function of intensities of a pixel in a neighborhood (x, y).
It is mainly used for noise reduction, extraction of image features and enhancement of the
image.

Figure4.1 Spatial Filtering

56 | P a g e
The term neighborhood refers to pixels encircling the specific pixel. There are two types
of pixel neighbors namely 4-neighborsand 8-neighbors. The difference between the two is on
the pixels considered as neighbors of the given pixel.

(a) (b)

Figure 4.2 (a) 4-neighbors (b) 8- neighbor

A. Convolution
In digital image processing, convolution refers to the general purpose filter effect for
images. It is a matrix input into an image and is composed of integers of mathematical
operations. It determines the value of a specific pixel or the central pixel by adding average
values to all of its neighbors. The result after convolution is a modified filtered image.

1. Kernel- is a matrix of numbers that is mainly for image


convolutions. There are differently sized kernels and each
kernel contains a different pattern of numbers, these
patterns produce different results in convolution. The most
common type of kernel used is a 3x3 matrix as shown on the
right.

B. Spatial Averaging and Spatial Filtering


Spatial averaging is used in the attenuation of noise in
images, this process results to the low pass filtering of digital
images. In this process, a pixel from a specific spatial position (x,
y) in the processed image has a brightness value of z(x, y)
tabulated as the average of the brightness value of the pixels in
the real image found in a spatial neighborhood of pixels around
(x, y). A coefficient of 0 for the convolution mask is needed to
achieve low pass filtering. A common convolution mask used

57 | P a g e
for low pass filtering is shown in the left side. High pass filtering of an image is achieved by
subtracting the low pass filtered image to the original image. The primary purpose of high pass
filtering through convolution is Edge Detection. An edge of an image is a specific point
wherein the brightness of the image varies significantly.

C. Blocks Used in Spatial Image Processing

1. MATRIX OPERATORS
a. IMAQ Convolute
IMAQ Convolute filters an image using linear filter. The calculations are
performed with either integers or floating points, depending on the image type
and the contents of the kernel.

b. IMAQ Buildkernel
The IMAQ BuildKernel block constructs a convolution matrix by converting a string. The
string can represent either integers or floating point values.

c. IMAQ NthOrder
As its name suggests, IMAQ NthOrder classifies the pixel values surrounding the pixel
being processed. This function is being used for median filtering.

d. IMAQ Lowpass
IMAQ Lowpass calculates the inter-pixel variation between the pixel being
processed and those pixels surrounding it.

58 | P a g e
e. IMAQ EdgeDetection
The IMAQ EdgeDetection block detects the edges in an image with grey levels.

IV. PROCEDURES

A. IMAGE CONVOLUTION

1. First, create three (3) Boolean OK button and name this blocks as load, process
and close. (Right click on the front panel > Boolean > OK button)
2. Second, create a while loop structure for the program. After the while loop, create 3
case structures for your three (3) Boolean OK buttons and put it all inside the
while loop.(Right click on the block diagram panel > Structures > While loop/ Case
Structure)
3. Use the File Dialog (Right click on the block diagram panel > File I/O >Adv File Funcs>
File Dialog) and choose file or folder and new or existing, IMAQ Create (Right click
on the block diagram panel > Vision and Motion > Vision Utilities > Image
Management > IMAQ Create) and IMAQ Readfile (Right click on the block diagram
panel > Vision and Motion > Vision Utilities > File > IMAQ ReadFile) to establish the
program name, data type and the directory of the file. Provide two (2) IMAQ Create
for acquiring the input and output of the image. These two (2) IMAQ Create should
be put outside the while loop. Make sure to input an image name (name as input
image and output image) for the IMAQ Create to avoid errors in the program.
4. For the first case structure, connect the Load button to the case selector and then
put the file dialog and IMAQ ReadFile inside the case structure. IMAQ WindDraw
(Right click on the block diagram panel > Vision and Motion > Vision Utilities >
External Display > IMAQ WindDraw)can be used to show the original image in a

59 | P a g e
different panel. IMAQ WindMove (Right click on the block diagram panel > Vision
and Motion > Vision Utilities > External Display > IMAQ WindMove) can also be
added to manipulate the coordinates on the screen of this said panel. Try the
coordinates (500, 40) or (720, 40) to use the center of the screen. For the
connection, connect the selected path pin of the file dialog to the file path pin of the
IMAQ ReadFile. Then, connect the new image pin of one of the IMAQ Create to the
image pin of the IMAQ ReadFile. After that, image out pin of the IMAQ ReadFile to
the image pin of the IMAQ WindDraw. Make sure to create a constant for the title
(name it as Original Image) and window number for IMAQ WindDraw to avoid
errors. For the window number, the default is 0, if the user will use another IMAQ
WindDraw make sure to use different number.
5. For the next case structure, connect the Process button to the case selector. Inside
this case structure are the blocks that manipulate or change the image. These blocks
are the IMAQ Convolute (Right click on the block diagram panel > Vision and Motion
> Image Processing > Filters > IMAQ Convolute), IMAQ BuildKernel (Right click on
the block diagram panel > Vision and Motion > Image Processing > Filters > IMAQ
BuildKernel) and the IMAQ WindDraw (Right click on the block diagram panel >
Vision and Motion > Vision Utilities > External Display > IMAQ WindDraw); for the
IMAQ Convolute, connect the image out of the IMAQ ReadFile to the image pin of
the IMAQ Convolute and then connect the IMAQ BuilKernel to the kernel pin of the
IMAQ Convolute, make sure to create a control for the kernel for fast variation in the
values. And for the IMAQ WindDraw, connect the image out of the IMAQ Convolute
to the image pin of IMAQ WindDraw to show the processed image in a different
panel. Make sure that the window number of the second IMAQ WindDraw is
different from the first IMAQ WindDraw and also you have to create a title for your
IMAQ WindDraw (name it as Processed Image). If the users notice some white box
on the edge of the case structure try to connect the new image pin of IMAQ Create
(input image) to the image source pin of the IMAQ Inverse for the false condition of
the first case structure. The white block means that the connection for the other
condition isnot yet connected.
6. For the last case structure, connect the Close button to the case selector. Inside
this case structure are the IMAQ WindClose (Right click on the block diagram panel
> Vision and Motion > Vision Utilities > External Display > IMAQ WindClose),
Unbundle by Name (Right click on the block diagram panel > Cluster, Class & Variant
> Unbundle by Name), Not button (Right click on the block diagram panel > Boolean
> Not), Stop button (Right click on the block diagram panel > Application Control >
Stop) and IMAQ Dispose (Right click on the block diagram panel > Vision and Motion
> Vision Utilities > Image Management > IMAQ Dispose). For the connection,

60 | P a g e
connect the error out pin of the IMAQ WindClose to the input cluster pin of the
unbundle by name. The unbundle by name status must be connected to the not
button. Then, the not button parallel with the all images pin of IMAQ Dispose and
Stop button. After that, parallel the not button and the continuous stop button
(Right click the loop condition button then check the continue if true status) from
the loop to the Close button so that the program will run continuously until the
close button has been clicked.
7. Try to familiarize the terminals on this block. All the functions and applications for
every terminal.
8. Lastly, press Load to choose image that you need and press Process if you want
to process that image and see the difference between the two.
9. Load different images and notice the effect of the spatial filtering on these images,
for different filtering windows sizes.

Figure 4.3 Image Convolution VI

B. IMAGE EDGE DETECTION

1. Repeat steps 1-4 from Image Convolution. But this time, add one (1) more for the
OK button (name it as Canny) and also one (1) for the case structure.
2. For the next case structure, connect the Process button to the case selector. Inside
this case structure are the blocks that manipulate or change the image. These blocks

61 | P a g e
are the IMAQ EdgeDetection (Right click on the block diagram panel > Vision and
Motion > Image Processing > Filters > IMAQ EdgeDetection) and the IMAQ
WindDraw(Right click on the block diagram panel > Vision and Motion > Vision
Utilities > External Display > IMAQ WindDraw); for the IMAQ EdgeDetection, connect
the image out of the IMAQ ReadFile to the image pin of the IMAQ EdgeDetection
and then create a control for the method pin for fast variation of ways that are
needed to use. And for the IMAQ WindDraw, connect the image out of the IMAQ
EdgeDetection to the image pin of IMAQ WindDraw to show the processed image in
a different panel. Make sure that the window number of the second IMAQ
WindDraw is different from the first IMAQ WindDraw and also you have to create a
title for your IMAQ WindDraw (name it as Processed Image). If the users notice
some white box on the edge of the case structure try to connect the new image pin
of IMAQ Create (input image) to the image source pin of the IMAQ Inverse for the
false condition of the first case structure. The white block means that the connection
for the other condition is not yet connected.
3. For the third case structure, connect the Canny button to the case selector. Inside
this case structure are the blocks that manipulate or change the image. These blocks
are the IMAQ CannyEdgeDetection (Right click on the block diagram panel > Vision
and Motion > Image Processing > Filters > IMAQ CannyEdgeDetection) and the IMAQ
WindDraw (Right click on the block diagram panel > Vision and Motion > Vision
Utilities > External Display > IMAQ WindDraw); for the IMAQ CannyEdgeDetection,
connect the image out of the IMAQ ReadFile to the image pin of the IMAQ
CannyEdgeDetection and then create a control for the filter parameters pin for fast
alteration of the components of an image. And for the IMAQ WindDraw, connect the
image out of the IMAQ CannyEdgeDetection to the image pin of IMAQ WindDraw to
show the canny edge detection image in a different panel. Make sure that the
window number of the third IMAQ WindDraw is different from the first two IMAQ
WindDraw and also you have to create a title for your IMAQ WindDraw (name it as
Canny Edge Detection Image).
4. Lastly, follow steps 6-9 from Spatial Filtering.

62 | P a g e
Figure 4.4 Image Edge Detection VI

C. MEDIAN FILTERING OF GREYSCALE IMAGES

1. First, follow steps 1-4 from the Image Convolution.


2. For the next case structure, connect the Process button to the case selector. Inside
this case structure are the blocks that manipulate or change the image. These blocks
are the IMAQ NthOrder (Right click on the block diagram panel > Vision and Motion
> Image Processing > Filters> IMAQ NthOrder)and the IMAQ WindDraw (Right click
on the block diagram panel > Vision and Motion > Vision Utilities > External Display >
IMAQ WindDraw); for the IMAQ NthOrder, connect the image out of the IMAQ
ReadFile to the image pin of the IMAQ NthOrder and make sure to create a control
for the size and order number pin for fast variation in the parameters of an image.
And for the IMAQ WindDraw, connect the image out of the IMAQ NthOrder to the
image pin of IMAQ WindDraw to show the processed image in a different panel.
Make sure that the window number of the second IMAQ WindDraw is different from

63 | P a g e
the first IMAQ WindDraw and also you have to create a title for your IMAQ
WindDraw (name it as Processed Image).
3. Lastly, follow steps 6-9 from the spatial filtering.

Figure 4.5 Median Filtering User Interface and VI

V. OBSERVATIONS
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________

VI. DATA AND RESULTS


________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________

64 | P a g e
VII. TEST YOUR SKILLS
1. Create a program that presses the load image 1 button to select, load and display an
image. Click the process button to display the result of the convolution with the
specified kernel. Have a copy of the original image, so that you can compare the
differences between the original and processed image. Try kernels with positive only
and both positive and negative coefficients for separate images and observe their effect.

2. Create a program that presses the load image button to select, load and display an
input image and the load template button to select, load and display an image
template. Hit the correlate button to display the correlation result in the form of a
correlation image as well as 3-D correlation surface. The point at which the maximum
correlation is obtained is displayed. Try the program with various images and templates,
trying to locate a part of the image or global image displacement.
3. Create a program that presses the load image button to select, load and display an
image. Select the desired kernel family (Smoothing, Gaussian, Gradient, Laplacian),
kernel size and kernel number. Hit the process button to display the result of linear
filtering with the specified kernel. The kernel coefficients will be displayed. Try various
kernels with different sizes and observe their effects. Notice that using the kernel
number you might select different kernels for the same family of the same size
performing various processes.

VIII. QUESTIONS AND ANSWERS


1. In the convolution process, what is the difference in the processed image between the
negative coefficients kernel, positive coefficients kernel and both positive and negative
coefficients kernel?
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________

2. In the edge detection process, what are the differences between each method?
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________

65 | P a g e
IX. CONCLUSION
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________

66 | P a g e
Laboratory Exercise no. 5
COLOR IMAGES

I. OBJECTIVES
1. To define color images and differentiate it with grey-level images.
2. To extract different color planes for various images and to relate bright and dark parts of
the color planes to color features in the images.
3. To explain profoundly the use of histograms and describe the characteristic of a color
image.
4. To observe the processes of color thresholding on both RGB and HSI domains.

II. PREREQUISITE KNOWLEDGE


1. Knowledge on basic image processing.

III.THEORY
A mathematical model abstract which unfolds the way hues or colors can be
represented as numbers commonly as three (3) or four (4) values is called as color model. A
color model, when associated to a description of the components will result into a color space.

Figure 5.1 Color Model

67 | P a g e
A. RGB Color Model
RGB color model, including CMY color model which is its subset is one of
the most popular color models, is a particular model which showcases the
closest similarity on how the human eyes see colors. It also resembles to the
principles of additive and subtractive color.

1. ADDITIVE COLOR -it is defined as the technique of combining solid spectral colors
which are optically mixed by positioning the colors closely to each other and is
presented in a very rapid succession. This way, the color is perceived by the human
eye as a single color.

2. SUBTRACTIVE COLOR- occurs when hues in a specific object absorb specific or


certain wavelengths of white light while the other colors are reflected.

Figure 5.2 Additive and Subtractive Color

B. HSI Color Model


The HSI color model is one of the most important models used in
image processing because it represents every specific color with three
components. These components are the hue (H), saturation (S) and
intensity (S). It is mainly used for high- quality enhancement of colors, it
only changes the intensity or saturation of a particular color but it does not
change its hue. This means that a specific color could appear lighter or
darker but it does not change its hue or base color.

In the figure shown on the right, the hue component is shown in a form of an angle
between 0 to 360 degrees. Each primary color has 120 degree spacing while the CMY colors
have a 60 degree separation. The saturation component is measured from 0 to 1. This
component defines how much white color or value is in the specific color. The intensity range is
same with the saturation range and it also limits the saturation value.

68 | P a g e
C. Color Thresholding
Threshold is defined as the magnitude that must be exceeded to achieve a particular
result. On the other hand, color thresholding is defined as the technique of converting a
grayscale image into a bi-level image. This process uses optimal threshold.

Thresholding is done to extract pixels, the information from the pixels is in binary form
and these represent the range of intensities.

1. Threshold Algorithms
a. QUADRATIC INTEGRAL RATIO (QIR) ALGORITHM
It is a global two stage thresholding technique which uses the intensities in a
histogram to find the point of threshold.

b. OTSU ALGORITHM
It is a global thresholding technique which saves the intensities of an images pixels in an
array. It is calculated by finding the mean and variance of the given values of intensities. In this
type of algorithm, there is only one change in the image that will occur.

D. Blocks Used for Color Images


a. IMAQ ExtractColorPlanes
IMAQ ExtractColorPlanes is used to extract the three planes (RGB, HSL, HSV or HSI)
from an image.

b. IMAQ ColorHistograph
IMAQ ColorHistograph calculates the histograms extracted from the three planes of
an image. This VI can function in one of four modes corresponding to the color models RGB,
HSL, HSV or HSI. The output from this VI is directly compatible with a LabVIEW graph.

69 | P a g e
c. IMAQ ColorEqualize
The IMAQ ColorEqualize block equalizes a color image. This VI either uses the luminance
plane or all three planes.

d. IMAQ ColorThreshold
This applies a threshold to the three planes of an RGB or HSL image and places the result
into an 8-bit image.

e. IMAQ ReplaceColorPlane
IMAQ ReplaceColorPlane changes one or more image planes from a color image (RGB,
HSV, HSL or HSI). Only the planes connected at the input are replaced.

70 | P a g e
IV. PROCEDURES

A. Color Plane Extraction

1. Construct the given LabVIEW VI in Figure 5-1 in order to perform color plane
extraction using File Dialog (Right click on the block diagram panel > File I/O >Adv
File Funcs> File Dialog), five IMAQ Create (Right click on the block diagram panel >
Vision and Motion > Vision Utilities > Image Management > IMAQ Create), IMAQ
CastImage (Right click on the block diagram panel > Vision and Motion > Vision
Utilities >Image Management > IMAQ CastImage), IMAQ ReadFile (Right click on the
block diagram panel > Vision and Motion > Vision Utilities > File > IMAQ ReadFile),
and IMAQ ExtractColorPlane (Right click on the block diagram panel > Vision and
Motion > Vision Utilities > Color Utilities> IMAQ ExtractColorPlane).
2. Name the File Dialogs prompt and connect its selected path node to the file path
node of the IMAQ ReadFile. Name the first IMAQ Create as Original and create a
constant for its Image Type node and select RGB (U32). Connect its New Image node
and error out to the corresponding nodes of IMAQ ReadFile.
3. From the Image Out node of the IMAQ ReadFile, create an indicator labeled as
Original Image. Connect also the Image Out node to the Image Src node of the IMAQ
Cast Image.
4. Use a new IMAQ Create named Greyscale and connect its error in to the error out of
the IMAQ ReadFile. Connect its New Image node to the Image Dst node of the IMAQ
Cast Image and its error out to the same blocks error in. Create a constant for the
Image Type node and select Greyscale (U16) and an indicator for the Image Dst Out
node of the IMAQ Cast Image and label it as Greyscale Image.
5. Using the three remaining IMAQ Create blocks, name it as Red, Green and Blue,
respectively. From the IMAQ ReadFiles error out, interconnect it to the IMAQ
Create blocks error ins and outs. Connect the Red IMAQ Create to the Red or Hue
plane node of IMAQ ExtractColorPlane, the Green IMAQ Create to the Green or Sat
plane node of the same block, and the Blue IMAQ Create to the Blue or Luma or Val
or Intensity plane node of the same block. Connect the error out of the Blue IMAQ
Create to the error in of IMAQ ExtractColorPlane.
6. Connect the Image Src node of IMAQ ExtractColorPlane to the IMAQ ReadFiles
Image node. Create an indicator for the three output nodes of the IMAQ
ExtractColorPlane and label it accordingly as shown in the figure below.
7. Go to the front panel window and replace all the image indicator as an image
display, the same as shown in Figure 5-2.
8. Run the program and use Cancer Image 4 and snip and observe the resulting images
from this exercise.

71 | P a g e
(a)

(b)

Figure 5.4 (a) Color Plane Extraction VI (b) Front Panel View

B. Color Histogram

1. Construct the LabVIEW VI given in Figure 5-3 in order to perform color histogram
using three case structures inside a while loop (Right click on the block diagram
panel > Structures > While loop), with two IMAQ Create blocks (Right click on the
block diagram panel > Vision and Motion > Vision Utilities > Image Management >
IMAQ Create), IMAQ Dispose (Right click on the block diagram panel > Vision and

72 | P a g e
Motion > Vision Utilities > Image Management > IMAQ Dispose), and IMAQ
WindClose (Right click on the block diagram panel > Vision and Motion > Vision
Utilities > External Display > IMAQ WindClose) outside the loop.
2. Name both of the IMAQ Create blocks as Source Image and Destination Image,
respectively, and set their Image Type node to RGB (U32). Connect the New Image
node of both blocks and the error out of the Source Image block to the while loop.
3. Inside the first case structure with a case selector control labeled as Load Button,
connect the File Dialogs (Right click on the block diagram panel > File I/O >Adv File
Funcs> File Dialog)selected path to the File Path of IMAQ ReadFile (Right click on the
block diagram panel > Vision and Motion > Vision Utilities > File > IMAQ ReadFile)
and name its prompt as Select an Image File. Connect the New Image node and
error out of the IMAQ Create to the Image node and error in of the IMAQ ReadFile,
respectively. Connect the Image Out node of the IMAQ ReadFile to a named and
number IMAQ WindDraw (Right click on the block diagram panel > Vision and
Motion > Vision Utilities > External Display > IMAQ WindDraw) that is also connected
to an IMAQ WindMove (Right click on the block diagram panel > Vision and Motion
> Vision Utilities > External Display > IMAQ WindMove) with a set coordinates for the
window to display. Connect also the IMAQ Create blocks error out to the IMAQ
Dispose and IMAQ WindClose.
4. Put an IMAQ Copy (Right click on the block diagram panel > Vision and Motion >
Vision Utilities >Image Management> IMAQ Copy) inside the first case structure,
connect its Image Src node to the Source Image node of the first IMAQ Create and
its Image Dst to the Destination Image node of the second IMAQ Create.
5. On the second case structure, put an IMAQ ColorHistograph (Right click on the block
diagram panel > Vision and Motion >Image Processing> Color Processing > IMAQ
ColorHistograph) and connect its Image Src node to the Image Dst Out node of the
IMAQ Copy located inside the first case structure. Create a control for the Color
Mode node of the Color Histograph block, and indicators for the three output nodes
of the same blocks. Label it accordingly as shown in the figure below. Create a
control for the case selector and label it as Show Histogram.

73 | P a g e
Figure 5.5 Color Histogram VI

6. On the third case structure, put an IMAQ ColorEqualize (Right click on the block
diagram panel > Vision and Motion >Image Processing > Color Processing > IMAQ
ColorEqualize) and an IMAQ WindDraw. Connect the IMAQ ColorEqualizes Image
Src node to the IMAQ ReadFiles Image Out node located in the first case structure
and the Image Dst node to the second IMAQ Creates New Image node. Connect the
Image Dst Out node of the IMAQ ColorEqualize block to a named and numbered
IMAQ WindDraw. Create a control for the Luma / RGB,HSL (Luma) node and for the
case selector and label it as Equalize. Create also a control for the loop condition,
and change its condition to Continue if True.
7. Go to the False case of the first case structure and connect the Source Image node
to the Image Src node of the IMAQ ColorEqualize and connect the Dest Image node
to the Image Src node of the IMAQ ColorHistograph.
8. Go to front panel window, replace the Load Button, Show Histogram, and Equalize
to an OK button and rename it as Load Image, Show Histograms, and Equalize,
respectively. Replace also the Stop to a stop button labeled as Stop Program.
Change its mechanical action to latch when released. Replace also the Histogram
indicators by right-click, replace, graph and choose Waveform Graph. Once it was
replaced, change the amplitude up to 3000 and the value up to 300. The front panel
view is shown in Figure 5.6.
9. Run the program. Load Cancer Image 3 and show the histograms for each color type.
Then, equalize the histogram obtained in the luminance plane. Show again the
74 | P a g e
histograms for all the color types. Observe the resulting histograms and differentiate
it from the original histogram of the unequalized image. Next, equalize the
histogram of the original image in the three color planes by clicking the slide switch.
Show again the histograms for all the color types and observe and differentiate it
from the original histogram, and the histogram of the equalized image in the
luminance plane.

Figure 5.6 Color Histogram VI Front Panel View

C. Color Thresholding

1. Load the LabVIEW program entitled Color Threshold Example.vi from the IMAQ
vision example folders by clicking Help>Find Examples>Search Color
Threshold>Select Color Threshold.vi
2. Follow the steps given on the VI, and observe and explain the difference in
thresholding between RGB and HSL. Take note also of the levels of RGB in both
planes so that in the threshold image, there is a same shade of the original image.

V. OBSERVATIONS
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________

75 | P a g e
VI. DATA AND RESULTS
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________

VII. TEST YOUR SKILLS


1. Create a LabVIEW VI that extracts the red, green, and blue hue planes from a 32 bit RGB
image. Once extracted, these hue planes are multiplied by user controlled value and
recombined to create a new 32 bit RGB image. These are the steps to be considered:
a. Import an image file.
b. Initialize U8 Grayscale images for original images.
c. Initialize images for multiplied hues.
d. Extract hue planes.
e. Bundle the planes and unbundle it again by name.
f. Use an IMAQ Operation
g. A tab control for the hue planes.
h. Replace original hue planes with new.

VIII. QUESTIONS AND ANSWERS


1. What is the advantage of color images to grey-level images?
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________

2. What are the three factors that the perceived color depends on? Define each factor
briefly.
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________

76 | P a g e
3. Explain why color thresholding in HSI domain is quite simpler and more advantageous
than in RGB domain.
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________

IX. CONCLUSION
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________

77 | P a g e
Laboratory Exercise No. 6
IMAGE PROCESSING IN THE FREQUENCY DOMAIN

I.OBJECTIVES
1. To define Fourier Transform and Frequency Domain Filtering.
2. To differentiate high pass and low pass filters.

II. PREREQUISITE KNOWLEDGE


1. Knowledge on basic image processing
2. Knowledge on spatial image processing

III.THEORY
In image processing, Fourier Transform is defined as an image
processing tool used in breaking down images into its sinusoidal
components specifically its sine and cosine components. The input
image is in spatial domain while the output image is in the frequency
domain or Fourier Domain. Each point of a specific image in the Fourier
domain represents a specific frequency contained in the spatial domain
image. Some of the most common applications of Fourier Transform
are image analysis, image filtering, image reconstruction and image
compression.

A. Discrete Fourier Transform


If digital images are used, Discrete Fourier Transform is used in image processing. DFT is
the sampled Fourier transform; hence it does not have all the frequencies that make up the
image. It only has samples wherein these samples are large enough to represent the image in
the spatial image domain. If the images in the spatial domain and in the frequency domain are
of the same size, the two- dimensional DFT is given by:

78 | P a g e
B. Filtering in the Frequency Domain
In image processing, high pass frequency component of an image denotes the edges
while the low pass frequency components denotes the smooth region encapsulated in the
image.

1. HIGH PASS FILTER


High pass filters sharpens or focuses in showing off the edges of an image. It
only touches the low frequencies of an image, hence it attenuates the low frequencies
and leave the high frequencies untouched. The relationship between the high-pass and
low pass filter is given by :

2. LOW PASS FILTER

In digital image processing, low pass filters are used to smoothen or blur an
image. It attenuates the high frequencies and leaves the low frequencies unchanged.
There are three common types of low pass filters and these are: Ideal Low Pass,
Butterworth ad Gaussian Low Pass Filter.

C. Blocks Used for Filtering Images in the Frequency Domain


1. IMAQ GetPalette
The IMAQ GetPalette block is used to select a display palette.

2. IMAQ FFT

IMAQ FFT is used to compute the FFT of an image.

79 | P a g e
3. IMAQ InverseFFT
IMAQ InverseFFT computes the inverse FFT of a complex image.

4. IMAQ ComplexTruncate
This truncates the frequencies of a complex image.

IV. PROCEDURES

A. Fourier Transform Implementation for Greyscale Images

1. Construct the given LabVIEW VI in Figure 6.1 to implement Fourier transform on a


greyscale image. A while loop with four case structure (Right click on the block
diagram panel > Structures > While loop/ Case Structure), and three IMAQ Create
(Right click on the block diagram panel > Vision and Motion > Vision Utilities > Image
Management > IMAQ Create) blocks are needed to start the program.
2. Name the IMAQ Create blocks Image 1, 2 and 3, respectively. The first block has a
Grayscale 8-bit image type, the second has a Complex (CSG) image type and the last
block has also a Grayscale 8-bit image type. Connect all of their New Image node to
the while loop, right-click the connection of the second IMAQ Create block and the
while loop and click Replace with Shift Register.
3. On the first case structure with a control labeled as Load Image, put a File Dialog
(Right click on the block diagram panel > File I/O >Adv File Funcs> File Dialog), IMAQ
ReadFile (Right click on the block diagram panel > Vision and Motion > Vision
Utilities > File > IMAQ ReadFile) and an IMAQ WindDraw (Right click on the block
diagram panel > Vision and Motion > Vision Utilities > External Display > IMAQ
WindDraw). Connect the selected path node of the File Dialog with a prompt name
Select an Image File to the File Path node of the IMAQ ReadFile where its Image
node is connect to the New Image node of the first IMAQ Create block. Connect the

80 | P a g e
Image Out node of the IMAQ ReadFile to the named and numbered IMAQ
WindDraw.
4. On the second case structure with a control labeled as FFT, put an IMAQ FFT (Right
click on the block diagram panel > Vision and Motion >Image Processing>Frequency
Domain> IMAQ FFT), IMAQ GetPalette (Right click on the block diagram panel >
Vision and Motion > Vision Utilities > External Display > IMAQ GetPalette) and an
IMAQ WindDraw. Connect the Image Out node of the IMAQ ReadFile located in the
first case structure to the Image Src node of the IMAQ FFT, then the Image Dst node
of the same block to the second IMAQ Create block. Connect the Image Dst Out
node of the IMAQ FFT to the named and numbered IMAQ WindDraw, connect an
IMAQ GetPalette block to the Color Palette node of the IMAQ WindDraw. Create a
control for the Palette number node of the IMAQ GetPalette.
5. On the third case structure with a control labeled as IFFT, put an IMAQ InverseFFT
(Right click on the block diagram panel > Vision and Motion >Image
Processing>Frequency Domain> IMAQ FFT) and an IMAQ WindDraw. Connect the
Image Dst Out of the IMAQ FFT block located on the second case structure to the
Image Src node of the IMAQ InverseFFT and its Image Dst node to the third IMAQ
Create block. Connect its output to a named and numbered IMAQ WindDraw
6. On the fourth case structure with a control labeled as Close, put an IMAQ
WindClose (Right click on the block diagram panel > Vision and Motion > Vision
Utilities > External Display > IMAQ WindClose), IMAQ Dispose (Right click on the
block diagram panel > Vision and Motion > Vision Utilities > Image Management >
IMAQ Dispose), Unbundle block (Right click on the block diagram panel > Cluster,
Class & Variant > Unbundle), not (Right click on the block diagram panel > Boolean >
Not) and stop (Right click on the block diagram panel > Application Control > Stop).
Create a constant for the IMAQ WindCloses Close all windows node and set it to
True. Connect that block to the Unbundle block. Connect the first element of the
unbundle block to the not block then to stop block and to the All Images node of
IMAQ Dispose. Connect also another not block and the loop condition to the case
selector control of the same case structure.

81 | P a g e
Figure 6.1 Fourier transform on greyscale images VI

7. Go to the false case of the first case structure, connect the first IMAQ Create block
to the Image Src node of the IMAQ FFT. Go to the false case of the second case
structure and connect the second IMAQ Create block to the Image Src node of IMAQ
InverseFFT. Go to the false case of the third case structure and connect node from
the second IMAQ Create to the shift register at the while loop.
8. Go to the front panel window and replace all the buttons to an OK button and
rename it according to its label on the block diagram window.
9. Run the program. Load X-RAY Image 6 and get the FFT using different Palette
Number. Prove that when the IFFT button was pressed it will return to its original
image. Save all the acquired images to a folder named FFT Images.

82 | P a g e
Figure 6.2 User interface located at front panel

B. Frequecy Domain Representation

1. Construct the given LabVIEW VI in Figure 6-3 to perform image processing in


frequency domain using a while loop with three case structures along with three
IMAQ Create blocks (Right click on the block diagram panel > Vision and Motion >
Vision Utilities > Image Management > IMAQ Create), IMAQ WindClose (Right click
on the block diagram panel > Vision and Motion > Vision Utilities > External Display >
IMAQ WindClose) and IMAQ Dispose (Right click on the block diagram panel > Vision
and Motion > Vision Utilities > Image Management > IMAQ Dispose).
2. Name the IMAQ Create blocks Source Image, Complex, and Plane, respectively. The
first and third IMAQ Create blocks Image Type is Grayscale (U8) while the second
IMAQ Create blocks Image Type is Complex (CSG). Connect the New Image nodes of
the three blocks to the while loop and also the error outs of the first two IMAQ
Create blocks. Connect the error out of the second block to the IMAQ WindClose
and IMAQ Dispose with a constant both set to True.
3. On the first case structure with a case selector control labeled as Load Button,
connect the File Dialogs (Right click on the block diagram panel > File I/O >Adv File
Funcs> File Dialog) selected path to the File Path of IMAQ ReadFile and name its
prompt as Select an Image File. Connect the New Image node and error out of the
IMAQ Create to the Image node and error in of the IMAQ ReadFile (Right click on

83 | P a g e
the block diagram panel > Vision and Motion > Vision Utilities > File > IMAQ
ReadFile), respectively. Connect the Image Out node of the IMAQ ReadFile to a
named and number IMAQ WindDraw (Right click on the block diagram panel >
Vision and Motion > Vision Utilities > External Display > IMAQ WindDraw) that is also
connected to an IMAQ WindMove (Right click on the block diagram panel > Vision
and Motion > Vision Utilities > External Display > IMAQ WindMove) with a set
coordinates for the window to display.
4. On the second case structure with a case selector control labeled as Process,
connect the Image Out node of the IMAQ ReadFile located in the first case structure
to the Image Src node of IMAQ FFT (Right click on the block diagram panel > Vision
and Motion >Image Processing>Frequency Domain> IMAQ FFT) and its Image Dst
node to the New Image node of the second IMAQ Create. Connect IMAQ FFTs
Image Dst Out node and error out node to an IMAQ ComplexFlipFrequency (Right
click on the block diagram panel > Vision and Motion >Image Processing>Frequency
Domain> IMAQ ComplexFlipFrequency), and then connect the latter to an IMAQ
ComplexImageToArray (Right click on the block diagram panel > Vision and Motion
>Image Processing>Frequency Domain>IMAQ ComplexImageToArray).
5. Use an add block where its y node has a constant of 1 and its x node is connected to
the Image Pixels node of the IMAQ ComplexImageToArray. The sum is connected to
a Logarithm Base 10 block and connected to a complex to polar block (Right click on
the block diagram panel >Numeric>Complex > Complex to Polar). Connect the r node
to an Array Max & Min block (Right click on the block diagram panel >Array>Array
Max & Min). The max value node is connected to the y node of a divide block (Right
click on the block diagram panel >Numeric>Divide) where its x node is connected
between the Logarithm and Complex to Polar block.
6. Use a multiply block (Right click on the block diagram panel >Numeric>multiply)
where its y node has a constant of 255 and its x node is connected to the quotient of
the previous operation. Its product is connected to the Image Pixels node of an
IMAQ ArrayToComplexImage block (Right click on the block diagram panel > Vision
and Motion >Image Processing>Frequency Domain>IMAQ ArrayToComplexImage)
where its Image node is connected also to the second IMAQ Create block. Its Image
Out node is connected to the Image node of an IMAQ ComplexPlaneToArray (Right
click on the block diagram panel > Vision and Motion >Image Processing>Frequency
Domain>IMAQ ComplexPlaneToArray) where its output, Image Pixels is converted to
byte integer and then connected to the Image Pixels (U8) node of an IMAQ
ArrayToImage block (Right click on the block diagram panel > Vision and Motion
>Vision Utilities>Pixel Manipulation>IMAQ ArrayToImage) where its Image node is
connected to the third IMAQ Create block and its Image Out node is connect to a
named and numbered IMAQ WindDraw.

84 | P a g e
Figure6.3 Frequency Domain Representation VI

7. On the third case structure with a case selector control labeled as Save Image, put
an IMAQ WriteFile (Right click on the block diagram panel > Vision and Motion >
Vision Utilities > Files > IMAQ WriteFile) where its Image node is connected to the
Image Out node of the IMAQ WindDraw located in the second case structure. Its File
Path node is connected to the selected path node of a File Dialog with a prompt
name of Save Image As. Create a control labeled as Stop for the loop condition
located inside the while loop.
8. Go to the false condition of the first case structure, connect the IMAQ Create to the
Image Src node of the IMAQ FFT and on the false case of the second case structure,
connect the third IMAQ Create to the Image node of the IMAQ WriteFile.
9. Go to front panel window and replace all the buttons to an OK button and a STOP
button and rename it using their labels in the block diagram window. Change their
mechanical action to latch when released. The front panel view is shown in Figure 6-
4.
10. Run the program. Load X-RAY Image 8 and Cancer Image 3. Process it on different
planes and save all the resulting images to a folder named Frequency Domain
Images.

85 | P a g e
Figure6.4 Frequency Domain Representation VI Front Panel View

C. Frequecy Domain Filtering for greyscale Images

1. Construct the given LabVIEW VI in Figure 6.5 to filter a greyscale image in frequency
domain using three case structures inside a while loop (Right click on the block
diagram panel > Structures > While loop/ Case Structure) and four IMAQ Create
blocks(Right click on the block diagram panel > Vision and Motion > Vision Utilities >
Image Management > IMAQ Create) outside it.
2. Name all IMAQ Create blocks Image 1, 2, 3, and 4, respectively, where the first and
fourth blocks has an Image Type of Grayscale (U8) while the second and third blocks
has an Image Type of Complex (CSG). Connect their New Image nodes to the while
loop and replace all the connections to a shift register.
3. On the first case structure with a control labeled as Close, put an IMAQ WindClose
(Right click on the block diagram panel > Vision and Motion > Vision Utilities >
External Display > IMAQ WindClose), IMAQ Dispose (Right click on the block diagram
panel > Vision and Motion > Vision Utilities > Image Management > IMAQ Dispose),
Unbundle block(Right click on the block diagram panel > Cluster, Class & Variant >
Unbundle), not (Right click on the block diagram panel > Boolean > Not) and
stop(Right click on the block diagram panel > Application Control > Stop). Create a
constant for the IMAQ WindCloses Close all windows node and set it to True.
Connect that block to the Unbundle block. Connect the first element of the
unbundle block to the not block then to stop block and to the All Images node of
IMAQ Dispose. Connect also another not block and the loop condition to the case
selector control of the same case structure.
4. On the second case structure with a control labeled as Load Image, put a File Dialog
(Right click on the block diagram panel > File I/O >Adv File Funcs> File Dialog), IMAQ

86 | P a g e
ReadFile (Right click on the block diagram panel > Vision and Motion > Vision
Utilities > File > IMAQ ReadFile) and an IMAQ WindDraw (Right click on the block
diagram panel > Vision and Motion > Vision Utilities > External Display > IMAQ
WindDraw). Connect the selected path node of the File Dialog with a prompt name
Select an Image File to the File Path node of the IMAQ ReadFile where its Image
node is connect to the New Image node of the first IMAQ Create block. Connect the
Image Out node of the IMAQ ReadFile to the named and numbered IMAQ
WindDraw.
5. On the third case structure with a control labeled as FFT, put an IMAQ FFT (Right
click on the block diagram panel > Vision and Motion >Image Processing>Frequency
Domain> IMAQ FFT), IMAQ InverseFFT (Right click on the block diagram panel >
Vision and Motion >Image Processing>Frequency Domain> IMAQ InverseFFT), IMAQ
GetPalette (Right click on the block diagram panel > Vision and Motion > Vision
Utilities > External Display >IMAQGetPalette), IMAQ ComplexTruncate (Right click
on the block diagram panel > Vision and Motion >Image Processing>Frequency
Domain> IMAQ ComplexTruncate) and three IMAQ WindDraw blocks. Connect the
Image Out node of the IMAQ ReadFile at the first case structure to the Image Src
node of the IMAQ FFT and its Image Dst node to the second IMAQ Create where its
output is connected to the IMAQ ComplexTruncates Image Src node. Its Image Dst
node is connected to the third IMAQ Create block. Its Image Dst Out node is
connected to the Image Src node of the IMAQ InverseFFT and its Image Dst node is
connected to the fourth IMAQ Create. Connect also the IMAQ ReadFiles output to
the first shift register without touching the third case structure.
6. From the output of the IMAQ FFT, IMAQ ComplexTruncate and IMAQ InverseFFT,
connect a named and numbered IMAQ WindDraw for each block. Connect an IMAQ
GetPalette to the Color Palette node of the IMAQ WindDraw blocks at the output of
IMAQ FFT and IMAQ ComplexTruncate. Create a control for the Palette number, and
connect all the Image Out nodes of the IMAQ WindDraw blocks to the shift registers
located at the while loop. Create a control for the Truncation Frequency and Low
Pass/High Pass node of the IMAQ ComplexTruncate.
7. Go to the false case of the third case structure, connect all the corresponding second
to fourth IMAQ Create blocks to the shift registers located in the while loop.
8. Go to the front panel window and replace all the buttons to an OK button and
rename it according to their label on the block diagram window. The front panel
view is show in Figure 6.6.
9. Run the program. Load X-RAY Image 6 and filter it using low pass filter and with the
different palette number and a truncation frequency of 20%. Repeat this step again
using high pass filter. Save all the images into a folder named Frequency Filtering of
Grayscale Images.

87 | P a g e
Figure 6.5 Frequency Domain Filtering of greyscale images

Figure 6.6 Frequency Domain Filtering of greyscale images Front Panel View

V. OBSERVATIONS
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________

88 | P a g e
VI. DATA AND RESULTS
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________

VII. TEST YOUR SKILLS


1. Implement a diagram that will perform the Fourier transform of a RGB color image.

2. Using Figure 6.1, modify the first block diagram to obtain a 3D representation of the
Fourier spectrum, before and after filtering.

VIII. QUESTIONS AND ANSWERS


1. What is the essence of Fourier Transform in digital image processing?
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________

2. What type of Fourier Transform is used in digital image processing? Explain.


________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________

3. Explain briefly the process of frequency domain filtering in digital images.


________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________

89 | P a g e
IX. CONCLUSION
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________

90 | P a g e
Laboratory Exercise No. 7
REGION OF INTEREST AND LOOK-UP TRANSFORMATION

I. OBJECTIVES
1. To learn the different ways in determining the region of interest.
2. To familiarize the different VIs in the region of interest and lookup transformations.
3. To determine the different uses of the specific functions of histogram for lookup
transformations.
4. To analyze the parameters needed in the region of interest and lookup transformations.
5. To know applications suitable for this topics.

II. PREREQUISITE KNOWLEDGE


1. Knowledge gained from Lab 1 - Lab 4

III. THEORY
Region of Interest (ROI) is defined as the specific part
of an image which captures the viewers vision in general. It
ROI is also defined as the subject or focus of an analysis. By
defining the regions of interest, gray-scale and color
statistics could be measured. Region of Interest could also be
Color Statistics Gray-scale Statistics
Measurement Measurement
defined as the specific part of an image selected wherein the
individual or average pixel values can be numerically
displayed. Gray-scale statistics is measured using light
meters and quantitative analysis functions. Color statistics on the other hand is the
measurement and analysis of the individual color components of an image.

A. ELEMENTS OF ROI DESCRIPTOR


1. GLOBAL RECTANGLE

A global rectangle is made up of four integers that define the boundaries that have all
the shapes in the ROI descriptor.

2. CONTOURS

Contours are all individual shapes that define the ROI as follows:

91 | P a g e
a. ID It defines whether the contour is an internal or external edge of an ROI. If a
specific contour is defined as external, all its external area is considered as part of
the ROI. Internal contours on the other hand, override the external contours
because external contours are calculated first; hence regions considered part of the
internal contour are excluded.

b. TYPE It is the shape and size of the contour.

c. COORDINATES- It is defined as any array which contains the specific location of that
defines the contour.

B. Look-Up Transformations
Lookup Transformations refer to basic image processing processes used to enhance the
brightness and contrast of an image by improving the intensity dynamic of regions with low or
poor contrast. LUT is also used in highlighting details which contains important information
compared to other areas. Histogram equalization and inversion, Gamma, Logarithmic and
exponential corrections and also Inverse Gamma corrections are considered LUT.

SPECIFIC FUNCTIONS:

1. Equalizer

This function changes the gray-level value of pixels to evenly distribute the
values in the defined gray scale range. The equalizer is used to increment the contrast of
images.

2. Reverse

The photometric negative of a particular image is the result of the reverse


function. The histogram of a reversed image is equivalent to the histogram of the
original image after vertical symmetry. If an 8-bit image is used the center will be on the
gray-level value of 128.

92 | P a g e
3. Logarithmic and Inverse Gamma Correction

These functions expand the low gray-level ranges and compress the high gray-
level ranges. In images which only use the Gray palette, it increases the brightness of
the image and also increases its contrast in the dark.

4. Exponential and Gamma Correction

Exponential and Gamma Corrections extends high gray-level ranges and


compresses low gray-level ranges. In simpler terms, these functions are the inverse of
Logarithmic and Inverse Gamma Correction functions. It decreases the overall
brightness of images which uses the gray palette.

C. Blocks Used in ROI and Look-Up Transformations


1. IMAQ ConstructROI
IMAQ Construct ROI is used to display an image and the tools palette in
an ROI constructor window.

2. IMAQ ROIToMask

The IMAQ ROIToMask block is used to convert the ROI descriptor into an
image mask.

3. IMAQ Equalizer
The IMAQ Equalizer block is used to distribute the grayscale values evenly
within a given grayscale range. It also increases the contrast in images
containing few grayscale values.

IV. PROCEDURES

A. REGION OF INTEREST

1. First, create three (3) boolean OK button and name this blocks as load, process
and close. (Right click on the front panel > Boolean > OK button)
2. Second, create a while loop structure for the program. While loop makes the program
continuous even if the user changes the parameters inside the program. After the while
loop, create 3 case structures for your three (3) Boolean OK buttons and put it all

93 | P a g e
inside the while loop. (Right click on the block diagram panel > Structures > While loop/
Case Structure)
3. Use the File Dialog (Right click on the block diagram panel > File I/O >Adv File Funcs> File
Dialog) and choose file or folder and new or existing, IMAQ Create (Right click on the
block diagram panel > Vision and Motion > Vision Utilities > Image Management > IMAQ
Create) and IMAQ Readfile (Right click on the block diagram panel > Vision and Motion
> Vision Utilities > File > IMAQ ReadFile)to establish the program name, data type and
the directory of the file. Provide two (2) IMAQ Create for acquiring the input and output
of the image. These two (2) IMAQ Create should be put outside the while loop. Make
sure to input an image name (name as input image and output image) for the IMAQ
Create to avoid errors in the program.
4. For the first case structure, connect the Load button to the case selector and then put
the file dialog and IMAQ ReadFile inside the case structure. IMAQ WindDraw (Right
click on the block diagram panel > Vision and Motion > Vision Utilities > External Display
> IMAQ WindDraw) can be used to show the original image in a different panel. IMAQ
WindMove (Right click on the block diagram panel > Vision and Motion > Vision Utilities
> External Display > IMAQ WindMove) can also be added to manipulate the coordinates
on the screen of this said panel. Try the coordinates (500, 40) or (720, 40) to use the
center of the screen. For the connection, connect the selected path pin of the file dialog
to the file path pin of the IMAQ ReadFile. Then, connect the new image pin of one of the
IMAQ Create (input image) to the image pin of the IMAQ ReadFile. After that, image out
pin of the IMAQ ReadFile to the image pin of the IMAQ WindDraw. Make sure to create
a constant for the title (name it as Original Image) and window number for IMAQ
WindDraw to avoid errors. For the window number, the default is 0, if the user will use
another IMAQ WindDraw make sure to use different number.
5. For the next case structure, connect the Process button to the case selector. Inside
this case structure are the blocks that manipulate or change the image. These blocks are
the IMAQ ConstructROI (Right click on the block diagram panel > Vision and Motion >
Vision Utilities > External Display > IMAQ ConstructROI), IMAQ ROItoMask2 (Right click
on the block diagram panel > Vision and Motion > Vision Utilities > Region of Interest >
IMAQ ROItoMask2), IMAQ Quantify (Right click on the block diagram panel > Vision and
Motion > Image Processing > Analysis > IMAQ Quantify) and the IMAQ WindDraw(Right
click on the block diagram panel > Vision and Motion > Vision Utilities > External Display
> IMAQ WindDraw); for the IMAQ ConstructROI, connect the image out of the IMAQ
ReadFile block to the image pin of the IMAQ ConstructROI and make sure to produce a
control for the tools and color palette to manipulate the input image. To get the
properties of ROI image, you need to connect the image out and ROI Descriptor out of
the IMAQ ConstrucROI to the image and ROI descriptor pin of IMAQ ROItoMask and

94 | P a g e
then connect the image out pin to the image pin of the IMAQ Quantify and make sure to
create a control for the filling value and background value if you want to control the
changes in the image. For the IMAQ WindDraw, connect the image out of the IMAQ
ROItoMask2 to the image pin of IMAQ WindDraw to show the processed image in
different panel. Make sure that the window number of the second IMAQ WindDraw is
different from the first IMAQ WindDraw and also you have to create a title for your
IMAQ WindDraw (name it as Processed Image). If the users notice some white box on
the edge of the case structure try to connect the new image pin of IMAQ Create (input
image) to the image source pin of the IMAQ Inverse for the false condition of the first
case structure. The white block means that the connection for the other condition is not
yet connected. And lastly, create an indicator for global and region reports.
6. For the last case structure, connect the Close button to the case selector. Inside this
case structure are the IMAQ WindClose (Right click on the block diagram panel > Vision
and Motion > Vision Utilities > External Display > IMAQ WindClose), Unbundle by
Name(Right click on the block diagram panel > Cluster, Class & Variant > Unbundle by
Name), Not button (Right click on the block diagram panel > Boolean > Not), Stop
button (Right click on the block diagram panel > Application Control > Stop) and IMAQ
Dispose (Right click on the block diagram panel > Vision and Motion > Vision Utilities >
Image Management > IMAQ Dispose). For the connection, connect the error out pin of
the IMAQ WindClose to the input cluster pin of the unbundle by name. The unbundle
by name status must be connected to the not button. Then, the not button parallel
with the all images pin of IMAQ Dispose and Stop button. After that, parallel the not
button and the continuous stop button (Right click the loop condition button then check
the continue if true status) from the loop to the Close button so that the program
will run continuously until the close button has been clicked.
7. Try to familiarize the terminals on this block. All the functions and applications for every
terminal.
8. Lastly, press Load to choose image that you need and press Process if you want to
process that image and see the difference between the two.

95 | P a g e
Figure 7.1 Region of Interest VI

B. LOOK-UP TRANSFORMATIONS EQUALIZER

1. First, repeat steps 1-4 from the ROI procedure.


2. For the next case structure, connect the Process button to the case selector. Inside
this case structure are the blocks that manipulate or change the image. These blocks are
the IMAQ Histogram (Right click on the block diagram panel > Vision and Motion >
Image Processing > Analysis > IMAQ Histogram), IMAQ Equalize (Right click on the block
diagram panel > Vision and Motion > Image Processing > Processing > IMAQ Equalize)
and the IMAQ WindDraw (Right click on the block diagram panel > Vision and Motion >
Vision Utilities > External Display > IMAQ WindDraw); for the IMAQ Histogram, connect
the image out of the IMAQ ReadFile block to the image pin of the IMAQ Histogram. The
histogram serves as the storage of the processed image before further processing it.
Connect the output of IMAQ ReadFile to the IMAQ Equalizer and create a control for the
number of classes. This pin will serves as the control in the equalization and brightness
of the image. And then, if you want to see the properties of the histogram just create an
indicator at the histogram report pin. After that, connect the histogram report pin of the
IMAQ Histogram to the histogram report pin of the IMAQ Equalize so that the
properties of the histogram can be equalize. For the IMAQ WindDraw, connect the
image out of the IMAQ Equalize to the image pin of IMAQ WindDraw to show the
processed image in different panel. Make sure that the window number of the second
IMAQ WindDraw is different from the first IMAQ WindDraw and also you have to create
a title for your IMAQ WindDraw (name it as Processed Image).
3. Repeat steps 6-8 from the ROI procedure.

96 | P a g e
Figure 7.2 Equalizer VI

V. OBSERVATIONS
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________

VI. DATA AND RESULTS


________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________

VII. TEST YOUR SKILLS


1. Create a program that presses the load button to select, load and display an image.
Set the input grey level range that is to be mapped using the minimum and maximum
values in range. Select different lookup transformations functions like as histogram
equalization, histogram inversion, Gamma corrections, Inverse Gamma corrections,

97 | P a g e
logarithmic corrections, and exponential corrections linear, logarithmic, exponential,
and square, square-root, power X, or power 1/X to define the lookup transformation
functions. Hit the process button and observe the original and processed images. Try
various lookup transformations for separate images and different ranges and in each
case observe the results. Differentiate the uses in each transformation.

2. Create a program that presses the load button to select, load and display an image.
Select different selection tool to obtain a specific selection tool like point, line,
rectangle, oval, polygon, freehand region and annulus. Hit the process button and
observe between the original and processed images. Try various selection tools for
separate images and in each case observe the results. Differentiate these tools and their
accuracy in the region of interest.

VIII. QUESTIONS AND ANSWERS


1. What is the default background value in the Region of Interest VI?
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________

2. In your opinion, what is the best selection tool that can be used in the region of
interest?
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________

IX. CONCLUSION
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________

98 | P a g e
Laboratory Exercise No. 8
MORPHOLOGICAL IMAGE PROCESSING

I. OBJECTIVES
1. To define morphological image processing and the use of structuring elements in the
process.
2. To understand basic morphological image processing operations.
3. To use both binary images and grey-scale images in morphological image processing.
4. To pre-define the use of morphological image processing in biomedical engineering.

II. PREREQUISITE KNOWLEDGE


1. Knowledge gained from Lab 1 - Lab 7

III. THEORY
Morphology was derived from the Greek
word morph which means to shape or form,
morphology in general refers to the process of
changing an image using computer practices in
gradual steps. Morphology can be compared to the
changing of a human body, from a small baby to
puberty until it reaches adulthood. In images,
morphology is used to remove noise and holes from
an object.

Morphological transformation is the process of extracting and/or modifying a specific


image. These transformations are useful in an images quantitative analysis and geometrical
properties analysis. It is also used in getting the basic modeling shapes, patterns and other
operations. Morphological operations are also applied in expanding or reducing particle
dimensions, gap filling, closing inclusions and the averaging of particle edges. Morphological
operations are based on neighborhood pixels, this means that the value of the pixel
underinspection(PUI) depends on the value of its neighborhood pixel.

99 | P a g e
A.Categories of Morphologiocal Image Transformations
Morphological transformation are
furthermore subdivided into two categories, these
Morphological are the binary morphological transformation and
Transformation
the gray-level morphological transformation.
Binary morphological transformations are applied
into binary images. A binary image is defines as an
Gray-Level
Binary Images
Images image divided into an object region which
contains particles, typically object pixels that are
coded by ones, and a background region wherein
object pixels are coded by zeros. Gray-level
Background
Object Region
Region morphological transformations, on the other
hand, are applied to gray-level images.

1. Basic Binary Morphological Transformations

a. EROSION

The process of eliminating isolated pixels located at


the background and corrodes the boundaries of the object
region is termed as erosion. The process of erosion
depends on the structuring element or mostly called
kernel. A structuring element is a pattern designated as
the coordinates of a specific number of discrete points
with respect to an origin. The origin in a kernel is marked
usually with a ring or is encircled. Cartesian coordinates
are the most commonly used representation of elements of a small image in a
rectangular grid. A 3x3 structuring element

b. DILATION
Just like in human eyes, the iris dilates, in images dilation is referred to as the
expansion of an object, increasing its size and removing holes and interconnecting
neighboring objects or pixels. Dilation is simply the reverse of erosion, the process of
dilation eliminates the small isolated gaps from particles and it emphasizes and
enlarges the contour of particles depending on the structuring element.

100 | P a g e
Original Structure Dilution Erosion

c. CLOSING

Closing is the morphological process of closing small holes and other non-
relevant background features by first diluting an image then eroding it. In this
process, the original data of the image is lost and hence could never be recovered.

d. OPENING
Opening is the reverse process of closing. In this procedure, the holes are
expanded and also the background features. This is done by first eroding an image
and then diluting it. The resulting image will not look exactly the same as the source
image, and the only remaining portions are the bulk areas.

2. Non-binary Morphological Transformations


Non-binary morphological transformation uses other methods in creating a
binary image rather than using the process of thresholding. These methods are gray and
color morphology. Gray morphology is the process of performing binary morphology
into coupled neighboring colors. The resulting image is then weighted back to its
respective gray levels and then recombined into an image with n-1colors.

B. Blocks Used in Image Morphology


1. IMAQ Threshold
The IMAQ Threshold function leads to a binary image by thresholding a grey-scale
image.

101 | P a g e
2. IMAQ Morphology
The IMAQ Morphology block performs basic morphological transformations.

3. IMAQ GrayMorphology
IMAQ GrayMorphology block performs grey-scale morphological transformations.

4. IMAQ Particle Analysis


This returns the number of particles detected in a binary image and a 2D array of
requested measurements about the particle.

5. IMAQ Particle Filter 3

IMAQ Particle Filter 3is used to filter each particle in an image according to its
measurements.

102 | P a g e
6. IMAQ FillHole
The IMAQ FillHole block fills the holes found in a particle.

7. IMAQ Distance
IMAQ Distance encodes a pixel value of a particle as a function of the location of
that pixel in relation to the distance to the border of the particle.

8. IMAQ Danielsson

IMAQ Danielssonreturns a distance map based on the algorithms of Danielsson.

9. IMAQ GrayMorphology Reconstruction

IMAQ GrayMorphologyReconcstruction performs morphological reconstruction on


gray-scale images.

103 | P a g e
10. IMAQ BinaryMorphology Reconstruction
The IMAQ BinaryMorphology Reconstruction block performs morphological
reconstruction on binary images.

IV. PROCEDURES

A. Practical Morphology Exercises

1. Perform dilation and erosionusing the given LabVIEW VI in Figure 8-1. Using an Event
Structure inside a while loop with File Dialog (Right click on the block diagram panel
> File I/O >Adv File Funcs> File Dialog), two IMAQ Create blocks (Right click on the
block diagram panel > Vision and Motion > Vision Utilities > Image Management >
IMAQ Create), IMAQ ReadFile (Right click on the block diagram panel > Vision and
Motion > Vision Utilities > File > IMAQ ReadFile), IMAQ WindDraw (Right click on the
block diagram panel > Vision and Motion > Vision Utilities > External Display > IMAQ
WindDraw), IMAQ Particle Analysis (Right click on the block diagram panel > Vision
and Motion >Image Processing>Analysis > IMAQ ParticleAnalysis), IMAQ Dispose
(Right click on the block diagram panel > Vision and Motion > Vision Utilities > Image
Management > IMAQ Dispose), and IMAQ WindClose (Right click on the block
diagram panel > Vision and Motion > Vision Utilities > External Display > IMAQ
WindClose).
2. Name the File Dialog and connect its selected path to the File Path node of the IMAQ
ReadFile. Connect the Image node of the IMAQ ReadFile to the New Image node of
the first IMAQ Create block named as Source Image. Connect the Image Out node of
the IMAQ ReadFile to a named and numbered IMAQ WindDraw. Connect the Image
Out node of the IMAQ WindDraw to the Imge node of IMAQ Particle Analysis.
3. Inside the event structure put an IMAQ GrayMorphology block (Right click on the
block diagram panel > Vision and Motion >Image Processing>Morphology> IMAQ

104 | P a g e
GrayMorphology). Connect the Image Out node of IMAQ Particle Analysis to the
Image Src node of IMAQ GrayMorphology and its Image Dst node to a named
second IMAQ Creates New Image node. Connect its Image Dst Out node to a
number and named IMAQ WindDraw.
4. Using a select block, connect its output to the Operation node of the IMAQ
GrayMorphology and create a constant for both the t and f input and select erode
and dilate. Create a control for its s node named Operation and connect it to the s
node of another select block where its output is also connected to the Title node of
the IMAQ WindDraw. Create a constant for the t and f input and name it as Eroded
Image and Dilated Image.
5. Create a control for the loop condition and move it inside the event structure. Right
click on the event structure and edit the events handled by this case. Choose
Operation on the Control Tab, and mouse up on the Mouse tab. Connect all the
error ins and outs of all the blocks and connect it to the IMAQ WindClose and IMAQ
Dispose outside the loop.
6. Go to the front panel view and change the Operation control to a toggle switch and
label it according to its operation as shown in Figure 8-2.
7. Run the program and choose X-Ray Image 3 and save both the Eroded and Dilated
images.

Fig.8-1 Dilation and Erosion

105 | P a g e
Fig.8-2 Dilation and Erosion Front Panel View

8. Perform closing and opening using the given LabVIEW VI Figure 8-3. Repeat steps 1-7
and change the operations to Close and Open operation. Change also the Title
constant on the IMAQ WindDraw to Closed and Opened Image.
9. Go to the front panel view and change also the label of the toggle switch. The front
panel view is shown in Figure 8-4.

Fig.8-3 Closing and Opening

106 | P a g e
Fig.8-4 Closing and Opening Front Panel View

B. Specific Morphological Operations

1. Perform particle removal using the given LabVIEW VI in Figure 8.5. Using an Event
Structure inside a while loop with File Dialog (Right click on the block diagram panel
> File I/O >Adv File Funcs> File Dialog), two IMAQ Create blocks (Right click on the
block diagram panel > Vision and Motion > Vision Utilities > Image Management >
IMAQ Create), IMAQ ReadFile (Right click on the block diagram panel > Vision and
Motion > Vision Utilities > File > IMAQ ReadFile), IMAQ WindDraw (Right click on the
block diagram panel > Vision and Motion > Vision Utilities > External Display > IMAQ
WindDraw), IMAQ Particle Analysis (Right click on the block diagram panel > Vision
and Motion >Image Processing>Analysis > IMAQ Particle Analysis), IMAQ Dispose
(Right click on the block diagram panel > Vision and Motion > Vision Utilities > Image
Management > IMAQ Dispose), and IMAQ WindClose (Right click on the block
diagram panel > Vision and Motion > Vision Utilities > External Display > IMAQ
WindClose).
2. Name the File Dialog and connect its selected path to the File Path node of the IMAQ
ReadFile. Connect the Image node of the IMAQ ReadFile to the New Image node of
the first IMAQ Create block named as Source Image. Connect the Image Out node of
the IMAQ ReadFile to a named and numbered IMAQ WindDraw. Connect the Image
Out node of the IMAQ WindDraw to the Image node of IMAQ Particle Analysis.
Create an indicator for the number of particles node in the IMAQ Particle Analysis
and label it as Particles Before Removal.
3. Inside the event structure put an IMAQ Particle Filter 3 (Right click on the block
diagram panel > Vision and Motion >Image Processing>Morphology> IMAQ Particle
Filter 3) where its Image Src is connected to the Image Out node of the IMAQ

107 | P a g e
WindDraw and the Image Dst node is connected to the second IMAQ Creates New
Image node. Create also a control for the Selection Values node and connect its
Image Dst Out node to a named and numbered IMAQ WindDraw. Its Image Out
node is also connected an IMAQ Particle Analysis block with an indicator in its
Number of Particles. Connect also an IMAQ GetPaletteblock (Right click on the block
diagram panel > Vision and Motion > Vision Utilities > External Display
>IMAQGetPalette) to the color palette node of the IMAQ WindDraw and move it
outside the loop. Create a constant for its palette number and set it to binary.
4. Connect all the error ins and out of every block and create a control for the loop
condition of the while loop structure.
5. Right-click the event structure and edit the events handled by this case. On the
control tabs, select Selection Values, and on the shortcut menu tab, select value
change.
6. Follow the front panel view shown in Figure 8-6 and run the program. Use the
circles.jpg image located on the Morphology Folder. After editing the selection
values shown in the front panel, click the range button and observe the resulting
image and the particles after removal.

Fig.8-6Particle Removal Wiring Diagram

108 | P a g e
Fig.8-7 Particle Removal Front Panel View

7. Perform holes filling using the LabVIEW VI given in Figure 8.8. Create another event
case. Put an IMAQ FillHole (Right click on the block diagram panel > Vision and
Motion >Image Processing>Morphology > IMAQ FillHole) and a numbered and
named IMAQ WindDraw. Connect the Image Src node of the IMAQ FillHole to the
Image Out node of the IMAQ WindDraw outside the loop and its Image Dst node to
the second IMAQ Creates New Image node outside the loop. Connect the Image Dst
Out node of the IMAQ FillHole to the IMAQ WindDraw. Create a control in its
connectivity node. Connect also the IMAQ GetPalette block to the IMAQ WindDraw
on the event structure. Connect all the error ins and outs and also a control for the
loop condition.

109 | P a g e
Fig.8-9 Holes filling wiring diagram

8. Run the program. Load circles2.jpg image located on the Morphology Folder. Click
connectivity to acquire the resulting image. Save it as Filled-Hole Image.
9. Add another event on the event structure and put an IMAQ Distance (Right click on
the block diagram panel > Vision and Motion >Image Processing>Morphology >
IMAQ Distance) and IMAQ WindDraw. Connect the Image Src node of the IMAQ
Distance to the IMAQ WindDraws Image Out node, and the Image Dst node of the
second IMAQ Creates New Image node. Connect the Image Dst Out to a named and
numbered IMAQ WindDraw. Connect also the IMAQ GetPalette to the Color Palette
node of the IMAQ WindDraw. Connect all the error ins and outs of the added
blocks and also the control for the loop condition. The block diagram is shown in
Figure 8-10.
10. Create a control for the Square/Hexa node of the IMAQ Distance. Edit the event
handled by this case, choose Square/Hexa on the control tab and Mouse Up on the
Mouse tab.
11. Run the program. Load circles3.jpg image. Click the Square/Hexa slide switch to
acquire the resulting image. Save it as Distance Contoured Image.

110 | P a g e
Fig. 8-10 Distance Contouring using IMAQ Distance

12. Create a new blank VI. Perform distance contouring using IMAQ Danielsson (Right
click on the block diagram panel > Vision and Motion >Image
Processing>Morphology > IMAQ Danielsson). Also using File Dialog (Right click on
the block diagram panel > File I/O >Adv File Funcs> File Dialog), two IMAQ Create
blocks (Right click on the block diagram panel > Vision and Motion > Vision Utilities >
Image Management > IMAQ Create), IMAQ ReadFile (Right click on the block
diagram panel > Vision and Motion > Vision Utilities > File > IMAQ ReadFile), two
IMAQ WindDraw (Right click on the block diagram panel > Vision and Motion >
Vision Utilities > External Display > IMAQ WindDraw), IMAQ Particle Analysis (Right
click on the block diagram panel > Vision and Motion >Image Processing>Analysis >
IMAQ Particle Analysis), IMAQ Dispose (Right click on the block diagram panel >
Vision and Motion > Vision Utilities > Image Management > IMAQ Dispose), and
IMAQ WindClose (Right click on the block diagram panel > Vision and Motion >
Vision Utilities > External Display > IMAQ WindClose), IMAQ GetPalette (Right click
on the block diagram panel > Vision and Motion > Vision Utilities > External Display
>IMAQGetPalette).
13. Name the File Dialog and connect its selected path to the File Path node of the IMAQ
ReadFile. Connect the Image node of the IMAQ ReadFile to the New Image node of
the first IMAQ Create block named as Source Image. Connect the Image Out node of

111 | P a g e
the IMAQ ReadFile to a named and numbered IMAQ WindDraw. Connect the Image
Out node of the IMAQ WindDraw to the Imge node of IMAQ Particle Analysis.
14. Connect the Image Src node of IMAQ Danielsson to the Image Out node of the IMAQ
WindDraw and its Image Dst node to the second IMAQ Creates New Image node.
Connect its Image Dst Out node to the second, named and numbered, IMAQ
WindDraw. Connect also the IMAQ GetPalette block to the color palette node of the
second IMAQ WindDraw. Create a constant on the palette number node of the
IMAQ GetPalette and set it to binary. Connect all the error ins and outs of every
block in the window.
15. Run the program. Load again circles3.jpg. Save the acquired image and differentiate
it to the acquired image of distance contouring using IMAQ Distance (Right click on
the block diagram panel > Vision and Motion >Image Processing>Morphology >
IMAQ Distance).

Fig.8-11Distance Contouring using IMAQ Danielsson

C. Implementation of Morphological Analaysis in Binary Images

1. Create a new blank VI to perform Binary Morphology using three case structures
inside a while loop (Right click on the block diagram panel > Structures > While loop/
Case Structure), three IMAQ Create blocks (Right click on the block diagram panel >
Vision and Motion > Vision Utilities > Image Management > IMAQ Create), IMAQ

112 | P a g e
WindClose (Right click on the block diagram panel > Vision and Motion > Vision
Utilities > External Display > IMAQ WindClose) and IMAQ WindMove (Right click on
the block diagram panel > Vision and Motion > Vision Utilities > External Display >
IMAQ WindMove). The block diagram is shown in Figure 8.12.
2. Name the IMAQ Create blocks Source Image, Thresh Image, and Dest Image and
connect their New Image node to the while loop, also the error out of the first IMAQ
Create block. Connect the error out to the IMAQ Dispose (Right click on the block
diagram panel > Vision and Motion > Vision Utilities > Image Management > IMAQ
Dispose) and IMAQ WindClose located outside the loop.
3. On the first case structure with a case selector control labeled as Load Button,
connect the File Dialogs (Right click on the block diagram panel > File I/O >Adv File
Funcs> File Dialog) selected path to the File Path of IMAQ ReadFile (Right click on
the block diagram panel > Vision and Motion > Vision Utilities > Files> IMAQ
ReadFile) and name its prompt as Select an Image File. Connect the New Image
node and error out of the IMAQ Create to the Image node and error in of the IMAQ
ReadFile, respectively. Connect the Image Out node of the IMAQ ReadFile to a
named and number IMAQ WindDraw that is also connected to an IMAQ WindMove
with a set coordinates for the window to display.
4. On the second case structure with a case selector control labeled as Threshold,
connect the Image Src node of the IMAQ Thresholdblock (Right click on the block
diagram panel > Vision and Motion >Image Processing> Processing> IMAQ
Threshold) to the Image Out node of the IMAQ ReadFile located in the first case
structure and its Image Dst node to the second IMAQ Creates New Image node.
Create a control for the Range node of the IMAQ Threshold. Connect the Image Dst
Out of the IMAQ Threshold to a named and numbered IMAQ WindDraw that is also
connected to an IMAQ WindMove with a set coordinates for the window to be
displayed.
5. From the Image Dst Out of the IMAQ Threshold, connect to the Image Src node of an
IMAQ Morphology (Right click on the block diagram panel > Vision and Motion
>Image Processing>Morphology > IMAQ Morphology) and its Image Dst node to the
third IMAQ Creates New Image node located outside the loop. Create a control for
the Operation, Number of Iterations and Structuring Element nodes. Connect the
Image Dst Out of the IMAQ Morphology to a named and numbered IMAQ
WindDraw.
6. Connect an IMAQ GetPalette (Right click on the block diagram panel > Vision and
Motion > Vision Utilities > External Display >IMAQGetPalette) to the Color Palette
node of the two IMAQ WindDraw inside the second case structure. Create a
constant for the Palette number node of the IMAQ GetPalette and set it to Binary.
7. On the third case structure with a case selector control labeled as Save Image, put
an IMAQ WriteFile (Right click on the block diagram panel > Vision and Motion >
Vision Utilities > Files > IMAQ WriteFile) where its Image node is connected to the

113 | P a g e
Image Out node of the second IMAQ WindDraw located in the second case
structure. Its File Path node is connected to the selected path node of a File Dialog
with a prompt name of Save Image As. Create a control labeled as Stop for the loop
condition, continue if true, located inside the while loop.
8. Go to the false case of the first case structure, connect the Source Image node to the
Image Src node of the IMAQ Threshold. On the false case of the second case
structure connect the same Source Image node to the Image node of the IMAQ
WriteFile passing through the two case structures.
9. Go to the front panel view, place the controls accordingly as shown in Figure 8.13.
Replace the Load Button, Threshold, and Save Button to an OK button and rename it
as shown in the Figure. Set its mechanical action to latch when released.

Figure8.12 Implementation of Morphological Analysis on Binary Images Block Diagram

114 | P a g e
Figure 8.13Implementation of Morphological Analysis on Binary Images Interface

10. Run the program. Load Cancer Cell Image 3 and process using different operations.
Save all the acquired images, name the folder Binary Morphology Images.

D. Implementation of Morphological Transformation in Grey-Level Images

1. Create a new blank VI to perform Grey Morphology using three case structures
inside a while loop (Right click on the block diagram panel > Structures > While loop/
Case Structure), two IMAQ Create blocks (Right click on the block diagram panel >
Vision and Motion > Vision Utilities > Image Management > IMAQ Create), IMAQ
WindClose(Right click on the block diagram panel > Vision and Motion > Vision
Utilities > External Display > IMAQ WindClose) and IMAQ Dispose (Right click on the
block diagram panel > Vision and Motion > Vision Utilities > Image Management >
IMAQ Dispose).
2. Name the two IMAQ Create blocks, Source Image and Dest Image, respectively and
connect their New Image nodes on the loop. Then connect the error out of the first
IMAQ Create block to the IMAQ Dispose and IMAQ WindClose passing through the
loop.
3. On the first case structure with a case selector control labeled as Load Button,
connect the File Dialogs (Right click on the block diagram panel > File I/O >Adv File
Funcs> File Dialog) selected path to the File Path of IMAQ ReadFile (Right click on
the block diagram panel > Vision and Motion > Vision Utilities > File > IMAQ

115 | P a g e
ReadFile)and name its prompt as Select an Image File. Connect the New Image
node and error out of the IMAQ Create to the Image node and error in of the IMAQ
ReadFile, respectively. Connect the Image Out node of the IMAQ ReadFile to a
named and number IMAQ WindDraw (Right click on the block diagram panel >
Vision and Motion > Vision Utilities > External Display > IMAQ WindDraw)that is also
connected to an IMAQ WindMove (Right click on the block diagram panel > Vision
and Motion > Vision Utilities > External Display > IMAQ WindMove) with a set
coordinates for the window to display.
4. On the second case structure with a case selector control labeled as Process,
connect the IMAQ GrayMorphology (Right click on the block diagram panel > Vision
and Motion >Image Processing>Morphology > IMAQ GrayMorphology) blocks Image
Src node to the IMAQ ReadFiles Image Out node located in the first case structure
while its Image Dst node is connected to the second IMAQ Creates New Image
node. Create a control for the Operation node of the same block and connect an
IMAQ BuildKernels (Right click on the block diagram panel > Vision and Motion
>Image Processing>Filters> IMAQ BuildKernel) Kernel node to the Structuring
Element node of the IMAQ GrayMorphology. Create a control for the Kernel Strings
node of the IMAQ BuildKernel.
5. Connect the Image Dst Out node of the IMAQ GrayMorphology to an IMAQ
Histograph (Right click on the block diagram panel > Vision and Motion >Image
Processing>Analysis> IMAQ Histograph) and create an indicator in its Histogram
Graph node. Connect also the Image Dst Out node of the IMAQ GrayMorphology to
a named and numbered IMAQ WindDraw.
6. On the third case structure with a case selector control labeled as Save Image, put
an IMAQ WriteFile (Right click on the block diagram panel > Vision and Motion >
Vision Utilities > Files > IMAQ WriteFile) where its Image node is connected to the
Image Dst node of the s IMAQ GrayMorphology located in the second case structure.
Its File Path node is connected to the selected path node of a File Dialog with a
prompt name of Save Image As. Create a control labeled as Stop for the loop
condition, continue if true, located inside the while loop.
7. Go to the false case of the first case structure and connect the Source Image node to
the Image Src node of the IMAQGrayMorphology. On the false case of the second
case structure, connect the node from the Source Image node to the Image node of
the IMAQ WriteFile located on the third case structure.
8. Go to the front panel window and replace the Load Button, Process, and Save Image
to an OK button and rename them according to the front panel view, shown in
Figure 8.15. Replace also the Histogram Graph by a Waveform Graph.

116 | P a g e
Figure 8.14 Implementation of Morphological Analysis on Grey-level Images Block Diagram

9. Run the program. Load X-RAY image 8 and Cancer Image 3. Process the images using
different operations and using the kernel given. Save the acquired images in a folder
named Grey Morphology Images.

Figure 8.15 Implementation of Morphological Analysis on Grey-level Images Interface

117 | P a g e
V. OBSERVATIONS
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________

VI. DATA AND RESULTS


________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________

VII. TEST YOUR SKILLS


1. Demonstrate a morphological segmentation using the watershed algorithm. Hint: Use
the Circles Image and a sequence structure in order to have the following sequence of
events:
a. Source Image
b. Threshold Image
c. Distance Contoured Image
d. Watershed Algorithm
e. Resulting Image

2. Demonstrate binary morphological reconstruction in the particle analysis. The block


threshold an image, computes the distance, and reconstructs only objects whose width
is greater than the number specified in thresholding.

3. Demonstrate gray morphological reconstruction that reconstructs an image using the


chosen ROI as a marker. The original image should be darker to be a marker image and
should be reconstructed. Subtract the reconstruction image from the source to separate
the objects. Then threshold the image to isolate the objects. A particle analysis returns
the center position of each particle and it will display the overlay result.

118 | P a g e
VIII. QUESTIONS AND ANSWERS
1. Why do images need to be morphed?
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________

2. Why is it essential that the structural element of an image is defined before it undergoes
morphological transformation?
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________

3. What is the significance of morphing images in binary and grey-level in biomedical


electronics?
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________

IX. CONCLUSION
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________

119 | P a g e
REFERENCES:

Introduction to Medical Electronics

McGraw-Hill Dictionary of Scientific & Technical Terms, 6E, Copyright 2003 ,The
McGraw-Hill Companies, Inc. via http://encyclopedia2.thefreedictionary.com/
medical+electronics

Electrical and Electronics Engineering Dictionary, Wiley, 2004.Via http://www.


dictionaryofengineering.com definition/medical-electronics.html

Jan Ainali, February 12, 2008, MRI-Philips via https://commons.wikimedia.org/wiki/File


:MRI-Philips.JPG, CC license 3.0

Joseph Scozzari, X-ray Machine for Captives, Guantanamo-b, October 17,2007, via
http://www.jtfgtmo.southcom.mil/virtualvisit/detainee_hospital.html

Thomas Ulrich, Medical Equipment, November 22,2012 via Pixabay, CC license

Wurtel, Monitor (medical), August 2007, via Wikimedia Commons, CC License

Myklassroom,no author, no adateMedical Electronics, http://www.myklassroom.com/


Engineering-branches/80/MEDICAL-ELECTRONICS

Laboratory Exercise No.1: Introduction to LabVIEW and IMAQ Vision

Christopher G. Relf, 2004, Image Acquisition and Processing with LabVIEW, United
States Of America, CRC Press LLC

Laboratory Exercise No.2: Basic Image Processing of Digital Images

Girod et.al,2013, Digital Image Processing EE368/CS232, Retrieved from http://web.


Stanford.edu/class/ee368/Handouts/Lectures/2015_Spring/1-Introduction_16x9.pdf

Russell A. Kirsch, NBSFirstScanImage, May 23, 2007, via Wikimedia Commons, CC


License 3.0

Laboratory Exercise No.3: Image Enhancement Point Operation

Image Analysis and Processing, 2016, Retrieved from http://www.ni.com/white-


paper/3470/en/

Laboratory Exercise No.4: Image Enhancement- Spatial Operation

120 | P a g e
Gonzales and Woods, 2008, Digital Image Processing, New Jersey, Pearson Education
Inc.

Laboratory Exercise No.5: Color Images

J.L. Morton, 2016, Basic Color Theory, Retrieved from http://www.colormatters.com/


color-and-design/basic-color-theory

Laboratory Exercise No.6: Image Processing in the Frequency Domain

Weisstein, Eric, Fourier Transfrom, Retrieved from http://mathworlds.wolfram.com/


FourierTransform.html

Jules Boilly, Joseph Fourier, circa 1823, via Wikimedia Commons, CC License 3.0

Laboratory Exercise No.7: Region of Interest and Look-Up Transformation

Techopedia,Region of Interest, Retrieved from https://www.techopedia.com/definition/


339/region-of-interest-roi

National Instruments, Lookup Tables, Retrieved from http://zone.ni.com/reference/en-


XX/help/372916L-01/nivisionconcepts/lookup_tables/

Laboratory Exercise No.8: Morphological Image Processing

Nick Efford, 2000, Digital Image Processing: A Practical Introduction Using Java, New
Jersey, Pearson Education

Human Growth, December 2008, Retrieved from http://nursingcrib.com/wp-


content/uploads/growth-chart2.jpg

121 | P a g e
122 | P a g e

You might also like