You can selectively enable and disable the last two lines of code in
Listing 1 to cause the output image to be either the raw image
(as in
Image 1 ) or a modified version of the raw image
(as in
Image 2 ). As explained
earlier , the red and green color components are inverted and the blue color component
is set to zero in the last line of code in
Listing 1 .
The remainder of the for loop
The code in
Listing 2 is the same as in
Pr0120-Image Explorer . It is included here to provide
continuity in the discussion.
The call to the
text method was inserted in
Listing 3 to display my name in the upper-left corner
of
Image 2 .
The call to the
displayPixelInfo method was removed from the
if statement in
Listing 3 . This causes
the pixel information shown at the bottom of
Image 2 to
be displayed any time that the mouse pointer is inside the display window withno requirement to press a mouse button to display the information.
(The information is actually displayed all of the time based on the last
known location of the mouse pointer. At the beginning, the mouse pointer isassumed to be at coordinates 0,0. After that, if the mouse enters and then leaves the output
display window, the last known location is the point on the edge where it leftthe window.)
The remainder of the class named class Pr0130aRunner
The remainder of the class named class
Pr0130aRunner is essentially the same as before. I
explained the entire class
in
Pr0120-Image Explorer and won't repeat that explanation in this
module.
Run the program
I encourage you to copy the code from
Listing 4 and
Listing 5 into your PDE. Be sure to put the code from
Listing 4 in the leftmost tab.
Don't forget to put an image file of your choice in a folder named
data that is a child of the folder that contains the files with the
.pde extension. You will need to edit the code from
Listing 4 to change the name of the image file in
two different places . Change the
name from
Pr0130a.jpg to the name of your file.
Run the sketchand observe the results. Experiment with the code. Make changes, run the sketch again, and observe the results of your changes. Make certain that you
can explain why your changes behave as they do.
Don't forget to also create and run the JavaScript version of your sketch in
your HTML 5 compatible browser.
Click
here to view my
JavaScript version of the sketch in your HTML 5compatible browser.
If you have a programmable Android device
, try creating and running the Android version of your sketch in your
Android device.
Also try creating and running the stand-alone version of the sketch by
selecting
Export Application from the
File menu while in
Java mode.
Summary
This module introduced you to pixel-based image processing algorithms,
similar to those that you might find in commercial image editing software suchas
Photoshop .
Click
here to view the
JavaScript version of the sketch discussed in this module in your HTML 5compatible browser.
Miscellaneous
This section contains a variety of miscellaneous information.
Housekeeping material
Module name: Pr0130-Introduction to Image Processing
Algorithms
File: Pr0130.htm
Published: 02/26/13
Disclaimers:
Financial : Although the Connexions
site makes it possible for you to download a PDF file for thismodule at no charge, and also makes it possible for you to
purchase a pre-printed version of the PDF file, you should beaware that some of the HTML elements in this module may not translate well into
PDF.
I also want you to know that, I receive no financial compensation from the Connexions website even if you purchase
the PDF version of the module.
In the past, unknown individuals have copied my modules from cnx.org, converted them to Kindle books, and
placed them for sale on Amazon.com showing me as the author. Ineither receive compensation for those sales nor do I know who does
receive compensation. If you purchase such a book, please beaware that it is a copy of a module that is freely
available on cnx.org and that it was made and published withoutmy prior knowledge.
Affiliation : I am a professor of Computer Information
Technology at Austin Community College in Austin, TX.
Complete program listing
Complete listings of the classes discussed in this module are provided in
Listing 4 and
Listing 5 .