Using the JImageViewer classes. JImageViewer classes JImageViewer class JImageViewer class ImagePanel class ImagePanel class Image class Image class.

Slides:



Advertisements
Similar presentations
2D Graphics Drawing Things. Graphics In your GUI, you might want to draw graphics E.g. draw lines, circles, shapes, draw strings etc The Graphics class.
Advertisements

Image Processing … computing with and about data, … where "data" includes the values and relative locations of the colors that make up an image.
Mouse Listeners We continue our examination of GUIs by looking at how to interact with the mouse –Just as Java creates Events when the user interacts with.
Cosc 5/4730 Blackberry Drawing. Screen size With Blackberry devices, they have a known screen size in pixels. If you are programming for specific device.
Graphics Programming. Introduction GOAL: Build the Indexer Client Event-driven vs. Sequential programs Terminology – Top-level windows are called “frame.
1 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Programming Project 1 Truth Table Lecture 03, file P1 Due January.
CSE Lecture 6 – Complex Numbers & Images
More Java Drawing in 2D Animations with Timer. Drawing Review A simple two-dimensional coordinate system exists for each graphics context or drawing surface.
Introduction to Java Classes, events, GUI’s. Understand: How to use TextPad How to define a class or object How to create a GUI interface How event-driven.
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae & david streader, VUW Images and 2D Graphics COMP.
CSE 803 Using images in C++ Computing with images Applications & Methods 2D arrays in C++ Programming project 4.
Raster Displays Images are composed of arrays of pixels displayed on a raster device. Two main ways to create images: –Scan and digitize an existing image.
Bits are Not just for Numbers Computers store characters as bits or binary digits. Characters from the English-language keyboard are represented in ASCII.
Eleven colors and rasters. Color objects Meta represents colors with color objects You can create a color by saying: [color r g b] r: amount of red (0-255)
First Bytes - LabVIEW. Today’s Session Introduction to LabVIEW Colors and computers Lab to create a color picker Lab to manipulate an image Visual ProgrammingImage.
Eleven colors and rasters. Color objects Meta represents colors with color objects You can create a color by saying: [color r g b] r: amount of red (0-255)
CS 4731: Computer Graphics Lecture 21: Raster Graphics Part 2 Emmanuel Agu.
How Images are Represented Bitmap images (Dots used to draw the image) Monochrome images 8 bit grey scale images 24 bit colour Colour lookup tables Vector.
Bitmapped Images 27 th November 2014 With Mrs
OpenGL Pixel Operations, Bitmaps, Fonts and Images The Current Raster Position Current raster position: A position in window coordinates where the next.
Graphics and Multimedia. Introduction The language contains many sophisticated drawing capabilities as part of namespace System.Drawing and the other.
Data starts with width and height of image Then an array of pixel values (colors) The number of elements in this array is width times height Colors can.
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae, VUW Images and 2D Graphics COMP # 16.
Computer Systems Nat 4.5 Computing Science Data Representation Lesson 4: Storing Graphics EXTENSION.
© GCSE Computing Candidates should be able to:  explain the representation of an image as a series of pixels represented in binary  explain the need.
Objective Understand concepts used to create digital graphics. Course Weight : 15% Part Three : Concepts of Digital Graphics.
Java Programming, 3e Concepts and Techniques Chapter 3 Section 65 – Manipulating Data Using Methods – Java Applet.
Chapter 2 Getting Started: Drawing Figures. The Framebuffer Lecture 2 Fri, Aug 29, 2003.
Introduction to the CSImageViewer. CSImageViewer classes 1.MainProgram 2.CSImageViewer 3.ImageData 4.GrayImageData 5.ColorImageData 6.pnmHelper 7.Timer.
Field Trip #26 Create a Find a Word Puzzle in Java By Keith Lynn.
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 5 Working with Images Starting Out with Games & Graphics in.
A brief introduction to javadoc and doxygen Cont’d.
ImageJ EE4H, M.Sc Computer Vision Dr. Mike Spann
Using the ImageViewer classes. ImageViewer classes CAboutDlg CAboutDlg CChildFrame CChildFrame CDlgTemplateBuilder CDlgTemplateBuilder CInputDialog CInputDialog.
Computer Science 111 Fundamentals of Programming I Introduction to Graphics.
Computer Science 112 Fundamentals of Programming II Graphics Programming.
7/3/00SEM107- © Kamin & ReddyClass 11 - Events - 1 Class 11 - Events r A couple of odds & ends m Component sizes  switch statement r Event types r Catching.
Graphic User Interface. Graphic User Interface (GUI) Most of us interact with computers using GUIs. GUIs are visual representations of the actions you.
CS112 Scientific Computation Department of Computer Science Wellesley College Numb3rs Number and image types.
MSc Workshop - © S. Kamin, U.Reddy Lect 4 - Events - 1 Lecture 4 – Event Handling r Painting r Event types r Catching different event types.
CSE 219 Computer Science III Image Manipulation. HW 1 Has been posted on Blackboard Making a Game of Life with limited.
1 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Lecture 02b: Tutorial for Programming in Processing Jarek Rossignac.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Introduction to Android (Part.
(C) 2010 Pearson Education, Inc. All rights reserved.  Class Graphics (from package java.awt) provides various methods for drawing text and shapes onto.
CS1033 Pixel and Resolution
Paint Application in Java Clark Jayson Cacal Aveline Germar Jose Sison Christopher Valera.
12/5/2015 EEC492/693/793 - iPhone Application Development 1 EEC-693/793 Applied Computer Vision with Depth Cameras Lecture 4 Wenbing Zhao
Images. Digital Images Rectangular arrays of pixel data Pixel - picture element, smallest addressable part of the frame buffer. Color depth - the depth.
Lecture 24: Color Announcements & Review Lab 7 Due Thursday 2 D arrays - embedding graphs in an array Computer Science Artifacts Abstraction Representations.
Computer Vision Chapter 1 Introduction.  The goal of computer vision is to make useful decisions about real physical objects and scenes based on sensed.
Color Web Design Professor Frank. Color Displays Based on cathode ray tubes (CRTs) or back- lighted flat-screen Monitors transmit light - displays use.
A brief introduction to doxygen. What does a compiler do?  A compiler ignores comments and processes the code.  What does doxygen do? –It ignores the.
Graphics and Java2D Chapter Java Coordinate System Origin is in _____________ corner –Behind title bar of window X values increase to the ________.
June 14, ‘99 COLORS IN MATLAB.
CIS Intro to JAVA Lecture Notes Set 8 9-June-05.
Applets Java code is compiled into byte code instead of machine language –Languages like C, C++, Pascal and others are compiled into machine language so.
Lecture 3.1 Using Graphics with JFrame. © 2006 Pearson Addison-Wesley. All rights reserved javax.swing.JFrame - int x - int y - int width - int.
Buffers Computer Graphics I, Fall 2010.
Rina System development with Java Instructors: Rina Zviel-Girshin Lecture 10.
Chapter 4 -- Color1 Color Open GL Chapter 4. Chapter 4 -- Color2 n The goal of almost all OpenGL applications is to draw color pictures in a window on.
Buffers. 2 Objectives Introduce additional OpenGL buffers Learn to read and write buffers Learn to use blending.
1 SIC / CoC / Georgia Tech MAGIC Lab Rossignac Processing  Install Processing  Learn how to edit, run, save, export,
CS 240 Week 9. EventQueue.invokeLater In Swing, all user interface operations must occur on the “UI thread” – All components should be created on the.
1 Sections 5.1 – 5.2 Digital Image Processing Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
CompSci From bits to bytes to ints  At some level everything is stored as either a zero or a one  A bit is a binary digit a byte is a binary.
10/20/2005week71 Graphics, mouse and mouse motion events, KeyEvent Agenda Classes in AWT for graphics Example java programs –Graphics –Mouse events –Mouse.
A brief introduction to doxygen
Chapter 5 Working with Images
12.4 p 471 a) double[] number = {1.05, 2.05, 3.05, 4.05, 5.05};
Java-Assignment #4 (Due, April. 9, 2004)
Presentation transcript:

