美文网首页
讲解:program、c/c++,Java、PythonR| S

讲解:program、c/c++,Java、PythonR| S

作者: huobaishi | 来源:发表于2020-01-09 09:27 被阅读0次

    Image processing pipeline - Part C (10%)Complete your program by implementing pipefile parsing and command-line argumentparsing.Pipefile parsing (5%)Your program should be able to parse an input text file, which we can call the pipefile. Thepipefile describes a complete processing pipeline using nodes in a sequence. The followingpipefile, pipe1.txt , is given as an example:Your program should be able to parse any pipefile that describes nodes that you haveimplemented in part A.In order to parse a pipefile, you will need to implement a method that reads in a pipefile, andthen creates and links the nodes as needed, and finally returns the exit node. The usage maylook like the following:Pipefile formatEach line in a pipefile describes a node to be integrated into a pipeline, described by key-valuepairs of the form key=value . Every line requires a node key whose value contains a known nodename. 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 , sharpenbool : given by either yes or noveci : integer vector, e.g. 550x0 or 300x300vecf : floating-point vector such as 0.5x0.5int : integer such as 34 or 55path : a filepath such as in/mask.pngfloat : 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_Greyscalenode=greyscaleN_Resizenode=crop origin=550x0 size=300x300node=vignettenode=greyscalenode=convolve kernel=sharpenImage input = new Image(in/cat.png);Node endNode = PipelineLoader.LoadPipeline(pipe1.txt);Image output = endNode.GetOutput(input);output.Write(output);node=resizenewSize= veciN_Thresholdnode=thresholdminThreshold= int [optional] (minimum threshold value)maxThreshold= int [optional] (maximum threshold value)N_Masknode=maskmaskFile= path (path to the mask file)N_Cropnode=croporigin= veci (location of the top-left origin)size= veci (size of the crop region)N_Pixelatenode=pixelatepixelSize= veci (pixel size of pixelations)N_Vignettenode=vignetteN_Noisenode=noisenoisePercent= doubleN_Convolvenode=convolvekernel=[blur or sharpen or edge]N_RegionGrownode=region_groworigin= veci (origin of the region growth)threshold= int (minimum threshold to grow into)Pipefile processing tipsThe System.IO.File.ReadAllLines(...) method can be used to read a text file. See the followingexample:The string.Split(...) method can be used to split up a string into an array of strings using agiven string as a splitting element. For example:It is highly recommended that you break this problem down by writing small methods thatperform 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 NodeA method that takes a pipefile line and a key as parameters, and returns the valueassociated with that key, or an empty string if the key does not existA 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 theway 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 shouldnot 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 uprogram留学生作业代做、代写c/c++,Java程序语言作业、代做Python课程设计作业 帮做R语言编程|代写留sing 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 atthe -output path using the pipeline described in -pipefile . If the -saveall option is given, eachoutput within the -output folder will also be a folder, containing the output images from eachnode.If a required folder does not exist, your program should create it usingDirectory.CreateDirectory(...) . For example:C:/> dotnet run -pipe mypipe.txt -input cat.png -output out| C:/| cat.png| out.pngC:/> 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.pngC:/> dotnet run -pipe mypipe.txt -input in/ -output out| C:/| in/| | cat.png| | greys.pngOutput 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.pngC:/> 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.pngC:/> dotnet run -helpUsage: 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 directoryOptions:-verbose : use this option to enable verbose logging-saveall : use this option to save all intermediate images-help : display this helpC:/> dotnet run -pipe pipefile.txt -input cat.png -output out -saveallC:/> dotnet run -saveall -output out -pipe pipefile.txt -input cat.pngIf 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 consolewhen they occur.If the -saveall option is specified, all intermediate results (the results of each node) should alsobe 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 inputimage should be created containing all results.If the -help option is specified, the help output is displayed.Command-line argument parsing tipsIt is recommended that all the work for this part is written in Program.cs , within the Programclass.It is possible to check if a directory or a file exists using System.IO.Directory.Exists andSystem.IO.File.Exists . It is possible to create a directory usingSystem.IO.Directory.CreateDirectory .It is recommended that you write helper methods that check for the existence or return thevalues 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 helppublic static void Main(string[] args){ returns true or false depending on whether args contains -verbosebool verboseExists = CheckSingularArg(args, -verbose); returns the value to the right of -input if it exists otherwise an empty stringstring inputPath = GetArgValue(args, -input);}转自:http://www.5daixie.com/contents/9/3027.html

    相关文章

      网友评论

          本文标题:讲解:program、c/c++,Java、PythonR| S

          本文链接:https://www.haomeiwen.com/subject/yezeactx.html