Smallest surrounding rectangle with any orientation.
The operator smallest_rectangle2 determines the smallest surrounding rectangle of a region, i.e. the rectangle with the smallest are of all rectangles containing the region. For this rectangle the center, the the inclination and the two radii are calculated. The procedure is applied when, for example, the location of a scenery of several regions (e.g. printed text on a rectangular paper orin rectangular print (justified lines)) must be found. The parameters of smallest_rectangle2 are chosen in such a way that they can be used directly as input for the HORUS-procedures disp_rectangle2 and rectangle2. If more than one region is passed in Regions the results are stored in tuples, the index of a value in the tuple corresponding to the index of a region in the input. In case of empty region all parameters have the value 0.0 if no other behavior was set (see set_system).
Regions (input_object) |
region(-array) -> object |
Regions to be examined. |
Row (output_control) |
rectangle2.center.y(-array) -> real |
Line index of the center. |
Column (output_control) |
rectangle2.center.x(-array) -> real |
Column index of the center. |
Phi (output_control) |
rectangle2.angle.rad(-array) -> real |
Orientation of the surrounding rectangle (arc measure) | |
Assertion: ((- pi / 2) < Phi) && (Phi <= (pi / 2)) |
Length1 (output_control) |
rectangle2.hwidth(-array) -> real |
First radius (half length) of the surrounding rectangle. | |
Assertion: Length1 >= 0.0 |
Length2 (output_control) |
rectangle2.hheight(-array) -> real |
Second radius (half width) of the surrounding rectangle. | |
Assertion: (Length1 >= 0.0) && (Length2 <= Length1) |
read_image(:Image:'fabrik':) > open_window(::0,0,-1,-1,'root','visible','':) > regiongrowing__(Image:Seg:5,5,6,100:) > smallest_rectangle2(Seg:::Row,Column,Phi,Length1,Length2) > rectangle2(:Rectangle:Row,Column,Phi,Length1,Length2:) > set_draw(::'margin':) > disp_region(Rectangle:::).
If F is the area of the region and N is the number of supporting points of the convex hull, the runtime complexity is O(F + N^2).
The operator smallest_rectangle2 returns the value TRUE if the input is not empty. The behavior in case of empty input (no input regions available) is set via the operator set_system(::'no_object_result',<Result>:). The behavior in case of empty region (the region is the empty set) is set via set_system(::'empty_region_result',<Result>:). If necessary an exception is raised.
threshold__, regiongrowing__, connection, fetch_chord
elliptic_axis, smallest_rectangle1