Using the JImageViewer classes

JImageViewer classes JImageViewer class JImageViewer class ImagePanel class ImagePanel class Image class Image class

JImageViewer classes JImageViewer class JImageViewer class main program entry point main program entry point construct one w/ image file name and a new window w/ an image will appear construct one w/ image file name and a new window w/ an image will appear menus & menu callbacks menus & menu callbacks implements ActionListener implements ActionListener contains: contains: mImagePanel mImagePanel mImage mImage

JImageViewer classes ImagePanel class ImagePanel class displays image via paint method displays image via paint method double buffered double buffered draws image into temporary buffer draws image into temporary buffer draws location string into temporary buffer draws location string into temporary buffer then draws temporary buffer then draws temporary buffer contains reference to JImageViewer “parent” via mParent contains reference to JImageViewer “parent” via mParent implements MouseMotionListener implements MouseMotionListener updates mMouseX and mMouseY updates mMouseX and mMouseY does NOT listen to clicks does NOT listen to clicks must implement MouseListener to receive mouse clicks (and a whole bunch of other events) must implement MouseListener to receive mouse clicks (and a whole bunch of other events)

JImageViewer classes Image class Image class constructor & image data members constructor & image data members given an image file name, the ctor loads the image into the member data given an image file name, the ctor loads the image into the member data

