![Page 1: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/1.jpg)
Winter Quarter 2003 Rolando V. Raqueño 11
Twas the Lecture Before Holiday Break
Readings
Present
Makefiles
Image Array Manipulation and I/O
Simple Widget Programs
![Page 2: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/2.jpg)
Winter Quarter 2003 Rolando V. Raqueño 22
First Project and Final Project Abstract
• Due today
• Please hand in something before break– Hardcopy for First Project– Wiki posting for Final Project Abstract
• Resubmissions of both will be accepted after break
![Page 3: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/3.jpg)
Winter Quarter 2003 Rolando V. Raqueño 33
Holiday Reading
• The Cuckoo’s Egg (Gift Quiz Material)– QUIZ about the book when we come back
References for doing homework and final project• Gumley Chapters
– 2, 3.1-3.2,4.1-4.4 (programming)– 7.1-7.5 (displaying images)– 9.1-9.3 (GUI programming)
• UNIX Power Tools Chapters– 48-51
![Page 4: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/4.jpg)
Winter Quarter 2003 Rolando V. Raqueño 44
netpbm.tgz
netpbm.tgzThis is the package that contains the entire PBMPLUS (also known as netpbm) and is distributed in a format known as
Compressed TAR File or
gzipped TAR file
![Page 5: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/5.jpg)
Winter Quarter 2003 Rolando V. Raqueño 55
present.tgz
• To illustrate how to process these types of files, there is a file called simpler file (present.tgz) which can be accessed via anonymous ftp from
% ftp ftp.cis.rit.edu
![Page 6: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/6.jpg)
Winter Quarter 2003 Rolando V. Raqueño 66
Anonymous ftp session login
% ftp ftp.cis.rit.edu
Name (ftp.cis.rit.edu:rvrpci): anonymous
331 Guest login ok, send your complete e-mail address as password.
Password:
![Page 7: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/7.jpg)
Winter Quarter 2003 Rolando V. Raqueño 77
Most important ftp command
ftp> ?
![Page 8: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/8.jpg)
Winter Quarter 2003 Rolando V. Raqueño 88
ftp session change directory
ftp> cd people/rolo/simg726250 "/people/rolo/simg726" is new cwd.ftp> ls200 PORT command successful.150 Opening ASCII mode data connection for /bin/ls.
Makefile_example.tgzfortran_stats.tgzpresent.tgz226 Listing completed.54 bytes received in 0.015 seconds (3.50 Kbytes/s)
![Page 9: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/9.jpg)
Winter Quarter 2003 Rolando V. Raqueño 99
ftp file transfer type
ftp> ascii
200 Type okay.
ftp> binary
200 Type okay.
![Page 10: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/10.jpg)
Winter Quarter 2003 Rolando V. Raqueño 1010
ftp getting a single file
ftp> get present.tgz
200 PORT command successful.
150 Opening ASCII mode data connection for present.tgz (1211 bytes).
226 Transfer completed.
local: present.tgz remote: present.tgz
1219 bytes received in 0.015 seconds (80.45 Kbytes/s)
![Page 11: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/11.jpg)
Winter Quarter 2003 Rolando V. Raqueño 1111
Getting multiple files
ftp> promptInteractive mode off.ftp> hashHash mark printing on (8192 bytes/hash mark).
ftp> mget *.tgz200 PORT command successful.150 Opening ASCII mode data connection for Makefile_example.tgz (31544 bytes).
##
![Page 12: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/12.jpg)
Winter Quarter 2003 Rolando V. Raqueño 1212
Getting out of ftp
ftp> quit
221 Goodbye.
![Page 13: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/13.jpg)
Winter Quarter 2003 Rolando V. Raqueño 1313
Most common ftp mistake
• Sending a binary file under ASCII mode
• Result– Characters not conforming to the ASCII
character set are removed
• ALWAYS– Check the size of the source file and the
transferred file
![Page 14: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/14.jpg)
Winter Quarter 2003 Rolando V. Raqueño 1414
Uncompressing and UnTAR
• To uncompress the file% gunzip present.tgz
• To extract the contents of the tar file% tar xvf present.tar
• Challenge - look at the file xmas.c and figure out what it does% cd present% more xmas.c
![Page 15: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/15.jpg)
Winter Quarter 2003 Rolando V. Raqueño 1515
Compiling the Package
• To compile or build the package, a Makefile is typically present which is an automatic mechanism to compile all the files and place them in the proper locations% make
• To run the program% ./xmas
![Page 16: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/16.jpg)
Winter Quarter 2003 Rolando V. Raqueño 1616
What is a Makefile
• A makefile is a description of how to build “things” in UNIX
• Automates the creation of “stuff”
• It is different from a script or batch file– Describes the relationship of components
to the resulting object– Keeps track of intermediate results and
their age
![Page 17: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/17.jpg)
Winter Quarter 2003 Rolando V. Raqueño 1717
Other Makefile examples
• Makefile_example.tgz• Fortran_stats.tgz
![Page 18: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/18.jpg)
Winter Quarter 2003 Rolando V. Raqueño 1818
Makefile_example
• Take a raw file -> convert to pgm image
• Take pgm image -> rotate image
• Take rotated image -> label image
• Makefiles work on file dependencies
![Page 19: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/19.jpg)
Winter Quarter 2003 Rolando V. Raqueño 1919
[Mm]akefile% more MakefileMyCat_labeled.pgm : MyCat_rotated.pgm label.dat ppmlabel -x 0 -y 200 -file label.dat
MyCat_rotated.pgm > MyCat_labeled.pgm
MyCat_rotated.pgm : MyCat.pgm pnmrotate 45 MyCat.pgm > MyCat_rotated.pgm
MyCat.pgm : MyCat.raw rawtopgm 256 256 MyCat.raw > MyCat.pgm
clean: rm MyCat_labeled.pgm MyCat_rotated.pgm MyCat.pgm
![Page 20: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/20.jpg)
Winter Quarter 2003 Rolando V. Raqueño 2020
If a file is out of date…
• If you edit a file and update it, the makefile will know
• Example– Edit label.dat to some other new text– Type make again– Look at the image
![Page 21: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/21.jpg)
Winter Quarter 2003 Rolando V. Raqueño 2121
Fortran_stats example
• Compile a fortran program that computes the mean of 1,2,3,4,5
• To compile the program% make
• To run the program% stats
![Page 22: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/22.jpg)
Winter Quarter 2003 Rolando V. Raqueño 2222
Fortran_stats
% more Makefilestats : main.o sum.o mean.o g77 -o stats main.o sum.o mean.o main.o : main.f g77 -c main.fsum.o : sum.f g77 -c sum.fmean.o : mean.f g77 -c mean.fclean: rm *.o
![Page 23: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/23.jpg)
Winter Quarter 2003 Rolando V. Raqueño 2323
Fortran_stats% more MakefileFORTRAN = g77stats : main.o sum.o mean.o $(FORTRAN) -o stats main.o sum.o mean.o main.o : main.f $(FORTRAN) -c main.fsum.o : sum.f $(FORTRAN) -c sum.fmean.o : mean.f $(FORTRAN) -c mean.fclean: rm *.o
![Page 24: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/24.jpg)
Winter Quarter 2003 Rolando V. Raqueño 2424
Typical unreadable makefile
% more makefileFORTRAN = g77OBJS = main.o mean.o sum.o.f.o: $(FORTRAN) -c $*.fstats: $(OBJS) $(FORTRAN) -o stats $(OBJS)clean: rm *.o
![Page 25: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/25.jpg)
Winter Quarter 2003 Rolando V. Raqueño 2525
Reading & Writing Data Files in IDL
![Page 26: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/26.jpg)
Winter Quarter 2003 Rolando V. Raqueño 2626
Reading & Writing Data Files
• IDL can read many types of file formats
• Files can be categorized into two general types– Formatted ( Readable Text & Numbers,
ASCII)– Unformatted( Images)
![Page 27: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/27.jpg)
Winter Quarter 2003 Rolando V. Raqueño 2727
Reading & Writing Data Files
• The three IDL commands we can use for opening files are as follows
openr (open a file for reading)
openw (open a file for writing)
openu (open a file for reading/writing)
![Page 28: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/28.jpg)
Winter Quarter 2003 Rolando V. Raqueño 2828
sample_data_1.dat
0 1
2 3
4 5
6 7
8 9
10 11
![Page 29: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/29.jpg)
Winter Quarter 2003 Rolando V. Raqueño 2929
Syntax for Opening Data Files
• Example command for opening a file for inputIDL> openr, 1, ‘sample_data_1.dat’
– The argument 1 is referred to as the logical unit number (also known as a file handle)
‘sample_data_1.dat’ is the input file name
![Page 30: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/30.jpg)
Winter Quarter 2003 Rolando V. Raqueño 3030
Reading the Data
• Need to allocate the array to read in the dataIDL> a=fltarr( 12)
ORIDL> a=fltarr( 2, 6)
• Read in the data using the readf statementIDL> readf, 1, a
![Page 31: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/31.jpg)
Winter Quarter 2003 Rolando V. Raqueño 3131
Closing the Data File
• To close the data file you can give the following commandIDL> close, 1
• A common mistake is to try to open a file(s) that is already open causing the error
% OPENR: File unit is already open: 1.% Execution halted at $MAIN$ (OPENR)• Solution
IDL> close, /all
![Page 32: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/32.jpg)
Winter Quarter 2003 Rolando V. Raqueño 3232
Putting it all together
IDL> openr, 1, ‘sample_data_1.dat’
IDL> a = fltarr( 2,12)
IDL> readf, 1, a
IDL> close, 1
IDL> print, a
![Page 33: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/33.jpg)
Winter Quarter 2003 Rolando V. Raqueño 3333
Another Way of Reading in a File
IDL> openr, lun, ‘sample_data_1.dat’, $
/get_lun
IDL> a = fltarr( 2, 6 )
IDL> readf, lun, a
IDL> free_lun, lun
IDL> print, a
![Page 34: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/34.jpg)
Winter Quarter 2003 Rolando V. Raqueño 3434
Yet Another Way
IDL> file_name = ‘sample_data_1.dat’
IDL> a = fltarr( 2, 6 )
IDL> openr, lun, file_name, /get_lun
IDL> readf, lun, a
IDL> free_lun, lun
IDL> print, a
![Page 35: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/35.jpg)
Winter Quarter 2003 Rolando V. Raqueño 3535
To Output a Formatted FileIDL> b = bindgen( 3, 2)*10+42
IDL> openw, lun, ‘test_output.dat’, $
/get_lun
IDL> printf, lun, b
IDL> free_lun, lun
![Page 36: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/36.jpg)
Winter Quarter 2003 Rolando V. Raqueño 3636
test_output.dat
42 52 62
72 82 92
![Page 37: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/37.jpg)
Winter Quarter 2003 Rolando V. Raqueño 3737
To Output an Unformatted File
IDL> b = bindgen( 3, 2)*10+42
IDL> openw, lun, ‘test_output.dat’,$
/get_lun
IDL> writeu, lun, b
IDL> free_lun, lun
![Page 38: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/38.jpg)
Winter Quarter 2003 Rolando V. Raqueño 3838
test_output.dat*4>HR\
• Why? Because ...
* - has an ASCII value of 42 decimal
4 - has an ASCII value of 52 decimal
> - has an ASCII value of 62 decimal
H - has an ASCII value of 72 decimal
R - has an ASCII value of 82 decimal
\ - has an ASCII value of 92 decimal
![Page 39: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/39.jpg)
Winter Quarter 2003 Rolando V. Raqueño 3939
test_P2_image.pgm
P2
3 2
255
42 52
62 72
82 92
![Page 40: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/40.jpg)
Winter Quarter 2003 Rolando V. Raqueño 4040
test_P5_image.pgm
P5
3 2
255
*4>HR\
![Page 41: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/41.jpg)
Winter Quarter 2003 Rolando V. Raqueño 4141
Testing Out Your or Somebody Else’s Image I/O Routines
• Read in a small test image
IDL> a=Read_P2_Image(“test_input.pgm”)• Write out the small test image
IDL> Write_P2_Image,“test_output.pgm”,a
• Read in the small test image you just wroteIDL> b=Read_P2_Image(“test_output.pgm”)
• Statistics (sum, mean, etc.) must be equal• Finally, sum_squares( a - b ) must be 0.0
![Page 42: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/42.jpg)
Winter Quarter 2003 Rolando V. Raqueño 4242
Multiband Image Pixel Ordering
• Band Sequential
array( column, row, band)
array( sample, line, band)• Band Interleaved by Line
array( column, band, row )
array( sample, band, line)• Band Interleaved by Pixel
array( band, column, row )
array( band, sample, line )
![Page 43: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/43.jpg)
Winter Quarter 2003 Rolando V. Raqueño 4343
Multiband Image Pixel Ordering
• Let us take the following file• test_data.dat
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
• And look at the different interleaving representations as a multiband image.
![Page 44: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/44.jpg)
Winter Quarter 2003 Rolando V. Raqueño 4444
Band Sequential Example
• If we read in the test_data.dat using the array defined as a=bindgen(2,3,4), we would get
Band 0 Band 1 Band 2 Band 30 1 6 7 12 13 18 19
2 3 8 9 14 15 20 21
4 5 10 11 16 1722 23
![Page 45: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/45.jpg)
Winter Quarter 2003 Rolando V. Raqueño 4545
Band Interleaved by Line
• If we read in test_data.dat using the array defined as a=bindgen(2,4,3), we would get
Band 0Band 1 Band 2 Band 30 1 2 3 4 5 6 7
8 9 10 11 12 1314 15
16 17 18 19 20 2122 23
![Page 46: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/46.jpg)
Winter Quarter 2003 Rolando V. Raqueño 4646
Band Interleaved by Pixel
• If we read in test_data.dat using the array defined as a=bindgen(4,2,3), we would get
Band 0 Band 1 Band 2 Band 30 4 1 5 2 6 3 7
8 12 9 13 10 14 11 15
16 20 17 21 18 2219 23
![Page 47: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/47.jpg)
Winter Quarter 2003 Rolando V. Raqueño 4747
Reform/Transpose Conversion
• To convert previous examples from BSQ to BIL, we can use the following command
• Assume a BSQ image a=bindgen(2,3,4)IDL> b = reform( a, 2, 4, 3 )
IDL> c = transpose( b, [0, 2, 1] )
• The image c is now a BIL image
![Page 48: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/48.jpg)
Winter Quarter 2003 Rolando V. Raqueño 4848
Reform/Transpose Conversion
• To convert previous examples from BSQ to BIP, we can use the following command
• Assume a BSQ image a=bindgen(2,3,4)IDL> b = reform( a, 4, 2, 3 )
IDL> c = transpose( b, [1, 2, 0] )
• The image c is now a BIP image
![Page 49: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/49.jpg)
Winter Quarter 2003 Rolando V. Raqueño 4949
Widget Programming
![Page 50: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/50.jpg)
Winter Quarter 2003 Rolando V. Raqueño 5050
Widget
• What is a widget?– It is a graphical user interface component
• Basic IDL Widget Toolkit– Widget_Base, Widget_Button– Widget_Draw, Widget_DropList– Widget_Label, Widget_List– Widget_Slider, Widget_Text
![Page 51: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/51.jpg)
Winter Quarter 2003 Rolando V. Raqueño 5151
Widget_Base
• This widget type is used to hold other widget types. You can think of this as your blank canvas. It is also known as the “parent window” in other terms.
• To invoke a widget base, you would give the following commands
IDL> base = Widget_Base()
IDL> Widget_Control, base, /realize
![Page 52: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/52.jpg)
Winter Quarter 2003 Rolando V. Raqueño 5252
What the IDL Commands Mean
• base = Widget_Base()– In this function call, base will contain a unique
identifier (ID) to this specific instance of a blank window. The window is still described in memory, but not displayed
• Widget_Control, base, /realize– This tells IDL to display the entity with the ID
value in the variable base
![Page 53: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/53.jpg)
Winter Quarter 2003 Rolando V. Raqueño 5353
Result of the Widget_Base
• You should see a blank window similar to the one below
![Page 54: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/54.jpg)
Winter Quarter 2003 Rolando V. Raqueño 5454
Other Widget Types
• To invoke a Widget_ButtonIDL> button1 = Widget_Button( base )
IDL> Widget_Control, base, /realize
![Page 55: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/55.jpg)
Winter Quarter 2003 Rolando V. Raqueño 5555
To Change the Title of a Button Widget
IDL>Widget_Control,button1,Set_Value=“OK”
![Page 56: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/56.jpg)
Winter Quarter 2003 Rolando V. Raqueño 5656
Destroying a Widget
IDL> Widget_Control,button1,/destroy
![Page 57: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/57.jpg)
Winter Quarter 2003 Rolando V. Raqueño 5757
To Destroy the Base Widget
IDL> Widget_Control,base,/destroy– If there are any widgets attached to the base,
those children widgets will also be destroyed.
![Page 58: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/58.jpg)
Winter Quarter 2003 Rolando V. Raqueño 5858
Other Widget Examples
IDL> base=widget_base(column=1)
IDL> button=widget_button(base)
IDL> label=widget_label(base)
IDL> widget_control,base,/realize
![Page 59: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/59.jpg)
Winter Quarter 2003 Rolando V. Raqueño 5959
Other Widget Examples
IDL> base1=widget_base(column=1)
IDL> list1=widget_list(base1)
IDL> slider1=widget_slider(base1)
IDL> widget_control, base1, /realize
![Page 60: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/60.jpg)
Winter Quarter 2003 Rolando V. Raqueño 6060
Adding to the Previous Example
IDL> base2=widget_base(base1,row=2)
IDL> button1=widget_button(base2, value="First Button")
IDL> button2=widget_button(base2, value="Second Button")
IDL> widget_control,base1,/realize
![Page 61: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/61.jpg)
Winter Quarter 2003 Rolando V. Raqueño 6161
Modifying Previous Example
IDL> widget_control,slider1,set_value=100
IDL> widget_control,base1,/realize
IDL> widget_control,button2,set_value=
"Last Button"
![Page 62: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/62.jpg)
Winter Quarter 2003 Rolando V. Raqueño 6262
Getting Information from a Widget
IDL>widget_control,button1,get_value=button_value
IDL>print,button_value
First Button
![Page 63: 1 Winter Quarter 2003Rolando V. Raqueño Twas the Lecture Before Holiday Break Readings Present Makefiles Image Array Manipulation and I/O Simple Widget](https://reader035.vdocument.in/reader035/viewer/2022070403/56649f285503460f94c41789/html5/thumbnails/63.jpg)
Winter Quarter 2003 Rolando V. Raqueño 6363
Have a Safe and Happy Holiday
Remember, friends don’t let friends program drunk