Using the ImageViewer classes. ImageViewer classes CAboutDlg CAboutDlg CChildFrame CChildFrame CDlgTemplateBuilder CDlgTemplateBuilder CInputDialog CInputDialog.

Slides:



Advertisements
Similar presentations
A C++ Crash Course Part II UW Association for Computing Machinery Questions & Feedback.
Advertisements

Procedural Programming in C# Chapters Objectives You will be able to: Describe the most important data types available in C#. Read numeric values.
Lecture 15: I/O and Parsing
Core Java Lecture 4-5. What We Will Cover Today What Are Methods Scope and Life Time of Variables Command Line Arguments Use of static keyword in Java.
Things to Remember When Developing 64-bit Software OOO "Program Verification Systems"
Unions The storage referenced by a union variable can hold data of different types subject to the restriction that at any one time, the storage holds data.
Character String Manipulation. Overview Character string functions sscanf() function sprintf() function.
Character String Manipulation. Overview Character string functions sscanf() function snprintf() function.
Lecture 20 Arrays and Strings
C Intro.
CS1061: C Programming Lecture 21: Dynamic Memory Allocation and Variations on struct A. O’Riordan, 2004, 2007 updated.
Growing Arrays in C By: Victoria Tielebein CS 265- Spring 2011.
Memory and Files Dr. Andrew Wallace PhD BEng(hons) EurIng
Primitive Variable types Basic types –char (single character or ASCII integer value) –int (integer) –short (not longer than int) –long (longer than int)
Computer Science 1620 Other Data Types. Quick Review: checklist for performing user input: 1) Be sure variable is declared 2) Prompt the user for input.
Introduction to Computers and Programming Lecture 7:
Mathematical Operators  2000 Prentice Hall, Inc. All rights reserved. Modified for use with this course. Introduction to Computers and Programming in.
Introduction and a Review of Basic Concepts
Working with the data type: char  2000 Prentice Hall, Inc. All rights reserved. Modified for use with this course. Introduction to Computers and Programming.
COMP 14: Intro. to Intro. to Programming May 23, 2000 Nick Vallidis.
An Introduction to C Programming (assuming that you already know Java; this is not an introduction to C++)
SOFTWARE TECHNOLOGY - I CONSTANTS VARIABLES DATA TYPES.
Java: Chapter 1 Computer Systems Computer Programming II.
Introduction to the CSImageViewer. CSImageViewer classes 1.MainProgram 2.CSImageViewer 3.ImageData 4.GrayImageData 5.ColorImageData 6.pnmHelper 7.Timer.
C Tokens Identifiers Keywords Constants Operators Special symbols.
By Nicholas Policelli An Introduction to Java. Basic Program Structure public class ClassName { public static void main(String[] args) { program statements.
Console Input. So far… All the inputs for our programs have been hard-coded in the main method or inputted using the dialog boxes of BlueJ It’s time to.
Basic Java Programming CSCI 392 Week Two. Stuff that is the same as C++ for loops and while loops for (int i=0; i
A brief introduction to javadoc and doxygen Cont’d.
ImageJ EE4H, M.Sc Computer Vision Dr. Mike Spann
IT253: Computer Organization Lecture 3: Memory and Bit Operations Tonga Institute of Higher Education.
Chapter 9 1 Chapter 9 – Part 1 l Overview of Streams and File I/O l Text File I/O l Binary File I/O l File Objects and File Names Streams and File I/O.
Using the JImageViewer classes. JImageViewer classes JImageViewer class JImageViewer class ImagePanel class ImagePanel class Image class Image class.
Netprog: Java Intro1 Crash Course in Java. Netprog: Java Intro2 Why Java? Network Programming in Java is very different than in C/C++ –much more language.
Pointers OVERVIEW.
Using Data Within a Program Chapter 2.  Classes  Methods  Statements  Modifiers  Identifiers.
College Board A.P. Computer Science A Topics Program Design - Read and understand a problem's description, purpose, and goals. Procedural Constructs.
Introduction to Java Lecture Notes 3. Variables l A variable is a name for a location in memory used to hold a value. In Java data declaration is identical.
College Board A.P. Computer Science A Topics Program Design - Read and understand a problem's description, purpose, and goals. Procedural Constructs -
1/28: Inputs, Variable Types, etc. Addition.java in depth Variable types & data types Input from user: how to get it Arithmetic operators.
Review Binary Numbers Bit : 0 or 1 Byte: 8 bites 256 different values 2 8 KB : 1024 bytes 2 10 bytes MB : 1024 * 1024 bytes 2 10 * 2 10 (2 20 ) bytes GB.
ECE 103 Engineering Programming Chapter 44 File I/O Herbert G. Mayer, PSU CS Status 6/4/2014 Initial content copied verbatim from ECE 103 material developed.
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.
Exceptions Chapter 16 This chapter explains: What as exception is Why they are useful Java exception facilities.
C# - variablesBjørk Busch1 Variables Basic types (also defined as classes with methods) : Integer-types Int, long, byte, sbyte, short, ushort, uint, ulong.
Road map char data type Reading –Liang 5: Chapter 2: 2.7.4; 2.9; –Liang 6: Chapter 2: 2.7.4; 2.9 –Liang 7: Chapter 2: 2.7.4; 2.9.
Gramming An Introduction to C Programming (assuming that you already know Java; this is not an introduction to C++)
1988 Morris Worm … estimated 10% penetration 2001 Code Red … 300,00 computers breached 2003 Slammer/Sapphire … 75,00 infections in 10 min Zotob …
1988 Morris Worm … estimated 10% penetration 2001 Code Red … 300,00 computers breached 2003 Slammer/Sapphire … 75,00 infections in 10 min Zotob …
Revisiting building. Preprocessing + Compiling 2 Creates an object file for each code file (.c ->.o) Each.o file contains code of the functions and structs.
Input Output Garbage In, Garbage Out. Outline Announcements: –Homework III: due Wednesday Advanced ASCII Binary Basics Filesystem Fun.
APS105 Malloc and 2D Arrays (text Ch6.4, Ch10.2).
An Introduction to C Programming (assuming that you already know Java; this is not an introduction to C++)
1 ENERGY 211 / CME 211 Lecture 3 September 26, 2008.
A variable is a name for a value stored in memory.
ECE Application Programming
Introduction to Programming
2.5 Another Java Application: Adding Integers
An Introduction to C Programming
Computer Programming Methodology File Input
A brief introduction to doxygen
null, true, and false are also reserved.
An Introduction to Java – Part I, language basics
© A+ Computer Science - VARIABLES © A+ Computer Science -
An overview of Java, Data types and variables
Chapter 2: Java Fundamentals
Bits and Bytes Topics Representing information as bits
Hank Childs, University of Oregon
Names of variables, functions, classes
CSS161: Fundamentals of Computing
Presentation transcript:

Using the ImageViewer classes

ImageViewer classes CAboutDlg CAboutDlg CChildFrame CChildFrame CDlgTemplateBuilder CDlgTemplateBuilder CInputDialog CInputDialog CImageViewerApp CImageViewerApp CImageViewerDoc CImageViewerDoc CImageViewerView CImageViewerView CLUT CLUT CMainFrame CMainFrame pnmHelper pnmHelper TIFFWriter TIFFWriter Timer Timer

ImageViewer classes Most important classes: Most important classes: –CImageViewerDoc –CImageViewerView –CInputDialog –pnmHelper –TIFFWriter –Timer

ImageViewer classes CImageViewerDoc class CImageViewerDoc class –mImageWidth, mImageHeight –mImageMin, mImageMax –OnOpenDocument(), OnSaveDocument(), OnCloseDocument()

ImageViewer classes CImageViewerDoc class CImageViewerDoc class –mImageSamplesPerPixel  1=gray, 3=rgb –int* mImage  actual image pixel data  stored mImage[0] is gray  or mImage[0]=r, mImage[1]=g, mImage[2]=b –3 separate ints

ImageViewer classes CImageViewerView class CImageViewerView class –unsigned char* mImage  displayable image  stored: b, g, r, 0 –4 separate bytes –Intel is little endian so this is actually 0,r,g,b  Recall CImageViewerDoc::mImage is 1 int per component while CImageViewerView::mImage is 1 byte per component. –OnMouseMove()

ImageViewer classes CImageViewerView class CImageViewerView class –OnDraw() CBitmap bm; bm.CreateBitmap( pDoc->mImageWidth, pDoc->mImageHeight, 1, 32, mImage ); pDoc->mImageHeight, 1, 32, mImage ); pDC->BitBlt( 0, 0, pDoc->mImageWidth, pDoc->mImageHeight, &dcMem, 0, 0, SRCCOPY ); pDoc->mImageHeight, &dcMem, 0, 0, SRCCOPY );or pDC->StretchBlt( mTx, mTy, (int)(mScale*pDoc->mImageWidth+0.5), (int)(mScale*pDoc->mImageWidth+0.5), (int)(mScale*pDoc->mImageHeight+0.5), &dcMem, 0, 0, (int)(mScale*pDoc->mImageHeight+0.5), &dcMem, 0, 0, pDoc->mImageWidth, pDoc->mImageWidth, pDoc->mImageHeight, SRCCOPY ); pDoc->mImageHeight, SRCCOPY );

