<< Chapter < Page Chapter >> Page >
The purpose of this module is teach you how to write an image explorer sketch that can be used determine the coordinates and RGB color values of any pixel in an image by pointing to the pixel with a mouse. The sketch can also be used to determine the dimensions of the image.

Table of contents

Preface

This module is one in a collection of modules designed to teach you about the Processing open source programming environment.

Processing is a Java-based OOP programming environment for people who want to create images, animations, and interactions.

The purpose of this module is to teach you 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.

Viewing tip

I recommend that you open another copy of this module in a separate browser window and use the following links to easily find and view the imagesand listings while you are reading about them.

Images

  • Image 1 . Normal output.
  • Image 2 . Output for image too wide.
  • Image 3 . Output for image too tall.
  • Image 4 . Output produced by a common mathematical algorithm.

Listings

Preview

In this module, I will teach you how to write a Processing sketch that can be used to determine the following information by pointing to a locationin an image and pressing a mouse button:

  • Width and height of an image.
  • X and Y coordinates of the mouse pointer.
  • RGB color values for the pixel at the mouse pointer.

Normal output from the sketch

Normal output from this sketch is shown in the screen capture image in Image 1 . (Note that a screen capture image does not show the mouse pointer.)

Image 1. normal output.

Normal output showing pixel location colors, etc.
Image 1. Normal output.

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, The processing programming environment. OpenStax CNX. Feb 26, 2013 Download for free at http://cnx.org/content/col11492/1.5
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'The processing programming environment' conversation and receive update notifications?

Ask