首页
编程语言
数据库
网络开发
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
热点文章
更多
辅导 ddes9012 critical appro...
2025-07-15
讲解 biochemical engineering...
2025-07-15
讲解 infs 5135 assignment –...
2025-07-15
辅导 visual analytics resit ...
2025-07-15
辅导 fite7407 securities tra...
2025-07-15
讲解 aero2363 – aerospace s...
2025-07-15
辅导 gfw0033 pembangunan &am...
2025-07-15
讲解 surfaces of section讲解...
2025-07-15
讲解 rlgn 3270 guru and disc...
2025-07-15
gsoe9340讲解 、辅导 java/pyt...
2025-07-15
辅导 assignment讲解 java语言
2025-07-15
讲解 cs 6043 – fall 2024 ho...
2025-07-15
辅导 imel7000/ecen7003_001 f...
2025-07-15
讲解 program、辅导 java/c++编...
2025-07-14
辅导 program、讲解 python/c+...
2025-07-14
讲解 a34315 number theory讲解...
2025-07-14
辅导 a36779 statistical meth...
2025-07-14
讲解 a37847 algebra & co...
2025-07-14
辅导 auto msc consultancy pr...
2025-07-14
讲解 hse208 integrated human...
2025-07-14
热点标签
mktg2509
csci 2600
38170
lng302
csse3010
phas3226
77938
arch1162
engn4536/engn6536
acx5903
comp151101
phl245
cse12
comp9312
stat3016/6016
phas0038
comp2140
6qqmb312
xjco3011
rest0005
ematm0051
5qqmn219
lubs5062m
eee8155
cege0100
eap033
artd1109
mat246
etc3430
ecmm462
mis102
inft6800
ddes9903
comp6521
comp9517
comp3331/9331
comp4337
comp6008
comp9414
bu.231.790.81
man00150m
csb352h
math1041
eengm4100
isys1002
08
6057cem
mktg3504
mthm036
mtrx1701
mth3241
eeee3086
cmp-7038b
cmp-7000a
ints4010
econ2151
infs5710
fins5516
fin3309
fins5510
gsoe9340
math2007
math2036
soee5010
mark3088
infs3605
elec9714
comp2271
ma214
comp2211
infs3604
600426
sit254
acct3091
bbt405
msin0116
com107/com113
mark5826
sit120
comp9021
eco2101
eeen40700
cs253
ece3114
ecmm447
chns3000
math377
itd102
comp9444
comp(2041|9044)
econ0060
econ7230
mgt001371
ecs-323
cs6250
mgdi60012
mdia2012
comm221001
comm5000
ma1008
engl642
econ241
com333
math367
mis201
nbs-7041x
meek16104
econ2003
comm1190
mbas902
comp-1027
dpst1091
comp7315
eppd1033
m06
ee3025
msci231
bb113/bbs1063
fc709
comp3425
comp9417
econ42915
cb9101
math1102e
chme0017
fc307
mkt60104
5522usst
litr1-uc6201.200
ee1102
cosc2803
math39512
omp9727
int2067/int5051
bsb151
mgt253
fc021
babs2202
mis2002s
phya21
18-213
cege0012
mdia1002
math38032
mech5125
07
cisc102
mgx3110
cs240
11175
fin3020s
eco3420
ictten622
comp9727
cpt111
de114102d
mgm320h5s
bafi1019
math21112
efim20036
mn-3503
fins5568
110.807
bcpm000028
info6030
bma0092
bcpm0054
math20212
ce335
cs365
cenv6141
ftec5580
math2010
ec3450
comm1170
ecmt1010
csci-ua.0480-003
econ12-200
ib3960
ectb60h3f
cs247—assignment
tk3163
ics3u
ib3j80
comp20008
comp9334
eppd1063
acct2343
cct109
isys1055/3412
math350-real
math2014
eec180
stat141b
econ2101
msinm014/msing014/msing014b
fit2004
comp643
bu1002
cm2030
联系我们
- QQ: 99515681 微信:codinghelp
© 2024
www.7daixie.com
站长地图
程序辅导网!