ImageViewer classes pnmHelper class pnmHelper class static int* read_pnm_file ( const char* const fname, int* w, int* h, const char* const fname, int* w, int* h, int* samplesPerPixel, int* min, int* max) int* samplesPerPixel, int* min, int* max) This method should be generally used to read any pnm (pgm grey, ppm color) binary or ascii image files.

ImageViewer classes pnmHelper class pnmHelper class static void write_pgm_or_ppm_ascii_data ( const int* const buff, const int width, const int* const buff, const int width, const int height, const char* const fname, const int height, const char* const fname, const int samples_per_pixel ) const int samples_per_pixel ) Write values as a pgm (grey) or ppm (color) ascii file.

ImageViewer classes TIFFWriter class TIFFWriter class static void write_tiff_data8_rgb ( uint8* buff, int width, int height, FILE* fp, int width, int height, FILE* fp, const bool use_clut, const bool use_clut, const int samples_per_pixel ) const int samples_per_pixel ) Write a 24-bit color tiff image.

ImageViewer classes Timer class Timer class –Updated 3/22 –Can be used to easily time algorithms. –Timer() ctor starts the timer. –reset() resets the timer to 0 (and start the timer) –getElapsedTime() returns a double of the elapsed time in seconds. –getCPUTime() returns a double of the CPU time used in seconds. –Timer demo: show Debug and Release for median filter.

