+ All Categories
Home > Documents > Image Data and Display

Image Data and Display

Date post: 04-Jan-2016
Category:
Upload: jalen
View: 57 times
Download: 2 times
Share this document with a friend
Description:
Image Data and Display. For Class Consistency. % source ~rvrpci/.simg726.rc. Quiz #2 Topics. mkdir chmod cd grep ci and co. PBMPLUS FORMAT and xv. Digital image format concepts PBMPLUS image interchange format. Displaying digital image xv image display. PBMPLUS Image Data Types. - PowerPoint PPT Presentation
56
Rolando V. Raqueño Monday, June 27, 202 2 1 1 Image Data and Display
Transcript
Page 1: Image Data and Display

Rolando V. Raqueño Thursday, April 20, 202311

Image Data and Display

Page 2: Image Data and Display

Rolando V. Raqueño Thursday, April 20, 202322

For Class Consistency

% source ~rvrpci/.simg726.rc

Page 3: Image Data and Display

Rolando V. Raqueño Thursday, April 20, 202333

Quiz #2 Topics

• mkdir• chmod• cd• grep• ci and co

Page 4: Image Data and Display

Rolando V. Raqueño Thursday, April 20, 202344

PBMPLUS FORMAT and xv• Digital image format concepts

– PBMPLUS image interchange format.

• Displaying digital image– xv image display

Page 5: Image Data and Display

Rolando V. Raqueño Thursday, April 20, 202355

PBMPLUS Image Data Types• Bilevel Image Data Type

– Black and White

• Monochrome Image Data Type– Greyscale

• RGB Color Image Data Type – Color

Page 6: Image Data and Display

Rolando V. Raqueño Thursday, April 20, 202366

Two PBMPLUS Representations

• All PBMPLUS data formats have the following representations– ASCII Format

• (for Human Consumption)

– RAW Format • (for Computer Consumption)

Page 7: Image Data and Display

Rolando V. Raqueño Thursday, April 20, 202377

Displaying Images• Use xv utility for display and documentation purposes.

– Note that xv is an X client

• Should NEVER be used for image processing – USE ONLY FOR DISPLAY PURPOSES

• To invoke xv

% xv &% xv filename.pgm &

Page 8: Image Data and Display

Rolando V. Raqueño Thursday, April 20, 202388

Portable Bit Map (PBM)

• Bilevel Image Data Type – (Black and White)

• Used to represent printed black and white imagery such as documents and faxes.

• Uses 0’s (zeroes) to represent white – (no ink deposited on paper)

• Uses 1’s (ones) to represent black – (ink deposited on paper)

Page 9: Image Data and Display

Rolando V. Raqueño Thursday, April 20, 202399

Let us digress – The vi Problem

• vi practice and creation of a bilevel image.• 7”x10” graph paper divided into 10 squares per inch. • Cell not covered by ink

– value of zero (0).

• Cell fully or partially covered by ink – value of one (1).

• You will have a total of 700 pixels to enter.

Page 10: Image Data and Display

Rolando V. Raqueño Thursday, April 20, 20231010

Problem #1 Solution

• vi - Brute Force Solution1. Is the current pixel 0 (zero) or 1 (one)?

2. Type the appropriate character

3. Repeat steps 1 and 2 until done

Page 11: Image Data and Display

Rolando V. Raqueño Thursday, April 20, 20231111

Problem #1 Solution

• vi- Smart Solution1. Type the vi command “70i0” “seventy, i - for insert, 0 (zero)”

2. Hit the ESCAPE key to get you out of insert mode.3. Type the vi command “o” to open a new line4. Hit the ESCAPE key to get you out of insert mode.5. Move back up to the line of zeroes and use the yy

(yank command) to make a copy of the line of 70 zeroes.

Page 12: Image Data and Display

Rolando V. Raqueño Thursday, April 20, 20231212

Problem #1 Solution

• vi- Smart Solution6. Type the vi command “p” 10 times

7. Move back up to the top line of zeroes and use the 10yy (yank command) to make a copy of 10 lines of 70 zeroes per line.

8. Type the vi command “p” 10 times

9.You will now have a page of 700 zeroes.

Page 13: Image Data and Display

Rolando V. Raqueño Thursday, April 20, 20231313

Problem #1 Solution• vi- Smart Solution

10. You can navigate to the areas that need to be changed to “1” and use the “R” command to replace contiguous set of characters.

11. Hit the ESCAPE key to get you out of insert mode.12. Navigate to next section and repeat steps 10 -12

until done.13. Save the file out and exit vi

:wq signature.dat

