1 Winter Quarter 2003Rolando V. Raqueño FINAL Project Information One Design Review presentations...

49
Winter Quarter 2003 Rolando V. Raqueño 1 1 FINAL Project Information • One Design Review presentations (10 minutes long) • A Final Document of your Project • Wiki Page Describing your Project – YourNameIdlGuiProject • Teaming is Encouraged – LastNamesIdlGuiProject

Transcript of 1 Winter Quarter 2003Rolando V. Raqueño FINAL Project Information One Design Review presentations...

Page 1: 1 Winter Quarter 2003Rolando V. Raqueño FINAL Project Information One Design Review presentations (10 minutes long) A Final Document of your Project Wiki.

Winter Quarter 2003 Rolando V. Raqueño 11

FINAL Project Information

• One Design Review presentations (10 minutes long)

• A Final Document of your Project

• Wiki Page Describing your Project– YourNameIdlGuiProject

• Teaming is Encouraged– LastNamesIdlGuiProject

Page 2: 1 Winter Quarter 2003Rolando V. Raqueño FINAL Project Information One Design Review presentations (10 minutes long) A Final Document of your Project Wiki.

Winter Quarter 2003 Rolando V. Raqueño 22

Final Project

• Post on the wiki, by this Thursday, a half page abstract of your intended GUI design, and the problem domain that it addresses.

Page 3: 1 Winter Quarter 2003Rolando V. Raqueño FINAL Project Information One Design Review presentations (10 minutes long) A Final Document of your Project Wiki.

Winter Quarter 2003 Rolando V. Raqueño 33

Working with Data

Page 4: 1 Winter Quarter 2003Rolando V. Raqueño FINAL Project Information One Design Review presentations (10 minutes long) A Final Document of your Project Wiki.

Winter Quarter 2003 Rolando V. Raqueño 44

Representation of Information in a Computer

• All information in a computer is stored as a collection of bits

• A bit, also known as a binary digit, is a number represented in base 2. It can only be either a 1 (one) or 0 (zero)

• Think of information as data with structure– All the one’s and zero’s represented by the

computer is data. How they are interpretted generates information (or garbage)

Page 5: 1 Winter Quarter 2003Rolando V. Raqueño FINAL Project Information One Design Review presentations (10 minutes long) A Final Document of your Project Wiki.

Winter Quarter 2003 Rolando V. Raqueño 55

Representation of Information in a Computer

• Information stored in a computer can represent– Instructions

• Executable Programs

– Data• Numbers - integers and real values• Characters - ASCII, multinational characters• Others - imagery, sound, etc.

Page 6: 1 Winter Quarter 2003Rolando V. Raqueño FINAL Project Information One Design Review presentations (10 minutes long) A Final Document of your Project Wiki.

Winter Quarter 2003 Rolando V. Raqueño 66

Representation of Information in a Computer

• Bits in a computer are usually grouped into the following units– 4 bits == 1 nibble– 8 bits == 1 byte or 1 ( char ) - a single

character– 16 bits == 2 bytes or 1 ( short int, int ) -

integer value– 32 bits == 4 bytes or 1 ( long int, int ) - integer

value– or 1( float) - real value– 64 bits == 8 bytes or 1 (double) - real value

Page 7: 1 Winter Quarter 2003Rolando V. Raqueño FINAL Project Information One Design Review presentations (10 minutes long) A Final Document of your Project Wiki.

Winter Quarter 2003 Rolando V. Raqueño 77

Representation of Information in a Computer

• Numbers can be represented as either integers or real values– integers { -5, 0, 125, -32767 }– real { 3.14159, -2.71828, -1.0e-20, 10.000 }

• Text is typically represented using the ASCII character set where each character is represented as a byte value.

Page 8: 1 Winter Quarter 2003Rolando V. Raqueño FINAL Project Information One Design Review presentations (10 minutes long) A Final Document of your Project Wiki.

Winter Quarter 2003 Rolando V. Raqueño 88

Representation of Information in a Computer• Text is typically represented using the ASCII character set

where each character is represented as a byte value.

The ASCII decimal character set is:

0 nul 16 dle 32 sp 48 0 64 @ 80 P 96 ` 112 p 1 soh 17 dc1 33 ! 49 1 65 A 81 Q 97 a 113 q 2 stx 18 dc2 34 " 50 2 66 B 82 R 98 b 114 r 3 etx 19 dc3 35 # 51 3 67 C 83 S 99 c 115 s 4 eot 20 dc4 36 $ 52 4 68 D 84 T 100 d 116 t 5 enq 21 nak 37 % 53 5 69 E 85 U 101 e 117 u 6 ack 22 syn 38 & 54 6 70 F 86 V 102 f 118 v 7 bel 23 etb 39 ' 55 7 71 G 87 W 103 g 119 w 8 bs 24 can 40 ( 56 8 72 H 88 X 104 h 120 x 9 ht 25 em 41 ) 57 9 73 I 89 Y 105 i 121 y 10 nl 26 sub 42 * 58 : 74 J 90 Z 106 j 122 z 11 vt 27 esc 43 + 59 ; 75 K 91 [ 107 k 123 { 12 np 28 fs 44 , 60 < 76 L 92 \ 108 l 124 | 13 cr 29 gs 45 - 61 = 77 M 93 ] 109 m 125 } 14 so 30 rs 46 . 62 > 78 N 94 ^ 110 n 126 ~ 15 si 31 us 47 / 63 ? 79 O 95 _ 111 o 127 del

Page 9: 1 Winter Quarter 2003Rolando V. Raqueño FINAL Project Information One Design Review presentations (10 minutes long) A Final Document of your Project Wiki.

Winter Quarter 2003 Rolando V. Raqueño 99

Representation of Information in a Computer

The quick brown

84 104 101 32 113 117 105 99 107 32 98 114 111 119 110 10

fox jumps over

102 111 120 32 106 117 109 112 115 32 111 118 101 114 10

the lazy dog.

116 104 101 32 108 97 122 121 32 100 111 103 46 10

Page 10: 1 Winter Quarter 2003Rolando V. Raqueño FINAL Project Information One Design Review presentations (10 minutes long) A Final Document of your Project Wiki.

Winter Quarter 2003 Rolando V. Raqueño 1010

Line Delimiters on Different Systems

• In the UNIX System, lines are delimited by linefeed (also designated as nl and has an ASCII value of 012 or 10)

• In MACS and PC’s, lines are delimited by carriage returns (also designated as cr and has an ASCII value of 015 or 13)

• Still other systems use a combination of carriage return-line feeds to delimit lines

Page 11: 1 Winter Quarter 2003Rolando V. Raqueño FINAL Project Information One Design Review presentations (10 minutes long) A Final Document of your Project Wiki.

Winter Quarter 2003 Rolando V. Raqueño 1111

Common Cross PlatformFile Problem

• Some one gave you a text file created on a PC which you transferred to the UNIX system. You try to edit the file using vi, but vi complains that the line is too long

• Solution: (A Stupid Unix Trick)– % cat old_file | tr “\015” “\012” > new_file– This command translates all carriage returns to

line feeds.

Page 12: 1 Winter Quarter 2003Rolando V. Raqueño FINAL Project Information One Design Review presentations (10 minutes long) A Final Document of your Project Wiki.

Winter Quarter 2003 Rolando V. Raqueño 1212

Numbering SystemsDECIMAL BINARY OCTAL HEXADECIMAL(Base 10) (Base 2) (Base 8) (Base 16)

0 0 0 01 1 1 12 10 2 23 11 3 34 100 4 45 101 5 56 110 6 67 111 7 78 1000 10 89 1001 11 910 1010 12 A11 1011 13 B12 1100 14 C13 1101 15 D14 1110 16 E15 1111 17 F

Page 13: 1 Winter Quarter 2003Rolando V. Raqueño FINAL Project Information One Design Review presentations (10 minutes long) A Final Document of your Project Wiki.

Winter Quarter 2003 Rolando V. Raqueño 1313

Converting Number BasesIn base 10,

4210 = 4 x 101 = 40+ 2 x 100 = 2_________________

4210 = 4210

In base 2,4210 = 1 x 25 = 32

+ 0 x 24 = 0+ 1 x 23 = 8+ 0 x 22 = 0+ 1 x 21 = 2+ 0 x 20 = 0_________________

1010102 = 4210

Page 14: 1 Winter Quarter 2003Rolando V. Raqueño FINAL Project Information One Design Review presentations (10 minutes long) A Final Document of your Project Wiki.

Winter Quarter 2003 Rolando V. Raqueño 1414

Converting Number Bases

In base 8,4210 = 5 x 81 = 40

+ 2 x 80 = 2_________________

528 = 4210

In base 16,4210 = 2 x 161 = 32

+ A x 160 = 10_________________

2A16 = 4210

Page 15: 1 Winter Quarter 2003Rolando V. Raqueño FINAL Project Information One Design Review presentations (10 minutes long) A Final Document of your Project Wiki.

Winter Quarter 2003 Rolando V. Raqueño 1515

Negative Number RepresentationDECIMAL DECIMAL BINARY

(Base 10) (4-digit) (4-digit)-8 9992 1000-7 9993 1001-6 9994 1010-5 9995 1011-4 9996 1100-3 9997 1101-2 9998 1110-1 9999 11110 0 00001 1 00012 2 00103 3 00114 4 01005 5 01016 6 01107 7 0111

Page 16: 1 Winter Quarter 2003Rolando V. Raqueño FINAL Project Information One Design Review presentations (10 minutes long) A Final Document of your Project Wiki.

Winter Quarter 2003 Rolando V. Raqueño 1616

Converting a Negative Number into

Binary using 2’s ComplementFor example lets convert -4210 into a negative binary

• Determine number of bits we want to represent (e.g. 16)

• Convert the absolute value (42) into binary

0000000000101010

• Take the 1’s complement of the binary number

1111111111010101

• Add 1 (one) to the resulting number

1111111111010110

Page 17: 1 Winter Quarter 2003Rolando V. Raqueño FINAL Project Information One Design Review presentations (10 minutes long) A Final Document of your Project Wiki.

Winter Quarter 2003 Rolando V. Raqueño 1717

How Does This All Relate to Computers and

Programming• Computer Architectures generally are described using thenumbering systems we have mentioned.

• We can determine the limitations of systems by the ranges described by these numbers.

• In hardware, these numbers determine the amount of memory a particular system can address and the range of values a particular memory location can hold.

• In programming, these numbers will tell you what data type you can work with.

• In images, these numbers can tell you the limits of your dimensions and limits of the number of “colors” you can have.

Page 18: 1 Winter Quarter 2003Rolando V. Raqueño FINAL Project Information One Design Review presentations (10 minutes long) A Final Document of your Project Wiki.

Winter Quarter 2003 Rolando V. Raqueño 1818

1-bit Address Line and 1-bit Data Line

Computer Architecture

CPU

01

ADDRESS BUS

DATA BUS

MEMORY

Page 19: 1 Winter Quarter 2003Rolando V. Raqueño FINAL Project Information One Design Review presentations (10 minutes long) A Final Document of your Project Wiki.

Winter Quarter 2003 Rolando V. Raqueño 1919

2-bit Address Line and 1-bit Data Line

Computer Architecture

CPU

01

ADDRESS BUS

DATA BUS

MEMORY

23

Page 20: 1 Winter Quarter 2003Rolando V. Raqueño FINAL Project Information One Design Review presentations (10 minutes long) A Final Document of your Project Wiki.

Winter Quarter 2003 Rolando V. Raqueño 2020

1-bit Address Line and 2-bit Data Line

Computer Architecture

CPU

01

ADDRESS BUS

DATA BUS

MEMORY

Page 21: 1 Winter Quarter 2003Rolando V. Raqueño FINAL Project Information One Design Review presentations (10 minutes long) A Final Document of your Project Wiki.

Winter Quarter 2003 Rolando V. Raqueño 2121

2-bit Address Line and 2-bit Data Line

Computer Architecture

ADDRESS BUS

DATA BUS

23

MEMORY

CPU

01

Page 22: 1 Winter Quarter 2003Rolando V. Raqueño FINAL Project Information One Design Review presentations (10 minutes long) A Final Document of your Project Wiki.

Winter Quarter 2003 Rolando V. Raqueño 2222

8-bit Address Line and 8-bit Data Line Computer

Architecture

CPU

0123...

255

.

.

.ADDRESS BUS

DATA BUS

MEMORY

Page 23: 1 Winter Quarter 2003Rolando V. Raqueño FINAL Project Information One Design Review presentations (10 minutes long) A Final Document of your Project Wiki.

Winter Quarter 2003 Rolando V. Raqueño 2323

In General• If you have n-bits of addressing, you can access 2 addresses ranging from 0 to 2 -1

n

n

• If you have n-bits of data, you can have 2 states foryour data.

n

• For images, the number of bits per picture element (pixel) will determine how many “colors” an image can represent.

bilevel image has 1 bit per pixel giving 2 “colors”

grey level image has n bits per pixel giving 2^n “colors”

RGB color image has 3 bands with n bits per bandgiving 2^(3n) “colors”

Multispectral images has m bands with n bits per band

Page 24: 1 Winter Quarter 2003Rolando V. Raqueño FINAL Project Information One Design Review presentations (10 minutes long) A Final Document of your Project Wiki.

Winter Quarter 2003 Rolando V. Raqueño 2424

Caveat on Multi-Byte Data

• When dealing with data that encompasses more than a single byte (e.g. integer value greater than 255), you must know the “endian” of the data

• Endian represents how a machine interprets the significance of a set of bytes.

• There are big-endian machines and little endian machines

Page 25: 1 Winter Quarter 2003Rolando V. Raqueño FINAL Project Information One Design Review presentations (10 minutes long) A Final Document of your Project Wiki.

Winter Quarter 2003 Rolando V. Raqueño 2525

Caveat on Multi-Byte Data

• Big Endian Machines (Suns, Motorolas) would represent the integer value 512 internally as two bytes in the following order.

MSB LSB

00000010 00000000

Page 26: 1 Winter Quarter 2003Rolando V. Raqueño FINAL Project Information One Design Review presentations (10 minutes long) A Final Document of your Project Wiki.

Winter Quarter 2003 Rolando V. Raqueño 2626

Caveat on Multi-Byte Data

• Little Endian Machines (DECS, Intels) would represent the integer value 512 internally as two bytes in the following order.

LSB MSB

00000000 00000010

Page 27: 1 Winter Quarter 2003Rolando V. Raqueño FINAL Project Information One Design Review presentations (10 minutes long) A Final Document of your Project Wiki.

Winter Quarter 2003 Rolando V. Raqueño 2727

Caveat on Multi-Byte Data• This is typically not a problem as long as you

stay on the same machine. • If you, however, start transferring data (e.g.

images) in raw form from one machine to another, you will need to be aware of this situation.

• You can often transpose multibyte data using the dd utility (does not work for data spanning more than two bytes)

Page 28: 1 Winter Quarter 2003Rolando V. Raqueño FINAL Project Information One Design Review presentations (10 minutes long) A Final Document of your Project Wiki.

Winter Quarter 2003 Rolando V. Raqueño 2828

Working with IDL Variables

• Variable names must start with a letter but can include, letters, digits, underscore or dollar characters.

• Variables are not case sensitive, i.e.,– Celsius is equivalent to celsius

Page 29: 1 Winter Quarter 2003Rolando V. Raqueño FINAL Project Information One Design Review presentations (10 minutes long) A Final Document of your Project Wiki.

Winter Quarter 2003 Rolando V. Raqueño 2929

Working with IDL Variables

• Variables in IDL have two important attributes– Data type– Attributes

Page 30: 1 Winter Quarter 2003Rolando V. Raqueño FINAL Project Information One Design Review presentations (10 minutes long) A Final Document of your Project Wiki.

Winter Quarter 2003 Rolando V. Raqueño 3030

IDL Variable Data Types

• Undefined• Integer Values

– Byte, Integer, Long Integer

• Floating Point Values– Floating Point, Double Precision– Single Precision Complex, Double

Precision Complex

• String

Page 31: 1 Winter Quarter 2003Rolando V. Raqueño FINAL Project Information One Design Review presentations (10 minutes long) A Final Document of your Project Wiki.

Winter Quarter 2003 Rolando V. Raqueño 3131

IDL Variable Data Structures

• Scalar

• Vector (one-dimensional array)

• Array (up to eight dimensions)

• Structure (combination of any mixture of data - Very Important in understanding Object-Oriented Programming Concepts)

Page 32: 1 Winter Quarter 2003Rolando V. Raqueño FINAL Project Information One Design Review presentations (10 minutes long) A Final Document of your Project Wiki.

Winter Quarter 2003 Rolando V. Raqueño 3232

Initializing Scalar Variables• byte_variable = 0B• integer_variable = 0• long_integer = 0L• float_variable = 0.0• double_variable = 0.0D• complex_variable = Complex(0.0, 0.0)• dcomplex_variable = DComplex(0.0, 0.0)• string_variable = ‘‘

Page 33: 1 Winter Quarter 2003Rolando V. Raqueño FINAL Project Information One Design Review presentations (10 minutes long) A Final Document of your Project Wiki.

Winter Quarter 2003 Rolando V. Raqueño 3333

Initializing Array Variables• byte_array = bytarr( 256, 256, 3 )• integer_array = intarr( 256, 256 )• long_array = lonarr( 256, 256 )• float_array = fltarr( 256, 256 )• double_array = dblarr( 256, 256 )• complex_array = complexarr( 256, 256 )• dcomplex_array = dcomplexarr( 256, 256)• string_array = strarr(80)

Page 34: 1 Winter Quarter 2003Rolando V. Raqueño FINAL Project Information One Design Review presentations (10 minutes long) A Final Document of your Project Wiki.

Winter Quarter 2003 Rolando V. Raqueño 3434

Initializing Array Variables

• Initializing Array with each element set to its subscript– bindgen, indgen, lindgen, findgen, dindgen,

cindgen, dcindgen, sindgen– Only real parts of complex numbers are set

to the subscripts– An array of strings containing the numbers

is created by sindgen

Page 35: 1 Winter Quarter 2003Rolando V. Raqueño FINAL Project Information One Design Review presentations (10 minutes long) A Final Document of your Project Wiki.

Winter Quarter 2003 Rolando V. Raqueño 3535

Initializing Array Variables

• Make_array function is a general way of creating and initializing arraysarray=make_array(10,12,Value=1,/Int)

• Replicate functions allows initialization of all elements of an array with a given variable (useful in structures)initial_value = 1array=replicate(initial_value, 10,12)

Page 36: 1 Winter Quarter 2003Rolando V. Raqueño FINAL Project Information One Design Review presentations (10 minutes long) A Final Document of your Project Wiki.

Winter Quarter 2003 Rolando V. Raqueño 3636

Structures in IDL

• Allows more abstract data types to be created from other basic data types

• Example– Date data structure

IDL> a={date, month:0B, day:0B, year:0B}

IDL> print,a

{ 0 0 0}

Page 37: 1 Winter Quarter 2003Rolando V. Raqueño FINAL Project Information One Design Review presentations (10 minutes long) A Final Document of your Project Wiki.

Winter Quarter 2003 Rolando V. Raqueño 3737

Structures in IDL• Date Example (using a Named Structure)

IDL> a.month=12IDL> a.day=25IDL> a.year=96IDL> print,a{ 12 25 96}IDL> print,a.month 12IDL> print,a.day 25IDL> print,a.year 96

Page 38: 1 Winter Quarter 2003Rolando V. Raqueño FINAL Project Information One Design Review presentations (10 minutes long) A Final Document of your Project Wiki.

Winter Quarter 2003 Rolando V. Raqueño 3838

Structures in IDL

• Date Structure ExampleIDL> c={date}

IDL> print,c

{ 0 0 0}

IDL> help,c

C STRUCT = -> DATE Array(1)

Page 39: 1 Winter Quarter 2003Rolando V. Raqueño FINAL Project Information One Design Review presentations (10 minutes long) A Final Document of your Project Wiki.

Winter Quarter 2003 Rolando V. Raqueño 3939

Structures in IDL

• Anonymous StructuresIDL> d={month:1,day:1,year:97}

IDL> print,d

{ 1 1 97}

IDL> e=d

IDL> print,e

{ 1 1 97}

Page 40: 1 Winter Quarter 2003Rolando V. Raqueño FINAL Project Information One Design Review presentations (10 minutes long) A Final Document of your Project Wiki.

Winter Quarter 2003 Rolando V. Raqueño 4040

Structures in IDL

• Anonymous StructuresIDL>

e={month:'January',day:d.day,year:d.year}

IDL> print,e

{ January 1 97}

IDL> e.month='December'

IDL> print,e

{ December 1 97}

Page 41: 1 Winter Quarter 2003Rolando V. Raqueño FINAL Project Information One Design Review presentations (10 minutes long) A Final Document of your Project Wiki.

Winter Quarter 2003 Rolando V. Raqueño 4141

Structures in IDL

• Determining Variable StructureIDL> help,e,/structure

** Structure <761058>, 3 tags, length=12, refs=1:

MONTH STRING 'December'

DAY INT 1

YEAR INT 97

Page 42: 1 Winter Quarter 2003Rolando V. Raqueño FINAL Project Information One Design Review presentations (10 minutes long) A Final Document of your Project Wiki.

Winter Quarter 2003 Rolando V. Raqueño 4242

Structures in IDL

• Determining Structure CharacteristicsIDL> print,n_tags(e)

3

IDL> print,tag_names(e)

MONTH DAY YEAR

Page 43: 1 Winter Quarter 2003Rolando V. Raqueño FINAL Project Information One Design Review presentations (10 minutes long) A Final Document of your Project Wiki.

Winter Quarter 2003 Rolando V. Raqueño 4343

Dual Nature of IDL structures

IDL> e={month:"December", day:1, year:97}

IDL> print,e.month

December

IDL> print,e.day

1

IDL> print,e.year

97

IDL> e={month:"December", day:1, year:97}

IDL> print,e.(0)

December

IDL> print,e.(1)

1

IDL> print,e.(2)

97

Page 44: 1 Winter Quarter 2003Rolando V. Raqueño FINAL Project Information One Design Review presentations (10 minutes long) A Final Document of your Project Wiki.

Winter Quarter 2003 Rolando V. Raqueño 4444

Array Manipulation in IDL

• Let’s create an array representing a multiband imageIDL> image=bindgen(2,3,4)

IDL> print,image 0 1 2 3 4 5

6 7 8 9 10 11

12 13 14 15 16 17

18 19 20 21 22 23

Page 45: 1 Winter Quarter 2003Rolando V. Raqueño FINAL Project Information One Design Review presentations (10 minutes long) A Final Document of your Project Wiki.

Winter Quarter 2003 Rolando V. Raqueño 4545

Array Manipulation in IDL• Extract the first and last band of the image

IDL> print,image(*,*,0)

0 1

2 3

4 5

IDL> print,image(*,*,3)

18 19

20 21

22 23

Page 46: 1 Winter Quarter 2003Rolando V. Raqueño FINAL Project Information One Design Review presentations (10 minutes long) A Final Document of your Project Wiki.

Winter Quarter 2003 Rolando V. Raqueño 4646

Array Manipulation in IDL

• Extracting the “color” or “spectral vector” of the first pixelIDL> print,image(0,0,*)

0

6

12

18

Page 47: 1 Winter Quarter 2003Rolando V. Raqueño FINAL Project Information One Design Review presentations (10 minutes long) A Final Document of your Project Wiki.

Winter Quarter 2003 Rolando V. Raqueño 4747

Array Manipulation in IDL

• Assign band 1 to band 4IDL> band1=image(*,*,0)

IDL> image(*,*,3) = band1

• ShortcutIDL> image(*,*,3)=image(*,*,0)

Page 48: 1 Winter Quarter 2003Rolando V. Raqueño FINAL Project Information One Design Review presentations (10 minutes long) A Final Document of your Project Wiki.

Winter Quarter 2003 Rolando V. Raqueño 4848

Array Manipulation in IDL• Subsectioning parts of an image

IDL> print,image(0:1,0:1,*) 0 1 2 3

6 7 8 9

12 13 14 15

0 1 2 3

Page 49: 1 Winter Quarter 2003Rolando V. Raqueño FINAL Project Information One Design Review presentations (10 minutes long) A Final Document of your Project Wiki.

Winter Quarter 2003 Rolando V. Raqueño 4949

Array Manipulation

• where function to find indices of elements that meet certain criteriaIDL> print, where( image gt 5 and image lt 12)

• Use of other arrays to index other arraysIDL> indices=where( image gt 5 and image lt 12)

IDL> image(indices)=-1