Timer class for Java public class Timer { /** \brief start at current time when constructed */ /** \brief start at current time when constructed */ private long mTime = System.currentTimeMillis(); private long mTime = System.currentTimeMillis(); /** \brief reset to current time */ /** \brief reset to current time */ public void reset ( ) { public void reset ( ) { mTime = System.currentTimeMillis(); mTime = System.currentTimeMillis(); } /** \brief return elapsed time in seconds */ /** \brief return elapsed time in seconds */ public double getElapsedTime ( ) { public double getElapsedTime ( ) { return (System.currentTimeMillis() - mTime) / 1e3; return (System.currentTimeMillis() - mTime) / 1e3; }}

ImageViewer classes CInputDialog class CInputDialog class –get new CInputDialog.h file from course web page –AfxMessageBox presents a modal dialog box to the user with a programmer-specified string. Java: String value = JOptionPane.showInputDialog( String value = JOptionPane.showInputDialog( "Enter value: " ); "Enter value: " );C++: CInputDialog dlg("Enter a value: "); CInputDialog dlg("Enter a value: "); CString result = dlg.m_str; //what user typed

Misc. C review topics printf printf –Must first #include –Must first #include int i=5242; printf( “The value %d\nis %x in hex.\n”, i, i ); double d = ; printf( “The std dev = %f.”, d ); char* name = “Ochlak”; printf( “Mr. %s, you have %.2f in your account.”, str, d );

Misc. C review topics sprintf sprintf –Just like printf but works on a string buffer in memory. char buff[ 256 ]; sprintf( buff, “Mr. %s, you have %.2f in your account.”, “Mr. %s, you have %.2f in your account.”, str, d ); AfxMessageBox( buff );

Misc. C review topics malloc/free malloc/free int* iptr = (int*) malloc( 1000 * sizeof(int) ); //what if iptr == NULL? for (int i=0; i<1000; i++) iptr[i] = i; iptr[i] = i; free( iptr ); //must do this or memory leaks occur! iptr = NULL; //just to be extra careful

Misc. C review topics Assert Assert –Assume or require some condition to be true. –Now in Java 5 as well! int* iptr = (int*) malloc( 1000 * sizeof(int) ); //what if iptr == NULL? assert( iptr != NULL ); Disappears completely in non-debug mode.

Misc. C review topics CInputDialog dlg("Enter a value: "); How can we check and convert what the user typed (a number)? int x; int howManyWereOK = sscanf( dlg.m_str, "%d", &x ); if (howManyWereOK!=1) { AfxMessageBox( “Bad input.” ); } else {......}

Misc. Java review topics String value = JOptionPane.showInputDialog( "Enter value: " ); "Enter value: " ); How can we check and convert what the user typed (a number)? boolean inputOK=true; int x; try { x = Integer.parseInt( value ); x = Integer.parseInt( value ); } catch (Exception e) { inputOK=false; inputOK=false;} if (!inputOK) { } else {......}

Misc. Java review topics String value = JOptionPane.showInputDialog( "Enter value: " ); "Enter value: " ); Octal support. int xy = 09; Compiler error: integer number too large. int jj = 0123; System.out.println( jj ); 83