2.3 Version 1 The source file of your program should be named prog03v1.c. For a given...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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. 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.
Expert Answer:
Answer rating: 100% (QA)
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... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
Emily and Fran sliding: The forces acting on Emily are the force of gravity downwards, the normal force upwards, and the frictional force to the left. The forces acting on Fran are the force of...
-
Codes that are enacted by a lawmaking body like Congress are referred to as _ _ _ _ _ _ . Group of answer choices civil law common law regulatory law Congressional law
-
The following is a list of items that could be included in the intangible assets section of the balance sheet. (a) Indicate which items on the list below would generally be reported as intangible...
-
What requirements must be met to deduct a trade or business expense? an expense related to the production of income?
-
Knowing that p is proportional to L, rescale the data of Example 5.7 to plot dimensionless p versus dimensionless diameter. Use this plot to find the diameter required in the first row of data in...
-
Turn back to Table 3.7, which shows marginal personal tax rates. Make a table in Excel that calculates taxes due for income levels ranging from $10,000 to $10 million. a. For each income, calculate...
-
Write a short note on : Types of belt drive.
-
Acme, Inc., a multinational company based in the United States, has a large subsidiary located in Beijing, China. Acme is audited by an international accounting firm headquartered in the United...
-
Roberta Bondar is travelling in her space craft around a distant planet. The planet has a radius R' and she is at an altitude of 2R' above its surface, coasting at some constant speed in a circular...
-
On April 1, 2010, Jose Guadalupe established an interior decorating business, Lodge Designs. During the month, Jose completed the following transactions related to the business: Apr. 1. Jose...
-
If you push twice as hard against a stationary wall, the amount of work you do on the wall Select one: a. doubles b. Stays Constant and > 0. c. Stays Constant and = 0. d. Stays Constant and <...
-
Diversification is a technique that reduces risk by allocating investments between various financial instruments, industries, and other categories. The goal is to maximize returns by investing in...
-
Choose an organization's website. Provide the name of the company and the URL address at the top of your answer. i) Analyze the website using THREE (3) relevant corporate communication concepts. (9%)...
-
Each of the following statements violates at least one of the criteria for effective supporting materials discussed in this chapter. Identify the flaw (or flaws) in each statement. It's just not true...
-
]What is the yield-to-maturity of a corporate bond that has face value of $1,000, annual coupon payments of $35, is being quoted at 102.5, and has seven years left to maturity? hint: You need to use...
-
At which point will you enter into such forward contracts for hedging purposes? i.e. would be prefer hedging against expected cashflow(before you even sign a contract with any foreign company),...
-
Evaluate the line integral fezydr+y dy+yz dz, where C is the line segment from the point (1,0.-1) to (3,4,2).
-
Catherine (aged 42) and Johnson (aged 45) have been married for 12 years. Johnson is a project manager of an event company at a monthly salary of $55,000 with an additional one-month salary of...
-
Van makes an investment in a partnership in 2012. Van's capital contributions to the partnership consisted of $30,000 cash and a building with an adjusted basis of$70,000, subject to a nonrecourse...
-
Ken (age 31) and Amy (age 28) Booth have brought you the following information regarding their income, expenses, and withholding for the year. They are unsure which of these items must be used to...
-
Diego, age 28, married Dolores, age 27, in 2012. Their salaries for the year amounted to $46,479 and they had interest income of $3,500. Diego and Dolores' deductions for adjusted gross income...
-
A liquid enters an adiabatic throttling valve, illustrated in Figure 6-4, at T = 80F and P = 5 atm, at which conditions it has V-0.100 L/mol. The exiting liquid has P = 0.5 atm. For this steady-state...
-
100 kg/min of liquid nitrogen is produced by the steady-state process shown in Figure 5-17. 1. Nitrogen enters the process at P = 1 bar and T = 300 K. 2. The nitrogen is cooled in a heat exchanger...
-
Revisit the two processes described in Examples 4-2 and 4-3. Applying Equation 4.14, calculate the changes in entropy for the gas, the surroundings, and the universe for both processes.
Study smarter with the SolutionInn App