Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2.3 Version 1 The source file of your program should be named prog03v1.c. For a given image and pattern your program should look for

2.3 Version 1 The source file of your program should be named prog03v1.c. For a given image and pattern yourIf the pattern is ABC 345 224 then the result for this pattern should be 2 3 1 4 5 because the pattern has2.3.2 Format of the output Each process will deal with one image file, specified by a file path. It will

2.3 Version 1 The source file of your program should be named prog03v1.c. For a given image and pattern your program should look for every occurrence of the pattern in the image and report in an output file the number of matches found, and their location. For example, if the pattern is 890 23a CFT then the result for this pattern should be 1 2 8 because the pattern has been found once in the image, at the location with its upper-left corner at row 2 and column 8 (Figure 1(a)). ABEFGH345TYH 123456789012 ABC3DG123asd 345ASABCFTGO 224CG345D12t SDFG3224 Zdlz (a) ABEFGH345TYH 123456789012 ABC3DG123asd 345ASABCFTGO 224CG345D12t SDFG3224zdlz Figure 1: Localization of "patterns" in an "image." (b) Note that we are using 0-based indices for rows and columns in our file output, with row index 1 corresponding to the top of the "image." If the pattern is ABC 345 224 then the result for this pattern should be 2 3 1 4 5 because the pattern has been found twice in the image, once at the location with its upper-left corner at row 3 and column 1, once at the location with its upper-left corner at row 4 and column 5 (Figure 1(b)). If the pattern is XXX yyy ZZZ then there is no match and the program should output 0 because the pattern is not found anywhere in the image. Note that the file extensions .img and .pat are just there to help you identify files of the types we are interested in. If you change the extension to .txt you can see that they are simply text files. 2.3.1 Input to the program Your program will be launched (typically by your bash script, but of course also directly from a bash terminal if your script is missing or deficient) with the following arguments: 1. The path to a file storing an "image" that you want to search for pattern within; 2. a list of paths to "pattern" files; For example, assuming that your executable was built with the name prog03v1 in the project's root folder, it could be launched with a command such as ./prog03v1 ./Data/Images/imagel.img\ ./Data/Patterns/pattern1.pat ./Data/Other Patterns/pattern2.pat \ ./Data/Patterns/Sub/pattern3.pat The characters'\' are part of the input. They are there to allow to enter a very long command over multiple line. In practice, they tell bash to "eat" the next character (which should be an end- of-line character). This is why there cannot be a space character after the '\', only an end of line. On the other hand there should be a space character either before ' \' or at the beginning of the next line (otherwise consecutive items of your command would be stuck together). If you do it well, then the '\' essentially means "the command continues on the next line." 2.3.2 Format of the output Each process will deal with one image file, specified by a file path. It will print out its results to the standard output (terminal). An example of output would be the following (these are completely made up output values, just chosen to illustrate the format): pattern1.pat 23 14 5 pattern2.pat 1 5 11 noMatchPattern.pat 0 pattern31.pat 3 8 10 12 5 15 1 pattern3.pat 1 4 125 character. It is worth pointing Note that the results for a given pattern are preceded by a tab out that the output only gives the name of the pattern file, not the full path, which means that there could be more than one image file with the same name. For example, we can see in the above output example that there were two pattern files named pattern1.pat searched by the program (presumably with a different path), and the program printed out separately the results for these two pattern files.

Step by Step Solution

3.47 Rating (157 Votes )

There are 3 Steps involved in it

Step: 1

Heres an example implementation of the program in C that searches for a given pattern in an image and outputs the number of matches found and their lo... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Programming questions

Question

What amount after being increased by 210% equals $465?

Answered: 1 week ago

Question

$750 is what percent more than $250?

Answered: 1 week ago

Question

How much is $10,000 after an increase of _3%? 4

Answered: 1 week ago