Page 14: Image Data and Display

Rolando V. Raqueño Thursday, April 20, 20231414

Yet another vi Digression

• To show line number in vi, execute the following command

:set number• To disable line numbers in vi, execute

the following command

:set nonumber

Page 15: Image Data and Display

Rolando V. Raqueño Thursday, April 20, 20231515

Viewing current vi settings:set allnoautoindent nomodelines noshowmode

autoprint nonumber noslowopen

noautowrite nonovice tabstop=8

nobeautify nooptimize taglength=0

directory=/var/tmp paragraphs=IPLPPPQPP LIpplpipnpbtags=tags /usr/lib/tags

noedcompatible prompt tagstack

noerrorbells noreadonly term=vt220

noexrc redraw noterse

flash remap timeout

hardtabs=8 report=5 ttytype=vt220

noignorecase scroll=11 warn

nolisp sections=NHSHH HUuhsh+c window=23

nolist shell=/bin/csh wrapscan

magic shiftwidth=8 wrapmargin=0

mesg noshowmatch nowriteany

Page 16: Image Data and Display

Rolando V. Raqueño Thursday, April 20, 20231616

Saving vi Preferences

• Preferences such as :set number can be saved in the file .exrc in your home directory (~)

Page 17: Image Data and Display

Rolando V. Raqueño Thursday, April 20, 20231717

A vi Command to Always Remember

• To replace all occurrences or a string in a file with new string.:%s/string1/string2/g

OR

:%s/string1/string2/gc(Will ask you for confirmation)

Page 18: Image Data and Display

Rolando V. Raqueño Thursday, April 20, 20231818

The Super-smart Solution

• In UNIX

% repeat 70 echo -n 0 >> one_line; echo >> one_line; repeat 100 cat one_line >> signature.dat

Page 19: Image Data and Display

Rolando V. Raqueño Thursday, April 20, 20231919

Let’s Create another image

• Put the signature.dat away for the time being and create a simpler image

• Call it bilevel.pbm

Page 20: Image Data and Display

Rolando V. Raqueño Thursday, April 20, 20232020

Portable Bit Map (PBM)• Bilevel Image Data Type

– For the ASCII file format, the file header is given by P1 – width and height of the image. – Comments are indicated by the # character

P1# This is a 16 column x 3 row# PBM ASCII image# Created by using vi16 3001010100011010000111110010010000101001001011100

Page 21: Image Data and Display

Rolando V. Raqueño Thursday, April 20, 20232121

Portable Bit Map (PBM)• Make a copy of bilevel.pbm and edit the copy to look like

the following,

P1

#This is a 16 column x 3 row PBM ASCII

#image

#

16 3

0010101000110100

0011111001001000

0101001001011100

Page 22: Image Data and Display

Rolando V. Raqueño Thursday, April 20, 20232222

Portable Bit Map (PBM)• When displayed looks like

P1

# This is a 16 column x 3 row PBM ASCII

# image

#

16 3

0010101000110100

0011111001001000

0101001001011100

Page 23: Image Data and Display

Rolando V. Raqueño Thursday, April 20, 20232323

How to Add a PBMPLUS Header to an Image File

• If its an ASCII file you can use vi• Use the cat command to concatenate a

header from a file or the keyboard (standard input - stdio)

Page 24: Image Data and Display

Rolando V. Raqueño Thursday, April 20, 20232424

Put a header on signature.dat and display in xv

• Method #1– Using a text editor, input the appropriate

header values.

Page 25: Image Data and Display

Rolando V. Raqueño Thursday, April 20, 20232525

Put a header on signature.dat and display in xv

• Method #2– Edit a file called header.dat containing

the header information– Concatenate the header file at the

beginning of signature.dat using the cat command

% cat header.dat signature.dat > signature.pbm

Page 26: Image Data and Display

Rolando V. Raqueño Thursday, April 20, 20232626

Put a header on signature.dat and display in xv

• Method #3– Concatenate the header data from the keyboard

directly to the beginning of signature.dat using the cat command

% cat - signature.dat > signature.pbm

P1

70 100

^D

Page 27: Image Data and Display

Rolando V. Raqueño Thursday, April 20, 20232727

Portable Bit Map (PBM)

• There is also a binary version of the PBM image type which uses a P4 header such as the one below

P4

# This is a 16 column x 3 row PBM RAW

# image

16 3

*4>HR\

Page 28: Image Data and Display

Rolando V. Raqueño Thursday, April 20, 20232828

Portable Grey Map (PGM)

• Monochrome Image Data Type (Greyscale)– Displayed greyscale imagery– Grey values brightness.– Convention opposite that of the PBM

