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

52
Winter Quarter 2003 Rolando V. Raqueño 1 1 FINAL Project Information • Two Design Review presentations (10-15 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 Two Design Review presentations...

Winter Quarter 2003 Rolando V. Raqueño 11

FINAL Project Information

• Two Design Review presentations (10-15 minutes long)

• A Final Document of your Project

• Wiki Page Describing your Project– YourNameIdlGuiProject

• Teaming is Encouraged– LastNamesIdlGuiProject

Winter Quarter 2003 Rolando V. Raqueño 22

Final Project

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

Winter Quarter 2003 Rolando V. Raqueño 33

Possible Project Choices• http://www.cis.rit.edu/rolo/teaching/simg726/project_archive/project_archive.html– Visualization of a DIRSIG Geometric Database– Visualization and modification of radiosonde data– Graphical User Interface for generating and

modifying a MODTRAN Card deck– Visualiation of radiance data– GUI for generating and modifying object material

parameters– GUI for visualizing emissivity files

Winter Quarter 2003 Rolando V. Raqueño 44

Possible Project Choices

– GUI for texture image creation– Visualization and modification of a scene

node file.– More Details to come...

Winter Quarter 2003 Rolando V. Raqueño 55

Quiz #2 (After Break) Topics

• RCS commands

• cd

• cp

• grep

• chmod

• Weekly wiki post

• The Cuckoo’s Egg Question

Winter Quarter 2003 Rolando V. Raqueño 66

Working with Data

Winter Quarter 2003 Rolando V. Raqueño 77

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)

Winter Quarter 2003 Rolando V. Raqueño 88

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.

Winter Quarter 2003 Rolando V. Raqueño 99

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

Winter Quarter 2003 Rolando V. Raqueño 1010

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.

Winter Quarter 2003 Rolando V. Raqueño 1111

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

Winter Quarter 2003 Rolando V. Raqueño 1212

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

Winter Quarter 2003 Rolando V. Raqueño 1313

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

Winter Quarter 2003 Rolando V. Raqueño 1414

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.

Winter Quarter 2003 Rolando V. Raqueño 1515

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

Winter Quarter 2003 Rolando V. Raqueño 1616

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

Winter Quarter 2003 Rolando V. Raqueño 1717

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

Winter Quarter 2003 Rolando V. Raqueño 1818

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

Winter Quarter 2003 Rolando V. Raqueño 1919

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

Winter Quarter 2003 Rolando V. Raqueño 2020

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.

Winter Quarter 2003 Rolando V. Raqueño 2121

1-bit Address Line and 1-bit Data Line

Computer Architecture

CPU

01

ADDRESS BUS

DATA BUS

MEMORY

Winter Quarter 2003 Rolando V. Raqueño 2222

2-bit Address Line and 1-bit Data Line

Computer Architecture

CPU

01

ADDRESS BUS

DATA BUS

MEMORY

23

Winter Quarter 2003 Rolando V. Raqueño 2323

1-bit Address Line and 2-bit Data Line

Computer Architecture

CPU

01

ADDRESS BUS

DATA BUS

MEMORY

Winter Quarter 2003 Rolando V. Raqueño 2424

2-bit Address Line and 2-bit Data Line

Computer Architecture

ADDRESS BUS

DATA BUS

23

MEMORY

CPU

01

Winter Quarter 2003 Rolando V. Raqueño 2525

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

Architecture

CPU

0123...

255

.

.

.ADDRESS BUS

DATA BUS

MEMORY

Winter Quarter 2003 Rolando V. Raqueño 2626

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

Winter Quarter 2003 Rolando V. Raqueño 2727

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

Winter Quarter 2003 Rolando V. Raqueño 2828

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

Winter Quarter 2003 Rolando V. Raqueño 2929

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

Winter Quarter 2003 Rolando V. Raqueño 3030

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)

Winter Quarter 2003 Rolando V. Raqueño 3131

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

Winter Quarter 2003 Rolando V. Raqueño 3232

Working with IDL Variables

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

Winter Quarter 2003 Rolando V. Raqueño 3333

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

Winter Quarter 2003 Rolando V. Raqueño 3434

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)

Winter Quarter 2003 Rolando V. Raqueño 3535

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 = ‘‘

Winter Quarter 2003 Rolando V. Raqueño 3636

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)

Winter Quarter 2003 Rolando V. Raqueño 3737

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

Winter Quarter 2003 Rolando V. Raqueño 3838

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)

Winter Quarter 2003 Rolando V. Raqueño 3939

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}

Winter Quarter 2003 Rolando V. Raqueño 4040

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

Winter Quarter 2003 Rolando V. Raqueño 4141

Structures in IDL

• Date Structure ExampleIDL> c={date}

IDL> print,c

{ 0 0 0}

IDL> help,c

C STRUCT = -> DATE Array(1)

Winter Quarter 2003 Rolando V. Raqueño 4242

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}

Winter Quarter 2003 Rolando V. Raqueño 4343

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}

Winter Quarter 2003 Rolando V. Raqueño 4444

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

Winter Quarter 2003 Rolando V. Raqueño 4545

Structures in IDL

• Determining Structure CharacteristicsIDL> print,n_tags(e)

3

IDL> print,tag_names(e)

MONTH DAY YEAR

Winter Quarter 2003 Rolando V. Raqueño 4646

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

Winter Quarter 2003 Rolando V. Raqueño 4747

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

Winter Quarter 2003 Rolando V. Raqueño 4848

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

Winter Quarter 2003 Rolando V. Raqueño 4949

Array Manipulation in IDL

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

0

6

12

18

Winter Quarter 2003 Rolando V. Raqueño 5050

Array Manipulation in IDL

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

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

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

Winter Quarter 2003 Rolando V. Raqueño 5151

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

Winter Quarter 2003 Rolando V. Raqueño 5252

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