JImageViewer classes Image class Image class members: members: mW & mH (width and height of image) mW & mH (width and height of image) mMin & mMax (min and max scalar pixel value) mMin & mMax (min and max scalar pixel value) mIsColor mIsColor True if color True if color False if gray False if gray mImage mImage 1D int array of pixel values 1D int array of pixel values Each int is either Each int is either a single gray value or a single gray value or an rgb (red/green/blue) value an rgb (red/green/blue) value Cannot be drawn by Java Cannot be drawn by Java mOriginalImage mOriginalImage original image data original image data mScreenImage mScreenImage image data actually drawn in window image data actually drawn in window

JImageViewer classes Image class Image class mImage mImage 1D int array of pixel values 1D int array of pixel values each int is either each int is either a single gray value or a single gray value or an rgb value an rgb value What is mImage.length? What is mImage.length? If color, how can we get at the individual rgb values? If color, how can we get at the individual rgb values? Each rgb int contains contains: Each rgb int contains contains: 8 bits for red 8 bits for red 8 bits for green 8 bits for green 8 bits for blue 8 bits for blue sometimes an 8 bits alpha blending value is present as well sometimes an 8 bits alpha blending value is present as well How many different colors can we represent? How many different colors can we represent? What is gray in terms of rgb? What is gray in terms of rgb? How many different shades of grary can we represent? How many different shades of grary can we represent?

Representing color So given an integer containing an argb value, how can we get at the individual component values? So given an integer containing an argb value, how can we get at the individual component values? B is the least significant (8 bit) byte. B is the least significant (8 bit) byte. Bits 7..0 Bits 7..0 G is bits G is bits R is bits R is bits A is bits A is bits

Representing color B is the least significant (8 bit) byte. B is the least significant (8 bit) byte. bits 7..0 bits 7..0 int b = mImage[i] & ?; int b = mImage[i] & ?;

Representing color B is the least significant (8 bit) byte. B is the least significant (8 bit) byte. bits 7..0 bits 7..0 int b = mImage[i] & 0xff; int b = mImage[i] & 0xff;

Representing color G is bits G is bits int g = mImage[i] ?; int g = mImage[i] ?;

Representing color G is bits G is bits int g = (mImage[i] & 0xff00) >> 8; int g = (mImage[i] & 0xff00) >> 8;

Representing color R is bits R is bits int r = mImage[i] ?; int r = mImage[i] ?;

Representing color R is bits R is bits int r = (mImage[i] & 0xff0000) >> 16; int r = (mImage[i] & 0xff0000) >> 16;

Color Given individual rgb values (as 3 int/bytes), how do we “pack” them into a single int? Given individual rgb values (as 3 int/bytes), how do we “pack” them into a single int? int r = 12; int r = 12; int g = 14; int g = 14; int b = 92; int b = 92; int rgb = ?; int rgb = ?;

Color Given individual rgb values (as 3 int/bytes), how do we “pack” them into a single int? Given individual rgb values (as 3 int/bytes), how do we “pack” them into a single int? int r = 12; int r = 12; int g = 14; int g = 14; int b = 92; int b = 92; int rgb = (r<<16) | (g<<8) | b; int rgb = (r<<16) | (g<<8) | b;

Color Say we process our image data and wish to change the image that appears on the screen? Say we process our image data and wish to change the image that appears on the screen? Where is the image data? Where is the image data? Where is the displayed image? Where is the displayed image?

Color Say we process our image data and wish to change the image that appears on the screen? Say we process our image data and wish to change the image that appears on the screen? Where is the image data? Where is the image data? In mImage in the Image class. In mImage in the Image class. Where is the displayed image? Where is the displayed image? In mScreenImage in the Image class. In mScreenImage in the Image class.

Displaying image data mScreenImage in the Image class is of type BufferedImage. mScreenImage in the Image class is of type BufferedImage. It is what appears in the window. It is what appears in the window. Allocated by: Allocated by: mScreenImage = new BufferedImage( mW, mH, BufferedImage.TYPE_INT_RGB ); It is set/changed by: It is set/changed by:mScreenImage.setRGB( 0, 0, mW, mH, mImage, 0, mW );

Displaying image data mScreenImage.setRGB( 0, 0, mW, mH, mImage, 0, mW ); mImage must be in rgb format mImage must be in rgb format What do we do for gray data? What do we do for gray data? Gray data may be more than 8 bits! Gray data may be more than 8 bits!