format

Page 29: Image Data and Display

Rolando V. Raqueño Thursday, April 20, 20232929

Portable Grey Map (PGM)

• Monochrome Image Data Type (Greyscale)– EXAMPLE,

P2

# This is a 3 column x 2 row PGM ASCII image

# With a possible maximum grey value of 255

3 2

255

42 52 62

72 82 92

Page 30: Image Data and Display

Rolando V. Raqueño Thursday, April 20, 20233030

Portable Grey Map (PGM)

• When displayed, the image is shown below P2

# This is a 3 column x 2 row PGM ASCII image

# With a possible maximum grey value of 255

3 2

255

42 52 62

72 82 92

Page 31: Image Data and Display

Rolando V. Raqueño Thursday, April 20, 20233131

Portable Grey Map (PGM)

• There is also a binary version of the PGM image type which uses a P5 header such as the one below

P5

# This is a 3 column x 2 row PGM Raw

# image

3 2

255

*4>HR\

Page 32: Image Data and Display

Rolando V. Raqueño Thursday, April 20, 20233232

Portable Pixel Map (PPM)

• RGB Color Image Data Type (Color)– Red, Green, and Blue bands– Arranged in pixel-interleaved format or

band interleaved by pixel (BIP)

Page 33: Image Data and Display

Rolando V. Raqueño Thursday, April 20, 20233333

Portable Pixel Map (PPM)• RGB Color Image Data Type (Color)

– For the ASCII file format, • P3 • width, height• maximum grey level possible of the image

– The pixel values are given as a triple representing the red, green, and blue components .

Page 34: Image Data and Display

Rolando V. Raqueño Thursday, April 20, 20233434

Portable Pixel Map (PPM)

• RGB Color Image Data Type (Color)– EXAMPLE,

P3

3 3

255

255 0 0 0 255 0 0 0 255

128 0 0 0 128 0 0 0 128

0 0 0 128 128 128 255 255 255

Page 35: Image Data and Display

Rolando V. Raqueño Thursday, April 20, 20233535

PPM QUESTION

So what does the data

*4>HR\ look like as a

Raw PPM Image?

Page 36: Image Data and Display

Rolando V. Raqueño Thursday, April 20, 20233636

Conversion of Raw Files to PBMPLUS Format

• Alternative to manually prepending a header file using cat command rawtopbm, rawtopgm, or rawtoppm

% rawtopgm 256 256 ~rvrpci/pub/MyCat_P5.raw > MyCat.pgm

Page 37: Image Data and Display

Rolando V. Raqueño Thursday, April 20, 20233737

Usage Note About PBMPLUS Commands

• PBMPLUS commands heavily use the UNIX redirection and piping

• To get help use -h option.% rawtopgm -h

usage: rawtopgm [-headerskip N] [-rowskip N] [-tb|-topbottom] [<width> <height>][rawfile]

Page 38: Image Data and Display

Rolando V. Raqueño Thursday, April 20, 20233838

Converting PNM Image File to Another Format

• PNM is a generic designator for all PBM, PGM, and PPM

• Convert a PBMPLUS format file into a TIFF – e.g., signature.pbm to signature.tiff.

• Use the following command

% pnmtotiff -none signature.pbm > signature.tiff

-none option means not invoke LZW image compression.

Page 39: Image Data and Display

Rolando V. Raqueño Thursday, April 20, 20233939

Rudimentary Image Processing Using the PBMPLUS Utilities

• Requires that all input be in some form of PBM, PGM, PPM image

• Supposed we wanted to enlarge a tiff file ( e.g., signature.tiff) by a scale factor of 2x and then convert it to a SUN raster file.

TIFF TIFF FILEFILE

PNM PNM FILEFILE

2X 2X ScaleScale

PNM PNM FILEFILE

RAST RAST FILEFILE

Page 40: Image Data and Display

Rolando V. Raqueño Thursday, April 20, 20234040

Rudimentary Image Processing Using the PBMPLUS Utilities

• The previous process can actually be executed in one UNIX command

% tifftopnm signature.tiff | pnmscale 2.0 | pnmtorast > signature.rast

• In fact you can pipe the information directly to xv before writing it out to another format

% tifftopnm signature.tiff | pnmscale 2.0 | pnmtorast | xv -

Page 41: Image Data and Display

Rolando V. Raqueño Thursday, April 20, 20234141

PBMPLUS File Information

• Supposed you wanted to know what the characteristics are of a particular PBMPLUS file you can give the following command% pnmfile MyCat.pgmMyCat.pgm: PGM raw, 256 by 256 maxval 255

