Download - Creating your own image data files
![Page 1: Creating your own image data files](https://reader035.vdocuments.site/reader035/viewer/2022062517/56812ece550346895d946e27/html5/thumbnails/1.jpg)
Creating your own image data files
![Page 2: Creating your own image data files](https://reader035.vdocuments.site/reader035/viewer/2022062517/56812ece550346895d946e27/html5/thumbnails/2.jpg)
Simple file output in C#
using System.IO;…StreamWriter file = new StreamWriter( "c:\\out.txt" );file.WriteLine( "hello, world." );…file.close();
Note from Microslip: Any similarities between the C# StreamWriter class and Java’s PrintWriter class are purely coincidental.
![Page 3: Creating your own image data files](https://reader035.vdocuments.site/reader035/viewer/2022062517/56812ece550346895d946e27/html5/thumbnails/3.jpg)
![Page 4: Creating your own image data files](https://reader035.vdocuments.site/reader035/viewer/2022062517/56812ece550346895d946e27/html5/thumbnails/4.jpg)
P2 = ASCII grey PGM
• Each pixel has one integer (grey) value.
P2w hmaxvalv1 v2 v3 …. . .. . . . . . vw*h
![Page 5: Creating your own image data files](https://reader035.vdocuments.site/reader035/viewer/2022062517/56812ece550346895d946e27/html5/thumbnails/5.jpg)
P3 = ASCII color PPM
• Each pixel’s color is represented as three consecutive values, <red,green,blue>.
P3w hmaxvalv1r
v1g v1b
v2r v2g
v2b
. . .
. . . . . . vw*hr vw*hg
vw*hb
![Page 6: Creating your own image data files](https://reader035.vdocuments.site/reader035/viewer/2022062517/56812ece550346895d946e27/html5/thumbnails/6.jpg)
Write a simple C# program that creates an image of the sin function.– file format: pgm (P2 / grey)– file name: out.pgm– 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
![Page 7: Creating your own image data files](https://reader035.vdocuments.site/reader035/viewer/2022062517/56812ece550346895d946e27/html5/thumbnails/7.jpg)
• Load result into your CSImageviewer; send a screen capture to me.
• Email your code (that produced the image data file) to me.
• The email subject must be CV sin assignment.
Exercise
Same values across each line repeated over and over and over for every line.