首页
编程语言
数据库
网络开发
Algorithm算法
移动开发
系统相关
金融统计
人工智能
其他
首页
>
> 详细
program留学生讲解、辅导c/c++,Java程序语言、讲解Python设计 解析R语言编程|辅导留学生 Statistics统计、回归、迭
Image processing pipeline - Part C (10%)
Complete your program by implementing pipefile parsing and command-line argument
parsing.
Pipefile parsing (5%)
Your program should be able to parse an input text file, which we can call the pipefile. The
pipefile describes a complete processing pipeline using nodes in a sequence. The following
pipefile, pipe1.txt , is given as an example:
Your program should be able to parse any pipefile that describes nodes that you have
implemented in part A.
In order to parse a pipefile, you will need to implement a method that reads in a pipefile, and
then creates and links the nodes as needed, and finally returns the exit node. The usage may
look like the following:
Pipefile format
Each line in a pipefile describes a node to be integrated into a pipeline, described by key-value
pairs of the form key=value . Every line requires a node key whose value contains a known node
name. Additional key-value pairs are needed for any parameters required by the node.
Within key-value pairs, values may take the form of:
string : e.g. crop , vignette , sharpen
bool : given by either yes or no
veci : integer vector, e.g. 550x0 or 300x300
vecf : floating-point vector such as 0.5x0.5
int : integer such as 34 or 55
path : a filepath such as in/mask.png
float : floating-point values such as 0.5 (can use double in C#)
The following describes the key-value pairs needed for each of the processors in part A:
N_Greyscale
node=greyscale
N_Resize
node=crop origin=550x0 size=300x300
node=vignette
node=greyscale
node=convolve kernel=sharpen
Image input = new Image("in/cat.png");
Node endNode = PipelineLoader.LoadPipeline("pipe1.txt");
Image output = endNode.GetOutput(input);
output.Write("output");
node=resize
newSize= veci
N_Threshold
node=threshold
minThreshold= int [optional] (minimum threshold value)
maxThreshold= int [optional] (maximum threshold value)
N_Mask
node=mask
maskFile= path (path to the mask file)
N_Crop
node=crop
origin= veci (location of the top-left origin)
size= veci (size of the crop region)
N_Pixelate
node=pixelate
pixelSize= veci (pixel size of pixelations)
N_Vignette
node=vignette
N_Noise
node=noise
noisePercent= double
N_Convolve
node=convolve
kernel=[blur or sharpen or edge]
N_RegionGrow
node=region_grow
origin= veci (origin of the region growth)
threshold= int (minimum threshold to grow into)
Pipefile processing tips
The System.IO.File.ReadAllLines(...) method can be used to read a text file. See the following
example:
The string.Split(...) method can be used to split up a string into an array of strings using a
given string as a splitting element. For example:
It is highly recommended that you break this problem down by writing small methods that
perform very simple processes.
using System.IO;
...
string[] linesArr = File.ReadAllLines("pipe1.txt");
string example = "100x500";
string[] split = example.Split("x"); returns { "100", "500" }
Here are some examples:
A method that takes a pipefile line as a parameter, and returns a constructed Node
A method that takes a pipefile line and a key as parameters, and returns the value
associated with that key, or an empty string if the key does not exist
A method that parses a vector string or coordinate (such as "500x300")
Command-line argument parsing (5%)
When the program is invoked via dotnet run , a number of parameters are used to control the
way the program behaves:
-pipefile : the path to the input pipefile
-input : the path to the input image or image folder
-output : the path to the output image or image folder (without extension)
-verbose : optional argument to enable logging
-saveall : optional argument to enable saving of intermediate files
-help : optional argument to print the help text and close (no processing)
Command-line arguments should be able to be positioned in any order - your program should
not make any assumptions about the existence or the order of command-line arguments.
If -input is a single image, then that image should be processed into a single output image at the
-output path using the pipeline described in -pipefile . However, if the -saveall option is given,
the output should be a folder containing the output image of each node.
If -input is a folder, then all images in that folder should be processed into a folder of outputs at
the -output path using the pipeline described in -pipefile . If the -saveall option is given, each
output within the -output folder will also be a folder, containing the output images from each
node.
If a required folder does not exist, your program should create it using
Directory.CreateDirectory(...) .
For example:
C:/> dotnet run -pipe mypipe.txt -input cat.png -output out
| C:/
| cat.png
| out.png
C:/> dotnet run -pipe mypipe.txt -input cat.png -output out -saveall
| C:/
| cat.png
| out/
| | cat-01-crop.png
| | cat-02-convolve.png
| | cat-03-noise.png
| | cat-04-greyscale.png
C:/> dotnet run -pipe mypipe.txt -input in/ -output out
| C:/
| in/
| | cat.png
| | greys.png
Output displayed using the -help option:
See below for the help text given when the -help command-line argument is given:
The order of parameters is unimportant - parameters should be able to be specified in any order.
For instance, the following two examples are equivalent:
Output displayed with no inputs:
| | house.png
| out/
| | mypipe-cat.png
| | mypipe-greys.png
| | mypipe-house.png
C:/> dotnet run -pipe mypipe.txt -input in/ output out -saveall
| C:/
| in/
| | cat.png
| | greys.png
| | house.png
| out/
| | mypipe-cat/
| | | cat-01-crop.png
| | | cat-02-convolve.png
| | | cat-03-noise.png
| | | cat-04-greyscale.png
| | mypipe-greys/
| | | greys-01-crop.png
| | | greys-02-convolve.png
| | | greys-03-noise.png
| | | greys-04-greyscale.png
| | mypipe-house/
| | | house-01-crop.png
| | | house-02-convolve.png
| | | house-03-noise.png
| | | house-04-greyscale.png
C:/> dotnet run -help
Usage: dotnet run [options] -pipe
-input
-output
Required parameters:
-pipe
: the path to the pipe txt file
-input
: the path to the input image or image directory
-output
: the path to the output (file or directory)
(must be a directory if -saveall is enabled or -input is a directory
Options:
-verbose : use this option to enable verbose logging
-saveall : use this option to save all intermediate images
-help : display this help
C:/> dotnet run -pipe pipefile.txt -input cat.png -output out -saveall
C:/> dotnet run -saveall -output out -pipe pipefile.txt -input cat.png
If the -verbose option is specified, logging should be enabled during processing (from part B).
Regardless of the -verbose option, useful error messages should always be output to the console
when they occur.
If the -saveall option is specified, all intermediate results (the results of each node) should also
be saved by the program. If intermediate results are saved, the output path must be a directory.
If many images are being processed, and intermediate results are needed, a folder for each input
image should be created containing all results.
If the -help option is specified, the help output is displayed.
Command-line argument parsing tips
It is recommended that all the work for this part is written in Program.cs , within the Program
class.
It is possible to check if a directory or a file exists using System.IO.Directory.Exists and
System.IO.File.Exists . It is possible to create a directory using
System.IO.Directory.CreateDirectory .
It is recommended that you write helper methods that check for the existence or return the
values of parameters. Some helper method ideas are given below.
C:/> dotnet run
-pipe missing!
-input missing!
-output missing!
Usage: dotnet run [options] pipe path> input path> output path>
use -h option for detailed help
public static void Main(string[] args)
{
returns true or false depending on whether args contains -verbose
bool verboseExists = CheckSingularArg(args, "-verbose");
returns the value to the right of -input if it exists
otherwise an empty string
string inputPath = GetArgValue(args, "-input");
}
联系我们
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-21:00
微信:codinghelp
热点文章
更多
辅导 cs1b spring 2024 tth hw...
2024-04-19
讲解 managing financial risk...
2024-04-19
辅导 cs 0449 – project 5: /...
2024-04-19
辅导 elec 2141 digital circu...
2024-04-19
讲解 csc171 — videogame pro...
2024-04-19
讲解 comp3411 artificial int...
2024-04-19
讲解 stat3061: random proces...
2024-04-19
辅导 accounting 452, spring ...
2024-04-19
辅导 finc5001 foundations in...
2024-04-19
辅导 7ssmm712 – topics in a...
2024-04-19
讲解 com 337 - film studies ...
2024-04-19
辅导 mes202tc - digital vlsi...
2024-04-19
辅导 geography 2041b distanc...
2024-04-19
辅导 ecos3006 international ...
2024-04-19
讲解 fit5225 2024 sm1 creati...
2024-04-19
讲解 cit 593: introduction t...
2024-04-19
讲解 math 4931: take home ex...
2024-04-19
辅导 csci 547|info 533: syst...
2024-04-19
辅导 cs536-s24 intro to pls ...
2024-04-19
讲解 fit5212 - assignment 1辅...
2024-04-19
热点标签
ee5311
imse2113
comp 2322
acct2102
fnd109
int102
is3s664
is6153
data4000
accfin5034
fit5212
cs536-s24
fit5225
ecos3006
mes202tc
finc5001
stat3061
csc171
cs1b
7ssmm712
cpt206
swen90004
cs170
comp3411
bu.450.760
comp5313/comp4313—large
bl5611
kxo206
comp532
elec207
kxo151
hpm 573
dts101tc
cs 2820
cpt108
math2319
dts204tc
qm222
comp2511
ccs599
infs1001
mat2355
eeee4123
25721
ifn647
pols0010
cs 2550
cse340
comp2003j
comp9417
qbus6860
stat0023
csci 1100
cs 61b
cs360
fin 3080
ierg 4080
cs6238
cit 594
finm7406
hw6
elec9713
asb-2522
lit301
mcd4540
geog0030
125.330
biol0006
125.320
cs3334
fit2093
acct1101
110.309
masy1-gc
cs314
elec0048
gds104
mg5637
math5905
fit2096
07
mso3610
eel4837
sehs4515
cpt s 321
asb2522 investment
ma214
co2104
mgmt2015
32516
math32051
econ1012
mark2052
dsci 525
comp3310
econ0019
comp30023
abmf3184
aps106
antc27
finm7401
itp122
tech2300
math3026
cs 211
36318
cao107
fit1047
is2022
comp9024
ics4u
2xc3
en.540.635
4qqmn506
finn3081
phys10362
sta601
ec481e
math5165
csi 2120
el1205
comp7250
ecos3013
beam065
info1113
sehh2042
comp2051
csc325
mne 6130
ai6126
inu1111
ecs150
is61x6
cse115
seng6110
bus265
cpts260
mphy0009
csc306
eco2011
ee3004
st332
idepg001
info6001
cpt106
qbus2820
fins5516
finm7409
fit3152
isom3028
eece 6083
ceg5304
mcd4700
eecs 493
eg25h4
38173
elc5216
infs6071
lubs5996m
7ssmm803
glbh0031
phys1120
comp52715
eeb240
soci3403
math3836
cmns3490
iy5610/4610
cpt304
ac6105
psyc3241
fin570
218.323
lng310
rim3352
bio206
comp3334
ac.f633
asb-3525
cs 1501
cpt408
bust10134
lng206
acfi302
soc100
infr11199
csc1002
comp9334
csci 2122
etf5650
eco202y1y
acct608
apm236
gbsh0007
efim20005
actl5105
elec 292
sdsc4026
ds2500
dts205tc
联系我们
- QQ: 99515681 微信:codinghelp
© 2024
www.7daixie.com
站长地图
程序辅导网!