Page 42: Image Data and Display

Rolando V. Raqueño Thursday, April 20, 20234242

PBMPLUS Histogram Utilities

• Greyscale histogram pgmhist

• Color histogram ppmhist

Page 43: Image Data and Display

Rolando V. Raqueño Thursday, April 20, 20234343

Cutting out regions of interest

% pnmcutusage: pnmcut x y width height [pnmfile]

% pnmcropusage: pnmcrop [-white|-black] [-left] [-right] [-top] [-bottom] [pnmfile]

Page 44: Image Data and Display

Rolando V. Raqueño Thursday, April 20, 20234444

Pasting or Arranging Images

% pnmcatpnmcat [-white|-black] -leftright|-lr [-jtop|-jbottom] pnmfile pnmfile ...

% pnmpastepnmpaste [-replace|-or|-and |xor] frompnmfile x y [intopnmfile]

Page 45: Image Data and Display

Rolando V. Raqueño Thursday, April 20, 20234545

You have a bunch of images...

% pnmindexpnmindex [-size N] [-across N]

[-colors N] [-black] pnmfile ...

Page 46: Image Data and Display

Rolando V. Raqueño Thursday, April 20, 20234646

Color Bands Combination and Extraction

% rgb3ppmrgb3toppm redpgmfile greenpgmfile bluepgmfile

% ppmtorgb3ppmtorgb3 [ppmfile]

•results in .red .grn .blu

Page 47: Image Data and Display

Rolando V. Raqueño Thursday, April 20, 20234747

Spatial Operations

• pnmconvol• pnmscale• pnmrotate• pnmflip• pnmshear

Page 48: Image Data and Display

Rolando V. Raqueño Thursday, April 20, 20234848

Greyscale/Color Operations

• ppmquant• pnmdepth• ppmdither

Page 49: Image Data and Display

Rolando V. Raqueño Thursday, April 20, 20234949

Really Useful Stuff

• Doing Screen Captures under X

% xwd | xwdtopnm | pnmdepth 255 | pnmtotiff > screen.tif

• Your cursor will turn into crosshairs

• Click on the window you want to capture

Page 50: Image Data and Display

Rolando V. Raqueño Thursday, April 20, 20235050

Screen Capture through xv

• Click on grab button• Specify a time delay• Left button grabs

window• Middle button grabs

a rectangle• Right button cancels

Page 51: Image Data and Display

Rolando V. Raqueño Thursday, April 20, 20235151

Getting Hardcopy Output• Determining what type of display device you

haveIDL> help,/deviceAvailable graphics_devices: CGM HP MAC NULL PCL PS ZCurrent graphics device: MAC Macintosh Quickdraw Driver Screen Resolution: 640x442 Physical Color Map Entries (Used / Total): 220 / 256 Current Window Number: 0, size: (320,240) type: Window. Graphics Function: 3 (copy) Current Font: Chicago Default Backing Store: Pixmap. Window Status: 0: Window 320x240 (Retained)

Page 52: Image Data and Display

Rolando V. Raqueño Thursday, April 20, 20235252

Getting Hardcopy Output• To get a postscript output of your plot

IDL> set_plot,’ps’IDL> device, Filename=‘new_plot.ps’IDL> plot, my_data,Title=‘Imaging Lab 1’IDL> device, /closeIDL> $lpr -Pdip new_plot.ps

• You then want to return your output device to whatever display device you had originallyIDL> set_plot,’MAC’

Page 53: Image Data and Display

Rolando V. Raqueño Thursday, April 20, 20235353

Check Your Postscript File Before Sending to the Printer • You can use the ghostview utility to

view a postscript file

Page 54: Image Data and Display

Rolando V. Raqueño Thursday, April 20, 20235454

Note Well

• Always make sure that the printer to which you will be sending your job is capable of talking Postscript. If it does not, you will be killing many trees.

• To find out the status of your job% lpq -P(printer name)

• To kill a print job% lprm -P(printer name) job_number

Page 55: Image Data and Display

Rolando V. Raqueño Thursday, April 20, 20235555

Getting Encapsulated Postscript File (EPS)

• To get a postscript file of your plot that you can include into another documentIDL> set_plot,’ps’IDL> device, /encapsulated, /previewIDL> device, Filename=‘new_plot.eps’IDL> plot, my_data,Title=‘Imaging Lab 1’IDL> device, /close

• The above process creates what is known as an Encapsulated Postscript File (EPS)

Page 56: Image Data and Display

Rolando V. Raqueño Thursday, April 20, 20235656


Recommended