Although this isn't rocket science, you may need to get a pencil and paper
and draw some diagrams in order to understand exactly how the code in
Listing 7 work. I will leave that as an exercise for
the student.
Listing 7 also signals the end of the
else clause that
began in
Listing 5 .
Display pixel information
The code in
Listing 8 tests to determine if a mouse
button is pressed, and if so, calls the method named
displayPixelInfo to cause the information shown at the bottom of
Image 1 to be
displayed.
If you remove the
if statement and simply call the
displayPixelInfo method at this point without regard to the mouse
buttons, this information will be displayed any time that the mouse pointer isinside the display window.
The method named
displayPixelInfo is shown in its entirety
in
Listing 9 .
This method displays coordinate and color information for the pixel at the current
mouse pointer location. It also displays the width and the height of the image.
Calls to the text method
The new material in
Listing 9 is the set of repeated
calls to the
text method. There are many overloaded versions of this method. In a nutshell, theversion used in
Listing 9 displays the String given by
the first parameter at a location in the display window specified by the secondand third parameters.
The individual lines of text, as shown in
Image 1 , are
positioned relative to the bottom of the display window. Therefore, if there isinsufficient blank space at the bottom of the window
(70 vertical pixels), the text will be drawn on the bottom of the image.
Converting from
two dimensions to one dimension
You may also need some guidance relative to the use of the following
expression in
Listing 9 :
mouseY * width + mouseX
This is the expression that is used to extract color data from the
one-dimensional pixel array for a pixel at a given X,Y coordinate position.
Listing 9 also signals the end of the class named
Pr0120aRunner .
Run the program
I encourage you to copy the code from
Listing 10 and
Listing 11 and paste it into your PDE. Be sure to
put the code from
Listing 10 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 10 to change the name of the image file in
two different places . Change
the name from
Pr0120a.jpg to the name of your file.
Run the sketch
and observe the results. Experiment with the code. Make changes, run the sketch again, and observe the results of your changes. Make certain that youcan 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 the JavaScript version of the
sketch discussed in this module in your HTML 5 compatible 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
In this module, you learned how to write an image explorer sketch
that can be used determine the coordinates and RGB color values of any pixel inan image by
pointing to the pixel with a mouse. The sketch can also be used to determine thedimensions of the image.
Click
here to view the JavaScript version of the
sketch discussed in this module in your HTML 5 compatible browser.
Miscellaneous
This section contains a variety of miscellaneous information.
Housekeeping material
Module name: Pr0120-Image Explorer
File: Pr0120.htm
Published: 02/25/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 code discussed in this module are provided in
Listing 10 and
Listing 11 .
Communication is effective because it allows individuals to share ideas, thoughts, and information with others.
effective communication can lead to improved outcomes in various settings, including personal relationships, business environments, and educational settings. By communicating effectively, individuals can negotiate effectively, solve problems collaboratively, and work towards common goals.
it starts up serve and return practice/assessments.it helps find voice talking therapy also assessments through relaxed conversation.
miss
Every time someone flushes a toilet in the apartment building, the person begins to jumb back automatically after hearing the flush, before the water temperature changes. Identify the types of learning, if it is classical conditioning identify the NS, UCS, CS and CR. If it is operant conditioning, identify the type of consequence positive reinforcement, negative reinforcement or punishment
nature is an hereditary factor while nurture is an environmental factor which constitute an individual personality. so if an individual's parent has a deviant behavior and was also brought up in an deviant environment, observation of the behavior and the inborn trait we make the individual deviant.
Samuel
I am taking this course because I am hoping that I could somehow learn more about my chosen field of interest and due to the fact that being a PsyD really ignites my passion as an individual the more I hope to learn about developing and literally explore the complexity of my critical thinking skills