Title: Quiz
1Quiz 6 Topics
2Numbering Systems
3Converting Between Bases
- 42 base 10 converted to base 10,
- 42 base 10 converted to base 8,
4Converting Between Bases
- 42 base 10 converted to base 2,
- 42 base 10 converted to base 16,
5Number Base Conversion using bc
- To convert decimal to binary
- obase2
- 42
- 101010
- To convert octal to hexadecimal
- obase16
- ibase8
- 52
- 2A
6Negative Number Representation
7Converting a Negative Number into Binary using
2s Complement
- To convert -42 into a negative binary value
- Determine the number of bits to represent (e.g.
16 bits) - Convert the absolute value (42) into binary
- 0000000000101010
- Take the 1s complement of the number
- 1111111111010101
- Add 1 to the number
- 1111111111010110
8Floating Point Representation
- Sets of bits are separated into
- mantissa
- exponent field
9Another Example of Unformatted Output (e.pro)
- pro e
- openw, lun, 'e.dat', /get_lun
- e exp(1.0)
- writeu,lun, e
- free_lun, lun
- end
10Octal Interpretation of e.dat (big endian)
- od -b e.dat
- 0000000 100 055 370 124
- 0000004
11Binary Interpretation of e.dat (big endian)
- bc -l
- obase2
- ibase8
- 100
- 1000000
- 55
- 101101
- 370
- 11111000
- 124
- 1010100
12Binary Interpretation of e.dat (big endian)
- 01000000 00101101 11111000 01010100
13(SINGLE PRECISION) - IEEE (ANSI/IEEE Std
754-1985)
- --------------------------------
- S exp fraction
- --------------------------------
-
- Bit31 Bit0
- A formula that gives the value of this float is
- Value(-1)S X 1.fraction X 2(exp-127)
-
14Binary Interpretation of e.dat (big endian)
- 01000000 00101101 11111000 01010100
- Bit 31
- S 0
- Bits 3023
- exp 1000000 0 128 (decimal)
- Bits 220
- fraction 0101101 11111000 01010100
15(SINGLE PRECISION) - IEEE (ANSI/IEEE Std
754-1985)
- Value(-1)S X 1.fraction X 2(exp-127)
- 2(128-127) 2
- bc -l
- ibase2
- 1.0101101 11111000 01010100
- 1.35914087295532226562500
- ibase1010
- 21.35914087295532226562500
- 2.71828174591064453125000
16Floating Point Interpretation of e.dat (big
endian)
- od -f e.dat
- 0000000 2.7182817e00
- 0000004
17Debugging in IDL
18Basic IDL Debugging Commands
- breakpoint
- .step (.s)
- .stepover (.so)
- .continue
- .return
- .out
19mean.pro
- 10 -
- 11
- 12 function mean,x
- 13 n n_elements(x)
- 14 answer sum(x)/double(n)
- 15 return, answer
- 16 end
20Breakpoints
- IDLgt breakpoint, mean.pro, 12
- IDLgt help,/breakpoint
- Breakpoints
- Index Module Line File
- ----- ------ ---- ----
- 0 MEAN 12 mean.pro
- IDLgt breakpoint, /clear, 0
- OR
- IDLgt breakpoint, /clear, mean.pro, 12
21.step
- Used after a breakpoint is reached
- Single step through commands
- If statement is a function or procedure
- Will enter into it
22.stepover
- Similar to .step
- Executes functions and procedures to completion
without stopping inside the function
23.return
- Continues execution until a return statement is
encountered. - Useful in checking the return value of an inner
(nested) function in a function composition - e.g.
- sqrt(variance(x))
24.out
- Continues execution out of the current routine.
- Useful in leaving a routine that you stepped
into, but have determined that all is working
properly and want to return to the calling
routine.
25mean.pro
- 10 -
- 11
- 12 function mean,x
- 13 n n_elements(x)
- 14 answer sum(x)/double(n)
- 15 return, answer
- 16 end
26Mystery Images
27Given an image of unknown origin
- Dimensions of the image?
- Most importantly the number of samples
- Aspect ratio of the image?
- Number of bytes per pixel?
- Number of bands of the image?
- Number of bits per pixel?
- External or internal compression applied
- gzip
- tiff or jpeg
28Know the imaging instrument
- Find out what kind of image capture device
- Framing Camera with filters
- Band Sequential Images (BSQ)
- Flatbed of Pushbroom scanner
- Band interleaved by line (BIL)
- Line Scanner
- Band interleaved by pixel (BIP)
29Tools at your disposal for dissecting the image
- file
- anytopnm
- more
- ls -l
- bc -l
- od
- dd
- strings
- rawtopgm or cat
- xv
30file
- Uses information in /etc/magic to determine the
type of a file. - Common outputs from the file command
- file irod.img.gz
- irod.img.gz gzip compressed data - deflate
method , original file name , max compression - file readme
- readme ascii text
31File (more examples)
- file RIT_bip.img
- RIT_bip.img data
- file modtran4.bat
- modtran4.bat executable c-shell script
- bean file maincode.exe
- maincode.exe ELF 32-bit MSB executable SPARC
Version 1, dynamically linked, not stripped
32File (image examples)Dont always believe the
extensions
- bean file feep.tif
- feep.tif TIFF file, big-endian
- bean file feep.pgm
- feep.pgm PGM ascii file
- bean file AVIRIS_RIT.jpg
- AVIRIS_RIT.jpg JPEG file
- bean file rotate.pbm
- rotate.pbm PGM raw file
33anytopnm
- Shell script that does a brute force test on
images and converts to pnm format - anytopnm mystery_file gt mystery_file.pnm
34od
- Can be used to quickly check the minimum and
maximum values in a file - Stupid UNIX Trick
- od d v image.raw cut c10- tr s
\012 sort nu head
35Xv and NetPBM
- Xv want multi-byte NetPBM files in little-endian
form - N.B. NetPBM utilities behave inconsistently for
multi-byte data
36Can you guess the dimensions of the image?
- Try to guess the number of rows (width) first.
- Possible guesses
- 256
- 512
- 2n
- 2n2(n-1)
37Can you guess the aspect ratio of the image?
- wc -c or ls -l
- determine how many bytes are in the image
- Square root of the image size
- Multiple of a perfect square
- Assume that the image is greyscale square
- use rawtopgm
- rawtopgm 512 512 image.raw gt image.pgm
38Square Gray Scale Image
- Used rawtopgm to create a pgm file and then use
xv to display
39A convenient little trick
- If you are just experimenting with a mystery
image - rawtopgm 512 512 image.raw xv -
40Does it have a header?
- Not a perfect square
- go ahead and try to display it as if it were a
square image to see if it has a header.
41Square Grey Scale image with a header
- This structure means you have a header in the
file that is causing a uniform shift - You can fix this by using dd
42Square image no header
- Your guess on the width of the image is short by
one pixel
43Square image no header
- Your guess on the width of the image is long by
one pixel
44Square image no header
- You probably guessed a little too low on the
width of this image - (off by 6 pixels)
45Square Image with no header
- Your probably guessed a little too high on the
width of the image - (off by 6 pixels)
46A color image displayed as greyscale image
- Correct dimensions
- 256x256x3 BIP
- Incorrectly assumed
- 443x443 image with header
- N.B.
- 196608/32562
- Indicates a multiband image
47Multiband Assumption
- Once multiband image is assumed
- Need to determine interleaving
- Can be deduced by displaying first band
- This assumes you have a guess of image dimension
- Extract the first band out using dd
48First band of color image file assumed to be BSQ
- Assume a square image for first band
- Color image file obviously not BSQ
49Square color image displayed as a greyscale (31
aspect ratio)
- Original image
- 3x256x256
- Displayed it as a greyscale
- 768x256
- To get insight into interleaving structure.
- BIP file would look like the left image
50Square color image displayed as greyscale( 31
aspect ratio)
- This is how a BIL image would behave
- What we have here is the individual bands side by
side
51Square color image displayed as greyscale( 31
aspect ratio)
- This is how a BSQ file would behave
52Multibyte pixel image
- Need to be careful about the endian of the
machine on which the image was written - Can use dd to swap bytes for short integer images
(2-bytes per pixel) or the swap_endian function
in IDL
53Mystery Image Examples
- Check Webpage for sources of examples.
- An example will be given for the midterm exam.