Write a program to recognize line patterns

Assignment Help Computer Engineering
Reference no: EM131141895

Write a program to recognize line patterns in a given set of points.

Computer vision involves analyzing patterns in visual images and reconstructing the real world objects that produced them. The process in often broken up into two phases: feature detection and pattern recognition. Feature detection involves selecting important features of the image; pattern recognition involves discovering patterns in the features. We will investigate a particularly clean pattern recognition problem involving points and line segments. This kind of pattern recognition arises in many other applications, for example statistical data analysis.

The problem. Given a set of N points in the plane, draw every line segment that connects 4 or more distinct points in the set.

1588_fig.png

Points and lines

Brute force. Write a program Brute.java that examines 4 points at a time and checks if they all lie on the same line segment, printing out any such line segments to standard output and plotting them usingStdDraw. To get started, you may use the data type Point.java and the client program PointPlotter.java which reads in a list of points from standard input and plots them. You will need to supply additional methods in Point.java in order to support the brute force client, e.g., checking whether three or four points lie on the same line.

A sorting solution. Remarkably, it is possible to solve the problem much faster than the brute force solution described above. Given a point p, the following method determines whether p participates in a set of 4 or more collinear points.

Think of p as the origin.

For each other point q, determine the angle it makes with p.

Sort the points according to the angle each makes with p.

Check if any 3 (or more) adjacent points in the sorted order have equal angles with p. If so, these points, together with p, are collinear.

Applying this method for each of theN points in turn yields an efficient algorithm to the problem. The algorithm solves the problem because points that make the same angle withp are collinear, and sorting brings such points together. The algorithm is fast because the bottleneck operation is sorting.

1657_fig1.png

Points and angles

Write a program Fast.java that implements this algorithm using Arrays.sort() and a user-defined Comparator for Point objects.
Input format. The data file consists of an integer N, followed by N pairs of integers (x, y) between 0 and 32,767.

% more input6.txt % more input8.txt 6 8 19000 10000 10000 0 18000 10000 0 10000 32000 10000 3000 7000 21000 10000 7000 3000 1234 5678 20000 21000 14000 10000 3000 4000 14000 15000 6000 7000

Output format. Print to standard output the line segments that your program discovers in the format below (number of collinear points in the line segment, followed by the points).

% java Brute 4: (10000, 0) -> (7000, 3000) -> (3000, 7000) -> (0, 10000) 4: (3000, 4000) -> (6000, 7000) -> (14000, 15000) -> (20000, 21000) % java Fast 5: (14000, 10000) -> (18000, 10000) -> (19000, 10000) -> (21000, 10000) -> (32000, 10000)

Also, plot the points and the line segments using standard drawin black. Your submitted version must use the standard pen size without calls tosetPenRadius(). Using thePoint data type supplied,p.draw()draws the pointp andp.drawTo(q) draws the line segment fromp toq. Before drawing, scale the coordinate system so that coordinates between 0 and 32,767 fit in the graphics window.

For full credit, Fast.java must print and plot a minimal representation: that is, only print one representation of each line segment and don't print subsegments. It's ok if Brute.java does not produce a minimal representation.

Analysis. Estimate (using tilde notation) the running time (in seconds) of your two programs as a function of the number of points N. Provide empirical and mathematical evidence to justify your hypotheses.

Reference no: EM131141895

Questions Cloud

Describe what will and will not work at pegasus : Identify and describe 3 process skills that are necessary for the consultant to have to facilitate change. Describe what will and will not work at Pegasus.
Research and analyze one of the given topic : Research and analyze one of the following topics- The possible Topics are:- Important historical events, past or present, relationships between the USA an d other Latin-American Countries.
What are the implications for further research : Does the study indicate a propensity for Personality Disorder when the Axis I ADHD disorder is present? Why? What are the implications for further research
How effective do you think that mediation would be and why : Why might a party be resistant to change? What techniques might be employed to reduce the resistance to change? Explore, in detail, an approach to collaborative negotiation. Address what issues would need to be addressed before the negotiation, d..
Write a program to recognize line patterns : Write a program to recognize line patterns in a given set of points - Applying this method for each of theN points in turn yields an efficient algorithm to the problem.
Determine the reactions at the support of the cantilever : Determine the reactions at the support of the cantilever shown in Figure S1.9 . The applied loading consists of the distributed triangular force shown.
Define starbucks ability to achieve long-term sustainability : Determine one (1) key management competency that a successful manager at Starbucks is likely to have. Indicate one (1) way in which this particular competency is a good fit for the organizational culture.
Explain the dimensions of conceptualizing these disorders : Explain the 2 dimensions of conceptualizing these disorders. Using additional resources (beyond the course text, but not Wikipedia or WebMD), support or refute the premise that the numbers of children with SEDs is signficant
Defend which valuation model best supports your findings : Defend which valuation model best supports your findings. Show calculations that support your findings, including those involving rates of return.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Write an user defined function

Write an user defined function, that takes as input the x and y co-ordinate of three points, i.e. (x1,y1), (x2,y2) and (x3,y3). The output arguments represents the length of three side of a triangle i.e. l1,l2,l3. (25)

  Questioncreate the logic for program that performs

questioncreate the logic for program that performs arithmetic functions. design a program to contain two numeric

  Be substantive and clear and use illustrations to reinforce

write 400-600 words that respond to the following questions with your thoughts ideas and comments. this will be the

  How inheritance improve a programmer''s productivity

define the difference between robustness and reliability and how design affects these characteristics.

  Describe the stages of the report life cycle and explain

1. what are the stages of the report life cycle and why is it a good business practice to follow one? discuss the

  In what order would you complete the tasks

You are sitting at your desk entering charges for a patient when you receive a call from the front desk. Patient Angela Diaz has just been seen by the doctor, and she is in the process of checking out.  She needs to schedule two appointments.

  Write down a 200- to 300-word short-answer response for the

write a 200- to 300-word short-answer response for the followingin what business database environments is

  Is concept of the process play a meaningful part

It is said that there is a dual definition of what an operating system must do. The first one is to present a "virtual machine" to the user which isolates him/her from bare-bones hardware and is user friendly and effective.

  What are the major problems of nrz

What are the major problems of NRZ (Non-Return to Zero) encoding/signaling? Is there any case where it's use could be acceptable? explain.

  Determine the period of the signal

Determine the period of the signal. Be sure to mention the units of the period, describe this signal in a complex exponential form and write the mathematical expression that describes the signal that will come out of the LTI system.

  What is going on during sampling and what is sampling method

What was going on during sampling? What was your sampling method? What are your results? What the 95th percentile exposure level would be?

  How to create program that performs arithmetic function

How to create program that performs arithmetic function Prompt a user for values for the variables. Pass both variables to methods named sum() and difference().

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd