Creating your own image data files
Download
1 / 9

Creating your own image data files - PowerPoint PPT Presentation


  • 62 Views
  • Uploaded on

Creating your own image data files. Simple ASCII file output in Java. import java.io.FileOutputStream; import java.io.PrintWriter; … PrintWriter out = null; try { out = new PrintWriter( new FileOutputStream("fred.txt") ); } catch (Exception e) {

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' Creating your own image data files' - ely


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

Simple ascii file output in java
Simple ASCII file output in Java

import java.io.FileOutputStream;

import java.io.PrintWriter;

PrintWriter out = null;

try {

out = new PrintWriter( new FileOutputStream("fred.txt") );

} catch (Exception e) {

System.err.println( "error: " + e );

return;

}

out.println( "hello" );

out.close();


P2 ascii grey pgm
P2 = ASCII grey PGM

  • Each pixel has one integer (grey) value.

    P2

    w h

    maxval

    v1 v2 v3 …

    . . .

    . . . . . . vw*h


P3 ascii color ppm
P3 = ASCII color PPM

  • Each pixel’s color is represented as three consecutive values, <red,green,blue>.

    P3

    w h

    maxval

    v1r v1g v1b v2r v2g v2b

    . . .

    . . . . . . vw*hr vw*hg vw*hb


Exercise
Exercise

Write a simple program that creates an image of the sin function.

  • file format: pgm (P2 / grey)

  • file name: out.pgm

  • Don’t use code other than your own.


Exercise1
Exercise

Write a simple program that creates an image of the sin function.

  • sin function:

    • width/domain/x: [0..2Pi]

    • y: real numbers [-1.0..+1.0]

  • image:

    • width: 500 pixels ({0,..,499})

    • height: 250 pixels (repeat values from sin 250 times)

    • pixel values: integers {0,…,255}


Exercise cont d
Exercise (cont’d.)

Part A.

  • Download GIMP (gimp.org), and load your PGM file into GIMP.

  • Email your code (including doxygen/javadoc comments) that produced the image data file to me.

  • The email subject must be: CV sin A assignment.

Same values across each line repeated over and over and over for every line.


Transfer files to and from the android and pcs
Transfer files to and from the Android and PCs

  • When you connect the Android to a PC, it will mount the Android file system on the PC.

    • From the PC, click on Computer. Then click on the Android (mounted as Portable Media Player). Then click on Tablet. Then click on Download.

      • Copy images to and from the Android’s Download folder.

  • On the Android, Apps --> My Files. Then navigate to /storage/sdcard0/Download.

    • These are the same Download folder.


Exercise cont d1
Exercise (cont’d.)

Part B.

  • Download and build Albie.

  • Copy your pgm file from PC to Albie Download folder.

  • Run Albie. (Note: Loading this ASCII file on a Samsung Galaxy Tab 3 takes 30 seconds.)

  • Use Albie’s Save option, and email the resulting JPEG to me.

  • The email subject must be: CV sin B assignment.

Same values across each line repeated over and over and over for every line.


ad