JP2011039664A - Line segment drawing processing method and device, and pickup image processing apparatus - Google Patents
Line segment drawing processing method and device, and pickup image processing apparatus Download PDFInfo
- Publication number
- JP2011039664A JP2011039664A JP2009184653A JP2009184653A JP2011039664A JP 2011039664 A JP2011039664 A JP 2011039664A JP 2009184653 A JP2009184653 A JP 2009184653A JP 2009184653 A JP2009184653 A JP 2009184653A JP 2011039664 A JP2011039664 A JP 2011039664A
- Authority
- JP
- Japan
- Prior art keywords
- line segment
- pixel
- line
- scanning direction
- error
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Images
Abstract
Description
本発明は、撮影した画像に任意の線分を重畳表示させる場合などに好適な線分描画処理方法及び装置、並びにそれを適用した撮像画像処理装置に関する。 The present invention relates to a line segment drawing processing method and apparatus suitable for displaying an arbitrary line segment superimposed on a captured image, and a captured image processing apparatus to which the line segment drawing processing method and apparatus are applied.
カメラなど撮像装置の機能の一つとして、撮影した画像に任意の線分を重畳表示させて、ユーザの操作等を支援する機能が今日では一般的になっている。例えば、車載カメラでは、車両の後方等を撮影した画像に重畳して、車幅線を表示することが行われている。 As one of the functions of an imaging apparatus such as a camera, a function that supports a user operation or the like by superimposing and displaying an arbitrary line segment on a captured image is now common. For example, in an in-vehicle camera, a vehicle width line is displayed by superimposing it on an image obtained by photographing the rear of the vehicle.
従来から、デジタル座標平面上の任意の2点で結ばられる線分上の各点(画素)を求めるアルゴリズムの一つとしてブレゼンハム方式がある。このブレゼンハム方式は乗算・除算を必要せず、加減算のみで線分を描画できるため、適用範囲の広いアルゴリズムとして知られている。 Conventionally, there is a Bresenham method as one of algorithms for obtaining each point (pixel) on a line segment connected by two arbitrary points on a digital coordinate plane. This Bresenham method is known as an algorithm with a wide application range because it does not require multiplication / division and can draw a line segment only by addition / subtraction.
ブレゼンハム方式では、線分を構成する画面各行の走査方向線分を求める処理が行われる。これは、具体的には走査方向線分の開始画素から終端画素を探索する処理である。この場合、従来のブレゼンハム方式では、走査方向線分の開始画素から終端画素を探索するのに、1画素ずつ探索を行う、いわゆる線型探索を用い、当該画素が終端画素かどうかは誤差項という値を求め、これを閾値と比較することにより行っていた。しかしながら、1画素ずつの線型探索では、走査方向線分が長い場合は探索時間が多くかかり、全体として処理時間が長くなる問題があった。 In the Bresenham method, a process for obtaining a line segment in the scanning direction of each row constituting the line segment is performed. Specifically, this is a process of searching for the end pixel from the start pixel in the scanning direction line segment. In this case, in the conventional Bresenham method, a so-called linear search is performed in which a search is performed pixel by pixel to search for the end pixel from the start pixel in the scanning direction line segment, and whether the pixel is the end pixel is a value called an error term. And comparing this with a threshold value. However, in the linear search for each pixel, there is a problem that if the line segment in the scanning direction is long, it takes a long time to search and the processing time becomes long as a whole.
また、プレゼン方式の変形例として線分の描画をブロック単位で処理し、各ブロック毎にその描画開始点の座標値と誤差項を独立に計算することで、処理時間の短縮を可能にした方法も提案されている(特許文献1)。しかし、この方法も各ブロック領域内の線分描画処理はブレゼンハムアルゴリズムを適用しているため、処理時間の短縮には限界があり、また、除算を用いてブロックの描画開始点の誤差項を求めているため、逆にブレゼンハム方式の利点を損なう問題がある。 In addition, as a modification of the presentation method, processing of line segments is processed in units of blocks, and the coordinate value and error term of the drawing start point are independently calculated for each block, thereby reducing processing time. Has also been proposed (Patent Document 1). However, this method also uses the Bresenham algorithm for line segment drawing processing in each block area, so there is a limit to shortening the processing time, and the error term of the drawing start point of the block is obtained using division. Therefore, there is a problem that the advantage of the Bresenham method is impaired.
ユーザの操作等を支援するため、撮影した画像に重畳して表示させる線分などの場合、傾きが小さい線分であることが多い。 In order to assist the user's operation or the like, in the case of a line segment displayed so as to be superimposed on a photographed image, the line segment has a small inclination in many cases.
本発明は、傾きが特に小さい線分の描画処理時間の短縮が可能になる線分描画処理方法及び装置、並びにそれを適用した画像処理装置を提供することを目的とする。 It is an object of the present invention to provide a line drawing processing method and apparatus capable of shortening the drawing processing time of a line having a particularly small inclination, and an image processing apparatus to which the line drawing processing method and apparatus are applied.
さらに、本発明は、リソースが複雑になる除算は行わずに、小リソース環境で線分の描画処理を実現する線分描画処理方法及び装置、並びにそれを適用した撮像画像処理装置を提供することを目的とする。 Furthermore, the present invention provides a line segment drawing processing method and apparatus for realizing line segment drawing processing in a small resource environment without performing complicated division, and a captured image processing apparatus to which the line segment drawing process is applied. With the goal.
請求項1の発明は、多数の画素で構成された2次元画面上に、線分の始点と終点を指定し、前記始点から終点に向かって、線分を構成する画面各行の走査方向線分を求めて線分を描画する線分描画処理方法において、走査方向に対する線分の傾きが所定値以下か否か判断し、前記線分の傾きが所定値以下の場合には、線分を構成する画面各行の走査方向線分の開始画素から二分探索を行って該走査方向線分の終端画素を探索し、前記線分の傾きが所定値以下でない場合には、線分を構成する画面各行の走査方向線分の開始画素から1画素ずつ探索を行う、線型探索を行って該走査方向線分の終端画素を探索することを特徴とする。 According to the first aspect of the present invention, a start point and an end point of a line segment are designated on a two-dimensional screen composed of a large number of pixels, and a line segment in the scanning direction of each line constituting the line segment from the start point to the end point is specified. In the line segment drawing processing method for drawing a line segment, it is determined whether or not the slope of the line segment with respect to the scanning direction is equal to or less than a predetermined value. When a binary search is performed from the start pixel of the scanning direction line segment of each line of the screen to search for the end pixel of the scanning direction line segment, and when the inclination of the line segment is not less than or equal to a predetermined value, each line of the screen constituting the line segment A search is performed pixel by pixel from the start pixel of the scanning direction line segment, and a linear search is performed to search for an end pixel of the scanning direction line segment.
請求項2の発明は、請求項1に記載の線分描画処理方法において、画面走査方向をx方向とし、線分の始点終点のx方向差分dx、y方向差分dyとし、線分の傾きdy/dxを計算して、dy/dx≦αを満足するか判断し、満足する場合に二分探索を適用することを特徴とする。 According to a second aspect of the present invention, in the line segment drawing processing method according to the first aspect, the screen scanning direction is the x direction, the x direction difference dx and the y direction difference dy of the start point and the end point of the line segment, and the line segment inclination dy / Dx is calculated to determine whether dy / dx ≦ α is satisfied, and when satisfied, a binary search is applied.
請求項3の発明は、請求項2に記載の線分描画処理方法において、所定値αは少なくとも1/8以下の値とすることを特徴とする。 The invention according to claim 3 is the line drawing processing method according to claim 2, wherein the predetermined value α is at least 1/8 or less.
請求項4の発明は、請求項2あるいは3に記載の線分描画処理方法において、二分探索では、現在着目している画素の位置をx方向にΔxp移動させて、移動後の画素での誤差ep=Δxp*dy/dxを計算し、誤差epが1≦ep<2ならば、該移動後の画素を走査方向線分の終端画素とし、誤差epが0<ep<1あるいはep≧2ならば、Δxp←1/2*Δxpとして、当該画素をx座標が大あるいは小になる方向に更に移動させ、これを1≦ep<2になるまで繰り返すことを特徴とする。 According to a fourth aspect of the present invention, in the line segment drawing processing method according to the second or third aspect, in the binary search, the position of the pixel of interest is moved by Δx p in the x direction, and the error e p = Δx p * dy / dx calculated, the error e p if the 1 ≦ e p <2, the pixel after the mobile and end pixels in the scanning direction line, the error e p is 0 <e p If <1 or e p ≧ 2, Δx p ← 1/2 * Δx p is set, and the pixel is further moved in the direction in which the x coordinate becomes larger or smaller, and this is repeated until 1 ≦ e p <2. It is characterized by that.
請求項5の発明は、請求項1に記載の線分描画処理方法において、画面走査方向をx方向とし、線分の始点終点のx方向差分dx、y方向差分dyとし、2k*dy≦dx(kは定数)を満足するか判断し、満足する場合に二分探索を適用することを特徴とする。 According to a fifth aspect of the present invention, in the line segment drawing processing method according to the first aspect, the screen scanning direction is the x direction, the x direction difference dx and the y direction difference dy of the start point and the end point of the line segment are 2 k * dy ≦ It is determined whether dx (k is a constant) is satisfied, and when satisfied, a binary search is applied.
請求項6の発明は、請求項5に記載の線分描画処理方法において、定数kは少なくとも3以上の値とすることを特徴とする。 The invention according to claim 6 is the line segment drawing processing method according to claim 5, wherein the constant k is a value of at least 3 or more.
請求項7の発明は、請求項5あるいは6に記載の線分描画処理方法において、二分探索では、現在着目している画素の位置をx方向にΔxp移動させて、移動後の画素での誤差Ep=Δxp*dyを計算し、誤差Epがdx≦Ep<2*dxならば、該移動後の画素を走査方向線分の終端画素とし、誤差Epが0<Ep<dxあるいはEp≧2*dxならば、Δxp←1/2*Δxpとして、当該画素をx座標が大あるいは小になる方向に更に移動させ、これをdx≦Ep<2*Δxpになるまで繰り返すことを特徴とする。 According to a seventh aspect of the present invention, in the line segment drawing processing method according to the fifth or sixth aspect, in the binary search, the position of the pixel of interest is moved by Δx p in the x direction, and The error E p = Δx p * dy is calculated, and if the error E p is dx ≦ E p <2 * dx, the pixel after the movement is set as the end pixel of the scanning direction line segment, and the error E p is 0 <E p If <dx or E p ≧ 2 * dx, Δx p ← 1/2 * Δx p is set, and the pixel is further moved in the direction in which the x coordinate becomes larger or smaller, and this is dx ≦ E p <2 * Δx It repeats until it becomes p , It is characterized by the above-mentioned.
請求項8の発明は、請求項4あるいは7に記載の線分描画処理方法において、x方向移動量Δxpの初期値は、少なくとも画面のx方向の画素数の半分以上の値とすることを特徴とする。 The invention of claim 8 is the line drawing processing method according to claim 4 or 7, the initial value of the x-direction movement amount [Delta] x p is that more than half of the value of the number of pixels x direction of at least the screen Features.
請求項9の発明は、請求項8に記載の線分描画処理方法において、x方向移動量Δxpの初期値の値を、処理対象行が線分の終点の行に近づくに従って徐々に減少させることを特徴とする。 According to a ninth aspect of the present invention, in the line segment drawing processing method according to the eighth aspect, the value of the initial value of the x-direction movement amount Δx p is gradually decreased as the processing target line approaches the end line of the line segment. It is characterized by that.
請求項10の発明は、請求項1乃至9のいずれか1項に記載の線分描画処理方法を実施する線分描画処理装置を特徴とする。 A tenth aspect of the present invention is characterized by a line segment drawing processing apparatus that implements the line segment drawing processing method according to any one of the first to ninth aspects.
請求項11の発明は、撮像装置で撮影された撮像画像を処理する画像処理手段と、線分を生成する線分処理手段と、前記撮像画像に前記線分を重畳した合成画像を生成する合成手段と、前記合成画像を表示する表示手段からなる線分描画処理装置において、前記線分処理手段は、請求項10に記載の線分描画処理装置からなることを特徴とする。
According to an eleventh aspect of the present invention, there is provided an image processing unit that processes a captured image captured by an imaging device, a line segment processing unit that generates a line segment, and a composite that generates a composite image in which the line segment is superimposed on the captured image. And a line segment drawing processing apparatus comprising the display means for displaying the composite image, wherein the line segment processing means comprises the line drawing processing apparatus according to
本発明では、傾きが特に小さい線分の場合、線分を構成する画面各行の走査方向線分にの開始画素から終端画素を探索する処理に、線型探索でなく二分探索を行うことで、処理時間を短縮することができる。また、Δx,Δyを比較することで直線の傾きの大きさを判定し、新たな誤差Epを定義することで、除算を不要とし、小リソース環境の低コストで線分の描画処理が可能になる。なお、本発明のこれ以外の更なる作用効果は、以下の実施例の説明で明らかになる。 In the present invention, when the line segment has a particularly small inclination, the process for searching for the start pixel from the start pixel to the line segment in the scanning direction of each line of the screen constituting the line segment is performed by performing a binary search instead of a linear search. Time can be shortened. Further, [Delta] x, to determine the magnitude of the slope of the line by comparing the [Delta] y, by defining a new error E p, and unnecessary division, can drawing process of a line at a low cost small resource environment become. In addition, the further effect of this invention other than this becomes clear by description of a following example.
はじめに、本発明の線分描画処理方法について説明する。いま、図2(a)のように、多数の画素(ピクセル)から構成されたxy座標平面(画面)上に、始点Aと終点Bを結ぶ線分1を、該線分を構成する画面各行の走査方向線分を求める処理を繰り返し行って描画する場合を考える。始点Aの座標を(xs,ys)、終点Bの座標を(xe,ye)とし、画面走査方向はx方向とする。線分1の傾きdy/dxは(ye−ys)/(xe−xs)で表わされる。この傾きdy/dxを所定値αと比較する。αについては後述するが、例えばαは1/8程度が適当である。ここで、dy/dx>αの場合(描画する線分の傾きが大きい)は、線分1を構成する画面各行の走査方向線分を求めるのに、従来のブレゼンハム方式などのアルゴリズムを適用し、走査方向線分の開始画素から1画素ずつ順次、いわゆる線型探索を行って終端画素を探索する。一方、dy/dx≦αの場合(描画する線分の傾きが小さい)は、走査方向線分の開始画素を基準にして、二分探索により終端画素を探索する。これが本発明の特徴である。以下、二分探索について詳述する。
First, the line segment drawing processing method of the present invention will be described. Now, as shown in FIG. 2A, a
傾きdy/dxの線分上に存在する或る点Pが主走査方向(x方向)に1ピクセルずれた時、副走査方向(y方向)にdy/dxピクセルだけずれるが、傾きdy/dxが小さい場合、その点は線分上に存在し続けることになる。いま、点Pを主走査方向にΔxpピクセルずらした場合に、その点(ピクセル)が線分上に存在するための副走査方向のずれを誤差epと呼ぶ。すなわち、誤差epはep=Δxp*dy/dx(*は乗算)で表わされる。現在処理している行における、走査方向線分の開始画素(Pとする)から主走査方向にΔxpピクセルずらし、その時の誤差epが1≦ep<2になるような点(ピクセル)が、当該行の走査方向線分の終端画素の位置となる。 When a certain point P existing on a line segment having an inclination dy / dx is shifted by one pixel in the main scanning direction (x direction), the dy / dx pixel is shifted in the sub scanning direction (y direction), but the inclination dy / dx If is small, the point will remain on the line segment. Now, when the offset [Delta] x p pixels the point P in the main scanning direction is called sub-scanning direction of the displacement for the points (pixels) are present on a line with the error e p. In other words, the error e p is represented by e p = Δx p * dy / dx (* multiplication). In row currently being processed, shifting [Delta] x p pixels starting from the pixel (and P) in the main scanning direction of the scanning direction line, error ep is 1 ≦ e p <2 to become such points at that time (pixels) , The position of the end pixel of the line segment in the scanning direction.
なお、処理対象行の走査方向線分の開始画素は、前の行の走査方向線分の終端画素の位置から一意に決まる。また、描画する線分の最初の行の走査方向線分の開始画素は、該描画する線分の始点(図2(a)のA)の画素となる。 Note that the start pixel of the scanning direction line segment of the processing target row is uniquely determined from the position of the end pixel of the scanning direction line segment of the previous row. In addition, the start pixel of the line in the scanning direction of the first line to be drawn is the pixel of the start point of the line to be drawn (A in FIG. 2A).
図2(b)は、処理対象行を描画する線分1の最初の行(ys)とし、始点Aの画素を当該行の走査方向線分の開始画素Pとして、これから主走査方向(x方向)にΔxpピクセルずらした画素P’における線分1と誤差epの関係を示したものである。誤差epが1≦ep<2を満たすか判定し、満たさない場合、移動量を半分ずつ減少させながら、誤差epの大きさに応じて、画素P’の位置をx軸の正あるいは負方向に移動させる処理を繰り返し、誤差epが1≦ep<2を満たす画素P’の位置を探索する(二分探索)。誤差epが1≦ep<2を満した場合、その時の画素P’の位置を当該行(図2(b)ではys)の走査方向線分の終端画素として、画素Aから画素P’までの画素群を当該行の走査方向線分と決定する。次の行では、前の行の走査方向線分の終端画素を基に当該行の走査方向線分の開始画素を一義的に決定し、該開始画素を基準に同様に二分探索を行って終端画素を探索する。以下、同様の処理を終点Bの行(ye)まで繰り返す。
In FIG. 2B, the processing target row is the first row (y s ) of the
図3に、本発明の線分描画処理方法の基本処理フローを示す。この処理フローは、描画する線分の傾きdy/dxがdy/dx≦α(描画する線分の傾きが小さい)の場合に適用される。ここで、描画する線分の傾きがdy/dx≦α(αは例えば1/8)であることは、すでに判定済みとする。 FIG. 3 shows the basic processing flow of the line segment drawing processing method of the present invention. This processing flow is applied when the slope dy / dx of the line segment to be drawn is dy / dx ≦ α (the slope of the line segment to be drawn is small). Here, it is assumed that it is already determined that the slope of the line segment to be drawn is dy / dx ≦ α (α is, for example, 1/8).
いま、処理対象の行の走査方向線分の開始画素をPとし、該画素Pのx座標、y座標をxp,ypで表わす。まず、画素Pのx方向移動量Δxpの初期値を設定する(ステップ101)。この初期値については、計算コストを減らすため、2の階乗値にする。初期値の大きさは、画面の主走査方向の画素数の半分以上の値にすればよい。例えば、画面サイズを180(主走査方向画素数)×120(副走査方向画素数)とした場合、Δxpの初期値を27(=128)とする。なお、この初期値の値は、処理済みの行が所定数になる毎に、すなわち、線分の終点の行に近づくに従い、順次、減少するようにしてもよい。これにより、二分探索の回数を減らすことが可能になる。 Now, let P be the start pixel of the line in the scanning direction of the row to be processed, and x and y coordinates of the pixel P be represented by x p and y p . First, an initial value of the movement amount Δx p of the pixel P in the x direction is set (step 101). The initial value is set to a factorial value of 2 in order to reduce calculation cost. The size of the initial value may be a value that is half or more of the number of pixels in the main scanning direction of the screen. For example, when the screen size is 180 (number of pixels in the main scanning direction) × 120 (number of pixels in the sub scanning direction), the initial value of Δx p is 2 7 (= 128). Note that the value of the initial value may be sequentially decreased every time the number of processed rows reaches a predetermined number, that is, as the end of the line segment is approached. This makes it possible to reduce the number of binary searches.
次に、画素Pの位置をx方向にΔxp移動させ(ステップ102)、移動後の画素P(便宜上、P’とする)の位置での誤差epを計算する(ステップ103)。先に述べたように、誤差epはep=Δxp*dy/dxで表わされる。 Next, [Delta] x p is moved (step 102) the position of the pixel P in the x direction, the pixel after movement P (for convenience, and P ') for calculating an error e p at the position (step 103). As mentioned earlier, the error e p is represented by e p = Δx p * dy / dx.
次に、誤差epの大きさを判定する(ステップ104)。ここで、1≦ep<2ならば、画素P’を当該行の走査方向線分の終端画素として、画素Pから画素P’までの画素群を当該行の走査方向線分と決定し(ステップ105)、当該行の処理が終了となる。そして、処理は次の行に移行する。 Next, it is determined the magnitude of the error e p (step 104). Here, if 1 ≦ e p <2, the pixel group from the pixel P to the pixel P ′ is determined as the scanning direction line segment of the row, with the pixel P ′ as the end pixel of the scanning direction line segment of the row ( Step 105), the processing of the row is completed. Then, the process moves to the next line.
一方、0<ep<1ならば、現在の画素P’の位置からx座標が大きくなる方向(正方向)に画素P’を移動させるような移動量Δxpを設定する(ステップ106)。この時の移動量Δxpは前の半分とする。移動量Δxpを設定後、ステップ102へ戻る。また、ep≧2ならば、現在の画素P’の位置からx座標が小さくなる方向(負方向)に画素P’を移動させるような移動量Δxpを設定する(ステップ107)。この時も、該移動量Δxpは前の半分とする。移動量Δxpを設定後、同様にステップ102に戻る。以後、1≦ep<2になるまで、ステップ102,103,104,106または107をループし、1≦ep<2になったならステップ105に進む。 On the other hand, if 0 <e p <1, a movement amount Δx p is set such that the pixel P ′ is moved in the direction (positive direction) in which the x coordinate increases from the current position of the pixel P ′ (step 106). At this time, the movement amount Δx p is set to the previous half. After setting the movement amount Δx p , the process returns to step 102. If e p ≧ 2, a movement amount Δx p is set so as to move the pixel P ′ from the current position of the pixel P ′ in the direction in which the x coordinate decreases (negative direction) (step 107). Also at this time, the movement amount Δx p is set to the former half. After setting the movement amount [Delta] x p, likewise returns to step 102. Thereafter, until 1 ≦ e p <2, the steps 102,103,104,106 or 107 loop, proceed to 1 ≦ e p <Step 105 if became 2.
図4に、図3の処理フローの具体的な処理イメージを示す。図4(a)は、多数の画素から構成されたxy座標平面の画面全体を示し、図4(b)は、その一部分(線分を描画する部分)を拡大して示したものである。ここでも、画面走査方向はx方向とする。 FIG. 4 shows a specific processing image of the processing flow of FIG. FIG. 4A shows the entire screen of the xy coordinate plane composed of a large number of pixels, and FIG. 4B shows an enlarged portion (portion for drawing a line segment). Again, the screen scanning direction is the x direction.
いま、描画する線分の始点をA、終点をBとし、y=n−1行までの線分描画処理が完了し、y=n行での線分描画処理を開始する場合を考える。なお、図4(a)の黒線は、描画済みの線分を示したものである。 Consider a case where the starting point of a line segment to be drawn is A, the end point is B, the line drawing process up to y = n−1 lines is completed, and the line drawing process on y = n lines is started. Note that the black lines in FIG. 4A indicate the drawn line segments.
図4(b)において、Pはy=n行の走査方向線分の開始画素で、該画素Pのx座標、y座標をそれぞれxp,ypと表わし、(xp,yp)=(m,n)とする。該画素Pは、前の行y=n−1の走査方向線分の終端画素peの位置(m−1,n−1)から一意に決定することができる。まず、移動量Δxpの初期値を設定して、画素Pからx座標正方向にΔxpピクセル移動し、移動後の画素P1について、誤差epを求め、該誤差epが1≦ep<2を満足するか判定する。ここでは満足せず、ep≧2であったため、次に、画素P1からx座標負方向に前回の1/2Δxpピクセル移動し、移動後の画素P2について、誤差epを求め、該誤差epが1≦ep<2を満足するか判定する。ここでも満足せず、まだep≧2であったため、再び、画素P2からx座標負方向に前回の更に半分の1/4Δxpピクセル移動し、移動後の画素P3について、誤差epを求め、該誤差epが1≦ep<2を満足するか判定する。ここでも満足せず、今度は0<ep<1であったため、画素P3からx座標正方向に前回の半分の1/8Δxpピクセル移動し、移動後の画素P4について、誤差epを求め、該誤差epが1≦ep<2を満足するか判定する。ここで満足したので、画素P4(m’,n)をy=n行の走査方向の線分の終端画素とし、m≦x<m’の範囲の画素群(PからP4までの画素)を、y=n行での走査方向線分と決定する。そして、これら画素群が塗り潰されることになる。 In FIG. 4 (b), P represents the start pixel in the scanning direction line of y = n rows, x-coordinate of the pixel P, respectively y coordinates x p, and y p, (x p, y p) = (M, n). Pixel P can be uniquely determined from the position of the previous line y = n-1 of the end pixel p e in the scanning direction line (m-1, n-1 ). First, by setting the initial value of the movement amount [Delta] x p, move [Delta] x p pixels x coordinate positive direction from the pixel P, the pixel P 1 after movement, determine the error e p, said error e p is 1 ≦ e It is determined whether p <2 is satisfied. Since it was not satisfied here and e p ≧ 2, next, the previous half Δx p pixel is moved in the negative x coordinate direction from the pixel P 1 , and the error e p is obtained for the pixel P 2 after the movement, said error e p determines whether satisfies 1 ≦ e p <2. Again, since e p ≧ 2, it was still ep ≧ 2, and again moved from the pixel P 2 in the negative x coordinate direction by a quarter ∆x p pixel, and the error e p for the pixel P 3 after the movement. look, determine whether said error e p satisfies 1 ≦ e p <2. Again, because 0 <e p <1, this time, the pixel P 3 moves from the pixel P 3 in the positive x-coordinate in the previous half by 1 / 8Δx p pixels, and the error e p for the pixel P 4 after the movement look, determine whether said error e p satisfies 1 ≦ e p <2. Since we are satisfied here, the pixel P 4 (m ′, n) is the terminal pixel of the line segment in the scanning direction of y = n rows, and the pixel group (pixels from P to P 4) in the range of m ≦ x <m ′. ) Is determined as a line segment in the scanning direction at y = n rows. Then, these pixel groups are filled.
次に処理は、y=n+1行に進むが、その走査方向線分の開始画素P(xp,yp)は、前のy=n行での線分終端画素P4の位置(m’,n)を基に、P(xp,yp)=(m’+1,n+1)と決定される。 Next, the processing proceeds to the y = n + 1 row, and the start pixel P (x p , y p ) of the scanning direction line segment is positioned at the position (m ′, line) of the line segment end pixel P4 in the previous y = n row. n), P (x p , y p ) = (m ′ + 1, n + 1) is determined.
以上、本発明の線分描画処理方法の基本的考え方を説明したが、描画する線分の傾きや方向は、図4のような場合とは限らず、例えば、図5(a)〜(c)のような場合も考えられる。いずれの場合も、Aは始点、Bは終点とする。ここで、図5(a)の場合は、着目する行において、最初は当該行の走査方向線分の開始画素をx座標負方向にΔxpピクセル移動するようにすればよい。その後の処理は、図4の場合と同様である。また、図5(b)や(c)の場合は、主走査方向をy方向とすればよい。 The basic idea of the line segment drawing processing method of the present invention has been described above. However, the inclination and direction of the line segment to be drawn are not limited to those shown in FIG. 4, for example, FIGS. ) Is also considered. In either case, A is the start point and B is the end point. Here, in the case of FIG. 5A, in the target row, first, the start pixel of the line in the scanning direction of the row may be moved by Δx p pixels in the negative x coordinate direction. The subsequent processing is the same as in FIG. In the case of FIGS. 5B and 5C, the main scanning direction may be the y direction.
傾きが特に小さい線分の場合、上述のように二分探索方式を用いて、各行毎に走査方向線分の終端画素を探索することにより、従来のブレゼンハム方式のように、走査方向線分の開始画素から1画素ずつ誤差項を求めて終端画素を探索(線型探索)する場合に比べて、処理時間を短縮することが可能になる。 When the line segment has a particularly small slope, the binary search method as described above is used to search the end pixel of the scan direction line segment for each row, thereby starting the scan direction line segment as in the conventional Bresenham method. The processing time can be shortened as compared with the case where an error term is obtained pixel by pixel and the end pixel is searched (linear search).
次に、本発明の線分描画処理方法の具体的な実施例について説明する。 Next, specific examples of the line segment drawing processing method of the present invention will be described.
図1は、本発明の線分描画処理機能を備えた撮像画像処理装置の一実施形態の全体構成を示した図である。なお、撮像画像処理装置は、他に操作部などを備えているが、図1では省略してある。 FIG. 1 is a diagram showing an overall configuration of an embodiment of a captured image processing apparatus having a line segment drawing processing function of the present invention. The captured image processing apparatus includes an operation unit and the like, which are omitted in FIG.
カメラなどの撮像装置10で撮影された画像データは画像処理部20に送られる。画像データは、一般にカラー画像データであるが、モノクロ画像データでもよい。ここで、撮像装置10からは、画像データと共に、画面(フレーム)の開始を示す同期信号Vsync、画面(フレーム)の各行の開始を示す同期信号Hrefも送出される。
Image data captured by the
画像処理部20は、撮像装置10から送られた画像データに対して所定の画像処理を施す。所定の画像処理とは、例えば、ベイヤー補完処理、倍率色収差補正処理、YUV変換処理、MTF補正処理、歪曲収差補正処理、γ補正処理などである。これらの画像処理は、同期信号Vsync、Hrefなどに同期して実施され、処理結果の画像データはフレームメモリ50に格納される。各画像処理は、一般にシーケンシャルに実施されるため、画像処理部20とフレームメモリ50との間のデータの流れは双方向になる。
The
線分処理部30は、画像処理部20から同期信号Vsync、Hrefを受け取り、該同期信号に同期して線分処理を実行する。線分の始点・終点座標は、あらかじめ線分メモリ40に保持しておく。描画する線分は、1つ以上いくつでもよい。線分処理部30では、フレーム毎に同期信号Vsyncに同期して、線分メモリ40から処理対象線分の始点・終点座標を読み込んで、線分の傾き、走査方向線分の開始画素などの初期値計算を行った後、同期信号Hrefに同期して、フレームの各行毎に、描画すべき線分(走査方向線分)の画素を決定する。その結果は線分メモリ40に保持される。ここで、線分メモリ40に保持される値は、走査方向線分の各画素の表示色などを表わすデータであり、線分を赤色で表示する場合、走査方向線分の各画素に対応するメモリアドレスに赤色の画素データが保持される。
The line
合成部60では、線分メモリ40に保持された走査方向線分の各画素の表示色などを表わす画素データと、フレームメモリ50に保持された画像データとを入力して、画像上に線分を重畳する処理を行う。表示装置70は、合成部60から出力された撮影画像と、線分の重畳画像をモニタ表示する。例えば、撮影画像に重畳して、線分を赤色で表示する。なお、線分の種類ごとに色分けして表示することも可能である。
The synthesizing
ここで、本発明の特徴は線分処理部30にある。線分処理部30は、例えばマイクロプロセッサからなり、アセンブラ言語などを用いて線分描画の処理を実行する。以下、線分処理部30での線分描画処理について詳述する。
Here, the feature of the present invention resides in the line
図6に線分処理部30の全体的な処理フローを示す。線分処理部30での線分描画処理は画像処理部20側の処理と同期して行われる必要がある。そこで、線分処理部30は、画像処理部20から同期信号が到来するのを待つ(ステップ201)。画像処理部20から同期信号を受け取ると、該同期信号がVsync信号かHref信号か判断する(ステップ202)。Vsync信号は画面(フレーム)の開始を示す同期信号、Href信号は画面の各行の開始を示す信号である。Vsync信号を受け取った場合にはVsync処理を実行し(ステップ203)、Href信号を受け取った場合にはHref処理を実行する(ステップ204)。その後、ステップ201に戻る。ここで、Vsync処理では、主に線分描画処理のための前処理が実行される。Href処理では、フレーム各行の走査方向線分描画処理が実行される。
FIG. 6 shows an overall processing flow of the
図7はVsync処理の概略処理フローである。線分処理部30は、画面(フレーム)の開始を示すVsync信号がオンになると(ステップ301)、線分描画処理のための初期値を計算する(ステップ302)。初期値は、描画する線分の傾き、先頭行の走査方向線分の開始画素の座標などである。線分処理部30は、処理対象線分の始点座標(xs,ys)、終点座標(xe,ye)を線分メモリ40から読み出して、傾きdy/dxを計算すると共に、始点座標(xs,ys)を描画する線分の先頭行の走査方向線分の開始画素座標とする。そして、該描画する線分の傾き、開始画素座標などの初期値を、線分メモリ40に保存する(ステップ303)。
FIG. 7 is a schematic process flow of the V sync process. When the V sync signal indicating the start of the screen (frame) is turned on (step 301), the line
なお、ここでは、線分の傾きdy/dxにかえて、dx=xe−xs,dy=ye−ys
を線分メモリ40に保持するとする。これにより、dy/dxを計算する必要がなく、除算を省略することができる。
Here, instead of the line of the slope dy / dx, dx = x e -x s, dy = y e -y s
Is stored in the
図8はHref処理の概略処理フローである。線分処理部30は、画面(フレーム)の各行の開始を示すHref信号がオンになると(ステップ401)、線分メモリ40から初期値を読み込む(ステップ402)。そして、線分の傾きdy/dxが所定値α以下かどうか判定する(ステップ403)。ここでは、除算を必要としないように、2k*dy≦dxかどうか判定する。すなわち、dyをkビットシフトして大きくした値とdxを比較し、dxが等しいか大きければ、線分の傾きは主走査方向に対して小さいと判断できる。例えば、α=1/8は、k=3の場合に対応する。
FIG. 8 is a schematic process flow of the H ref process. When the H ref signal indicating the start of each row of the screen (frame) is turned on (step 401), the line
線分の傾きdy/dxがdy/dx≦αの場合、すなわち、2k*dy≦dxである場合には、二分探索処理により、着目する行について、走査方向線分の開始画素から探索を開始して、走査方向線分の終端画素を求める(ステップ404)。そして、走査方向線分の開始画素と終端画素とこれらに挟まれた画素とを線分描画画素として画素データを線分メモリ40へ保存する(ステップ406)。例えば、線分メモリ40内の対応するメモリアドレスに赤色などの画素データを保存する。また、求まった走査方向線分の終端画素の走査方向位置から走査方向へ1ピクセルずらした位置の座標値を、同様に線分メモリ40へ保存する。一方、線分の傾きdy/dxがdy/dx>αの場合、すなわち、2k*dy>dxである場合には、ブレゼンハム方式などを適用して、線型探索処理により、着目する行について、走査方向線の開始画素から1画素ずつ探索を行って、走査方向線分の終端画素を求める(ステップ405)。そして、ステップ406へ進む。
When the slope dy / dx of the line segment is dy / dx ≦ α, that is, 2 k * dy ≦ dx, a search is performed from the start pixel of the line segment in the scanning direction by the binary search process. Starting, the end pixel of the scanning direction line segment is obtained (step 404). Then, the pixel data is stored in the
二分探索処理や線型探索処理は、実際には描画する線分の始点の行(線分の先頭行)から開始して、終点の行で終了となる。処理が線分の先頭行の時、線分メモリ40に初期値として保存されている処理対象線分の始点座標に対応する画素が、該先頭行の走査方向線分の開始画素として用いられる。それ以降の各行では、順次、ステップ406で線分メモリへ保存される、前の行の走査方向線分の終端画素の走査方向位置から走査方向へ1ピクセルずらした位置の座標値に対応する画素が当該行の走査方向線分の開始画素として利用される。
The binary search process and the linear search process actually start from the start line of the line segment to be drawn (the first line of the line segment) and end at the end line. When the process is the first line of the line segment, the pixel corresponding to the start point coordinates of the process target line segment stored as the initial value in the
なお、図8において、ステップ403の線分の傾き判定は、最初にHref信号がオンになった場合にのみ、すなわち、処理対象の行が画面先頭行に戻った場合にのみ実行し、それ以降はステップ403はスキップして、直ちにステップ404あるいは405に進むようにしてもよい。また、図7のステップ302の初期値計算で、線分の傾き判定も実行して、その判定結果を線分メモリ40に保存しておくとこでもよい。
In FIG. 8, the slope determination of the line segment in
図9は図8の二分探索処理(ステップ404)についての具体的な処理フローを示したものである。これは、先の図3の処理フローと基本的に同じであるが、誤差epに替えて新たに誤差Epを定義して、傾きdy/dxの除算を不要としたものである。また、描画する線分は、図2(a)に示したような線分としている。 FIG. 9 shows a specific processing flow for the binary search process (step 404) of FIG. This is a process flow basically the same as that of FIG. 3 before, by defining a new error E p in place of the error e p, is obtained by eliminating the need for division of the slope dy / dx. Further, the line segment to be drawn is a line segment as shown in FIG.
処理対象の行の走査方向線分の開始画素をPとし、該画素Pのx座標、y座標をxp,ypで表わす。まず、画素Pのx方向移動量Δxpの初期値を設定する(ステップ501)。ここでは、Δxpの初期値は27とする。先に述べたように、このΔxpの初期値は、画面の主走査方向の画素数の半分以上の値にするのが望ましい。また、処理済みの行が所定数になるごとに、順次、値を減少するようにしてもよい。 The start pixel of the scanning direction line segment of the row to be processed is represented by P, and the x coordinate and y coordinate of the pixel P are represented by x p and y p . First, an initial value of the movement amount Δx p of the pixel P in the x direction is set (step 501). Here, the initial value of [Delta] x p is 2 7. As described above, the initial value of Δx p is preferably set to a value that is half or more of the number of pixels in the main scanning direction of the screen. Alternatively, the value may be sequentially decreased every time a predetermined number of processed rows are reached.
次に、画素Pの位置をx方向にΔxp移動させる(ステップ502)。そして、この移動後の画素P(便宜上、P’とする)が、当該行の走査方向線分の終端画素となるか否か調べるため、画素P’での誤差を計算する(ステップ503)。 Next, the position of the pixel P is moved by Δx p in the x direction (step 502). Then, an error at the pixel P ′ is calculated in order to check whether or not the pixel P after the movement (for convenience, P ′) is the terminal pixel of the line in the scanning direction of the row (step 503).
先に述べたように、誤差はep=Δxp*dy/dxで表わされる。該誤差epが1≦ep<2になるような点(ピクセル)が、当該行の走査方向線分の終端画素となる。しかし、dy/dxの値を求めるには、除算を必要とする。先の線分の傾き判定に2k*dy≦dxを定義して除算を不要としたように、ここでは、誤差epにかえて新たに誤差Ep=dx*ep=Δxp*eyを定義する。該誤差Epがdx≦Ep<2*dxとなるような点(ピクセル)を求めれば、それが当該行の走査方向線分の終端画素となる。このように誤差Epを定義することで、傾きdy/dxの値を必要とせず、除算なしで走査方向線分の終点画素を求めることができる。 As described above, the error is expressed as e p = Δx p * dy / dx. It said error e p is 1 ≦ e p <2 to become such points (pixels), the end pixel in the scanning direction line of the row. However, division is required to obtain the value of dy / dx. Here, in order to define 2 k * dy ≦ dx for the determination of the inclination of the previous line segment and to eliminate the need for division, here, a new error E p = dx * e p = Δx p * e is substituted for the error e p. Define y . By obtaining a point such said error E p is dx ≦ E p <2 * dx (in pixels), it is the end pixel in the scanning direction line of the row. By thus defining the error E p, it does not require the value of the slope dy / dx, without division can be obtained end pixel in the scanning direction line.
次に、誤差Epの大きさにより、二分探索処理を終了させるか、継続させるか判断する(ステップ504)。ここで、dx≦Ep<2*dxならば、画素P’を当該行の走査方向線分の終端画素として、画素Pから画素P’までの画素群を当該行の走査方向線分と決定する(ステップ505)。0<Ep<dxならば、現在の画素P’の位置からx座標が大きくなる方向(正方向)に画素P’を移動させるような移動量Δxpを設定する(ステップ506)。このときの移動量Δxpは前の半分にする。移動量Δxpを設定後、ステップ502へ戻る。また、Ep≧2*dxならば、現在の画素P’の位置からx座標が小さくなる方向(負方向)に画素P’を移動させるような移動量Δxpを設定する(ステップ507)。この時も該移動量Δxpは前の半分にする。移動量Δxpを設定後、同様にステップ502へ戻る。 Next, the magnitude of the error E p, or to terminate the binary search processing, determines whether to continue (step 504). Here, if dx ≦ E p <2 * dx, the pixel group from the pixel P to the pixel P ′ is determined as the scanning direction line segment of the row, with the pixel P ′ as the terminal pixel of the scanning direction line segment of the row. (Step 505). If 0 <E p <dx, a movement amount Δx p is set such that the pixel P ′ is moved in the direction (positive direction) in which the x coordinate increases from the current position of the pixel P ′ (step 506). At this time, the movement amount Δx p is set to the previous half. After setting the movement amount Δx p , the process returns to Step 502. If E p ≧ 2 * dx, a movement amount Δx p is set so as to move the pixel P ′ from the current position of the pixel P ′ in the direction in which the x coordinate decreases (negative direction) (step 507). Also at this time, the movement amount Δx p is set to the previous half. After setting the movement amount [Delta] x p, likewise returns to step 502.
これまで、処理対象線分を1本として説明してきたが、一般に画像に重畳する線分は1本とは限らない。以下に、処理対象線分を複数に拡張した場合の線分処理部30での線分描画処理について説明する。全体の処理フローは図6と同様である。
Up to now, the processing target line segment has been described as one, but in general, the number of line segments to be superimposed on an image is not necessarily one. The line drawing process in the
図10は、線分処理部30がVsync信号を受け取った際の処理フローである。処理対象線分の総数、各線分の始点と終点の座標などはあらかじめ線分メモリ40に保持されているとする。
FIG. 10 is a processing flow when the
まず、nを1に初期設定する(ステップ601)。次に、n本目の線分について、その始点と終点の座標を線分メモリ40から読み込み(ステップ602)、ラインプロパティ(LP)を計算する(ステップ603)。ここで、線分描画処理の際に頻繁に利用される種々の値をラインプロパティ(LP)と呼ぶことにする。 First, n is initially set to 1 (step 601). Next, for the nth line segment, the coordinates of the start point and end point are read from the line segment memory 40 (step 602), and the line property (LP) is calculated (step 603). Here, various values frequently used in the line segment drawing process are referred to as line properties (LP).
ラインプロパティ(LP)の具体的な値としては、
傾きの方向を示す値:StepX
終点のY座標:ye
始点終点のX方向差分:dx
始点終点のY方向差分:dy
線分描画点のX座標:DrawX
線分描画点のY座標:DrawY
などがある。
Specific values of the line property (LP)
A value indicating the direction of inclination: StepX
Y coordinate of the end point: y e
X direction difference between start and end points: dx
Difference in Y direction between start point and end point: dy
X coordinate of line drawing point: D raw X
Y coordinate of line drawing point: D raw Y
and so on.
StepXは傾きの方向(“/” or “\” の方向)を示す値である。この値により、線分の始点から終点への向きが分かるようになる。DrawXの更新の際に利用される。yeは直線の描画処理を終了する際に利用される。dxとdyは直線の傾きの大きさを判断する際に利用される。DrawX,DrawYは現在描画処理中の線分における着目行の走査方向線分のカレントX座標、Y座標を表し、描画処理中に値が更新されていく。この座標(DrawX,DrawY)で示される点(画素)に沿って線分は描画されることになる。 StepX is a value indicating the direction of inclination (direction of “/” or “\”). With this value, the direction from the start point to the end point of the line segment can be known. Used when updating D raw X. y e is used when the straight line drawing process ends. dx and dy are used when determining the magnitude of the slope of the straight line. D raw X and D raw Y represent the current X coordinate and Y coordinate of the line in the scanning direction of the line of interest in the line currently being drawn, and the values are updated during the drawing. A line segment is drawn along a point (pixel) indicated by the coordinates (D raw X, D raw Y).
ここで、ラインプロパティ(LP)は以下のように算出される。 Here, the line property (LP) is calculated as follows.
StepX=(終点のX座標−始点のX座標)の符号値(1 or −1)
ye=終点のY座標
dx=|終点のX座標−始点のX座標|
dy=|終点のY座標−始点のY座標|
DrawX=線分の始点のX座標
DrawY=線分の始点のY座標
なお、StepX,ye,dxとdyは処理対象線分の描画処理を通して定数として扱われるが、DrawXとDrawYは後述のLP更新処理の際に値が変更されていく。ステップ603で設定されるDrawXとDrawYは初期値である。
StepX = (Signal value of end point X coordinate-start point X coordinate) (1 or -1)
y e = Y coordinate of the end point
dx = | End point X coordinate-Start point X coordinate |
dy = | Y coordinate of the end point−Y coordinate of the start point |
D raw X = X coordinate of the start point of the line segment
D raw Y = the Y coordinate of the start point of the line segment Note that Step X, y e , dx and dy are treated as constants through the drawing process of the line segment to be processed, but D raw X and D raw Y are used in the LP update process described later. When the value is changed. D raw X and D raw Y set in
次に、ステップ603で算出したラインプロパティ(LP)を線分メモリ40に存在する。そして、全ての処理対象線分のラインブプロパティを計算したか判定し(ステップ605)、未処理のものがあれば、nを+1して(ステップ606)、ステップ602に戻る、以下、全ての処理対象線分のラインプロパティを計算して、Vsync処理が終了となる。
Next, the line property (LP) calculated in
図11は、線分処理部30がHref信号を受け取った際の処理フローを示したものである。まず、nを1に初期設定する(ステップ701)。次に、n本目の線分について、その時点のラインプロパティ(LP)を線分メモリ40から読み込む(ステップ702)。次に、現在処理対象になっている行(sFとする)に、DrawYが一致するか判定する(ステップ703)。sF≠DrawYならば、現在処理対象になっている行について、当該線分の線分描画処理を開始する必要がないため、そのまま、ステップ710に行く。
FIG. 11 shows a processing flow when the
一方、sF=DrawYならば、当該線分の現在処理対象になっている行の線分描画処理を開始する。初めに、当該線分の傾きの大きさを判断する(ステップ704)。ここでは、先に述べたように、dy/dx≦αのかわりに2k*dy≦dx(kは定数)を用いて判断する。すなわち、2k*dy≦dxならば、主走査方向に対する傾きが特に小さい線分と判断できる。2k*dy≦dxの場合、二分探索処理により、当該線分の現在処理対象になっている行の走査方向線分を求める(ステップ705)。これは図9と同じである。すなわち、図9のxpをDrawXに置き換えればよい。2k*dy>dxの場合には、従来のブレゼンハム方式などを適用して線型探索処理により、当該線分の現在の処理対象になっている行の走査方向線分を求める(ステップ706)。そして、ステップ705あるいは706で求まった当該線分の処理対象行の走査方向線分に対応する画素群の画素データ(例えば、赤色データ)を線分メモリ40の該当アドレスに書き込む(ステップ707)。
On the other hand, if sF = D raw Y, the line segment drawing process for the line currently being processed is started. First, the magnitude of the inclination of the line segment is determined (step 704). Here, as described above, the determination is performed using 2 k * dy ≦ dx (k is a constant) instead of dy / dx ≦ α. That is, if 2 k * dy ≦ dx, it can be determined that the line segment has a particularly small inclination with respect to the main scanning direction. If 2 k * dy ≦ dx, a line segment in the scanning direction of the row currently being processed is obtained by the binary search process (step 705). This is the same as FIG. That is, x p in FIG. 9 may be replaced with D raw X. When 2 k * dy> dx, the line segment in the scanning direction of the line currently being processed is obtained by linear search processing using the conventional Bresenham method or the like (step 706). Then, the pixel data (for example, red data) of the pixel group corresponding to the scanning direction line segment of the processing target row obtained in
次に、DrawYが当該線分の終点のY座標yeに一致するか判定する(ステップ708)。DrawY=yeならば、そのままステップ710にいく。DrawY≠yeならば、当該線分の次の行における線分描画処理のため、DrawXとDrawYの値を次のように更新する(ステップ709)
DrawX ← DrawX+StepX
DrawY ← DrawY+1
これらの値が、当該線分における次の行の走査方向線分の開始画素の座標値となる。更新後、線分メモリ40に保存する。
Next, it is determined whether or not D raw Y matches the Y coordinate y e of the end point of the line segment (step 708). If D raw Y = y e, it goes to step 710. If D raw Y ≠ y e , the values of D raw X and D raw Y are updated as follows for the line segment drawing process in the next row of the line segment (step 709).
D raw X ← D raw X + Step X
D raw Y ← D raw Y + 1
These values become the coordinate values of the start pixel of the line segment in the scanning direction of the next row in the line segment. After the update, it is stored in the
その後、全ての処理対象線分について処理したか判定し(ステップ710)、未処理のものがあれば、nを+1して(ステップ711)、ステップ702に戻る。以下、処理対象線分の数だけステップ702〜711の処理を繰り返す。
Thereafter, it is determined whether or not all the processing target line segments have been processed (step 710). If there is an unprocessed line segment, n is incremented by 1 (step 711), and the process returns to step 702. Thereafter, the processing in
次に、二分探索処理と線形探索処理を場合分けする際に用いられる、線分の傾きdy/dxの閾値αの具体的値について説明する。図12は、種々の傾きの線分について、線形探索処理と二分探索処理により描画した場合の命令数を比較したものである。ここで、線型探索には通常のブレゼンハムアルゴリズムを用いた。また、画面サイズは180(主走査方向画素数)×120(副走査方向の画素数)であり、二分探索処理ではΔxpの初期値を27とした。命令数は、各行の線分描画処理に掛かる命令数のうち、最大の命令数を意味する。図12より、線分の傾きdy/dxが特に1/8=0.125以下の場合に、二分探索処理を適用すればよいことが分かる。先に述べたように、α=1/2kの関係にあり、α=1/8は、k=3の場合に対応する。したがって、23*dy≦dxの場合、二分探索処理を適用すればよいとも云える。この場合、dyをビットシフトした値とdxを比較するだけで、線分の傾きが特に小さいか否か判断でき、除算が不要になる。 Next, a specific value of the threshold α of the line segment inclination dy / dx used when the binary search process and the linear search process are divided into cases will be described. FIG. 12 shows a comparison of the number of instructions when drawing by linear search processing and binary search processing for various slope line segments. Here, the normal Bresenham algorithm was used for the linear search. Also, the screen size is 180 (the main scanning direction pixel number) × 120 (number of sub-scanning direction pixel), a binary search process was 2 7 the initial value of [Delta] x p. The number of instructions means the maximum number of instructions among the number of instructions required for line drawing processing of each row. From FIG. 12, it is understood that the binary search process may be applied when the slope dy / dx of the line segment is 1/8 = 0.125 or less. As described above, α = 1/2 k , and α = 1/8 corresponds to the case of k = 3. Therefore, when 2 3 * dy ≦ dx, the binary search process may be applied. In this case, it is possible to determine whether the slope of the line segment is particularly small by simply comparing the value obtained by bit-shifting dy with dx, and division is not necessary.
なお、二分探索処理と線形探索処理を場合分けするための判断基準である線分の傾きの閾値αや1/2kの最適値は、上記の具体例に限定されないことは云うまでもない。 Needless to say, the threshold value α of the slope of the line segment and the optimum value of 1/2 k , which are judgment criteria for dividing the binary search process and the linear search process into cases, are not limited to the above specific examples.
また、本発明の具体的実施形態として、撮像画像に線分を重畳して表示する実施例を示したが、本発明の線分描画処理方法の適用は、これに限定されるものではない。 Moreover, although the example which superimposes and displays a line segment on a captured image was shown as concrete embodiment of this invention, application of the line segment drawing processing method of this invention is not limited to this.
10 撮像装置
20 画像処理部
30 線分処理部
40 線分メモリ
50 フレームメモリ
60 合成部
70 表示装置
DESCRIPTION OF
Claims (11)
走査方向に対する線分の傾きが所定値以下か否か判断し、
前記線分の傾きが所定値以下の場合には、線分を構成する画面各行の走査方向線分の開始画素から二分探索を行って該走査方向線分の終端画素を探索し、
前記線分の傾きが所定値以下でない場合には、線分を構成する画面各行の走査方向線分の開始画素から1画素ずつ探索を行う、線型探索を行って該走査方向線分の終端画素を探索する、
ことを特徴とする線分描画処理方法。 Specify the start and end points of a line segment on a two-dimensional screen composed of a large number of pixels, and draw the line segment from the start point toward the end point by finding the line segment in the scanning direction of each line that makes up the line segment. In the line segment drawing processing method to
Determine whether the slope of the line segment with respect to the scanning direction is less than or equal to a predetermined value,
When the slope of the line segment is equal to or less than a predetermined value, a binary search is performed from the start pixel of the scan direction line segment of each screen row constituting the line segment to search for the end pixel of the scan direction line segment,
If the slope of the line segment is not less than or equal to a predetermined value, a search is performed pixel by pixel from the start pixel of the scanning direction line segment of each row constituting the line segment, a linear search is performed, and the end pixel of the scanning direction line segment Explore
A line segment drawing method characterized by the above.
線分の傾きdy/dxを計算して、dy/dx≦αを満足するか判断し、満足する場合に二分探索を適用することを特徴とする請求項1に記載の線分描画処理方法。 The screen scanning direction is the x direction, the x direction difference dx and the y direction difference dy of the start point and end point of the line segment,
The line segment drawing processing method according to claim 1, wherein a slope dy / dx of the line segment is calculated to determine whether dy / dx ≦ α is satisfied, and when the condition is satisfied, a binary search is applied.
誤差epが0<ep<1あるいはep≧2ならば、Δxp←1/2*Δxpとして、当該画素をx座標が大あるいは小になる方向に更に移動させ、これを1≦ep<2になるまで繰り返す、
ことを特徴とする請求項2あるいは3に記載の線分描画処理方法。 The binary search, and the position of the pixel of interest currently is [Delta] x p moved in the x-direction, the error e p = Δx p * dy / dx of the pixel after movement is calculated, the error e p is 1 ≦ e p If <2, the pixel after the movement is the end pixel of the scanning direction line segment,
If the error e p is 0 <e p <1 or e p ≧ 2, as Δx p ← 1/2 * Δx p, is further moved in the direction of the pixel x-coordinate becomes large or small, 1 ≦ it Repeat until e p <2.
The line segment drawing method according to claim 2 or 3,
2k*dy≦dx(kは定数)を満足するか判断し、満足する場合に二分探索を適用することを特徴とする請求項1に記載の線分描画処理方法。 The screen scanning direction is the x direction, the x direction difference dx and the y direction difference dy of the start point and end point of the line segment,
2. The line segment drawing processing method according to claim 1, wherein it is determined whether or not 2 k * dy ≦ dx (k is a constant) and a binary search is applied when the condition is satisfied.
誤差Epが0<Ep<dxあるいはEp≧2*dxならば、Δxp←1/2*Δxpとして、当該画素をx座標が大あるいは小になる方向に更に移動させ、これをdx≦Ep<2*Δxpになるまで繰り返す、
ことを特徴とする請求項5あるいは6に記載の線分描画処理方法。 In the binary search, the position of the pixel of interest is moved by Δx p in the x direction, and an error E p = Δx p * dy in the pixel after the movement is calculated, and the error E p is dx ≦ E p <2 If * dx, the pixel after the movement is the end pixel of the scanning direction line segment,
If the error E p is 0 <E p <dx or E p ≧ 2 * dx, Δx p ← 1/2 * Δx p is set, and the pixel is further moved in the direction in which the x coordinate becomes larger or smaller. Repeat until dx ≦ E p <2 * Δx p ,
The line segment drawing method according to claim 5 or 6.
前記線分処理手段は、請求項10に記載の線分描画処理装置からなることを特徴とする撮像画像処理装置。 Image processing means for processing a picked-up image captured by the image pickup device, line segment processing means for generating a line segment, combining means for generating a composite image in which the line segment is superimposed on the picked-up image, and the composite image In a line drawing processing device comprising display means for displaying,
The captured image processing apparatus according to claim 10, wherein the line segment processing unit includes the line segment drawing processing apparatus according to claim 10.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2009184653A JP5428629B2 (en) | 2009-08-07 | 2009-08-07 | Line segment drawing processing method and apparatus, and captured image processing apparatus |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2009184653A JP5428629B2 (en) | 2009-08-07 | 2009-08-07 | Line segment drawing processing method and apparatus, and captured image processing apparatus |
Publications (2)
Publication Number | Publication Date |
---|---|
JP2011039664A true JP2011039664A (en) | 2011-02-24 |
JP5428629B2 JP5428629B2 (en) | 2014-02-26 |
Family
ID=43767389
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2009184653A Expired - Fee Related JP5428629B2 (en) | 2009-08-07 | 2009-08-07 | Line segment drawing processing method and apparatus, and captured image processing apparatus |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP5428629B2 (en) |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPH0660191A (en) * | 1992-08-05 | 1994-03-04 | Seiko Epson Corp | Straight line picture element generator |
JPH06213660A (en) * | 1993-01-19 | 1994-08-05 | Aisin Seiki Co Ltd | Detecting method for approximate straight line of image |
JPH09212667A (en) * | 1996-01-31 | 1997-08-15 | Brother Ind Ltd | Method for transforming line segment data and device therefor |
-
2009
- 2009-08-07 JP JP2009184653A patent/JP5428629B2/en not_active Expired - Fee Related
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPH0660191A (en) * | 1992-08-05 | 1994-03-04 | Seiko Epson Corp | Straight line picture element generator |
JPH06213660A (en) * | 1993-01-19 | 1994-08-05 | Aisin Seiki Co Ltd | Detecting method for approximate straight line of image |
JPH09212667A (en) * | 1996-01-31 | 1997-08-15 | Brother Ind Ltd | Method for transforming line segment data and device therefor |
Also Published As
Publication number | Publication date |
---|---|
JP5428629B2 (en) | 2014-02-26 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US8274570B2 (en) | Image processing apparatus, image processing method, hand shake blur area estimation device, hand shake blur area estimation method, and program | |
JP4941950B1 (en) | Image processing apparatus, image processing method, and image processing program | |
US8326082B2 (en) | Image processing apparatus, image processing method, and program | |
WO2017122810A1 (en) | Image processing device, image processing method, image processing program, and storage medium | |
JP2008067110A (en) | Generation device for superresolution image | |
US8553097B2 (en) | Reducing blur based on a kernel estimation of an imaging device | |
JP2007096437A (en) | Determination of image creator's intention | |
JP2012100360A (en) | Image processing apparatus, image processing method, and image processing program | |
JP6532328B2 (en) | Image processing apparatus, control method therefor, and control program | |
JP4128123B2 (en) | Camera shake correction device, camera shake correction method, and computer-readable recording medium recording camera shake correction program | |
JPWO2012049768A1 (en) | Image processing apparatus, image processing method, and image processing program | |
JP5428629B2 (en) | Line segment drawing processing method and apparatus, and captured image processing apparatus | |
JP2007087218A (en) | Image processor | |
KR20120069543A (en) | Device for processing image, method thereof and imaging device | |
WO2015098721A1 (en) | Image processing device, image processing method, image processing program, and imaging device | |
CN110692235B (en) | Image processing apparatus, image processing program, and image processing method | |
JP2017199974A (en) | Imaging apparatus, display device and image processing apparatus | |
JP2007241859A (en) | Image processor and image processing method | |
JP2009060464A (en) | Video resolution increasing apparatus and method | |
JP6524644B2 (en) | Image processing apparatus and electronic device | |
JP2009225253A (en) | Image processing apparatus and its method | |
JP4470762B2 (en) | Image processing apparatus, display controller, and electronic device | |
JP2020057242A (en) | Image processing system, image processing method, and program | |
JP2015055988A (en) | Image processor, image processing method, and program | |
JP6091082B2 (en) | Image processing apparatus, image processing method, and program |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
A621 | Written request for application examination |
Free format text: JAPANESE INTERMEDIATE CODE: A621 Effective date: 20120528 |
|
A977 | Report on retrieval |
Free format text: JAPANESE INTERMEDIATE CODE: A971007 Effective date: 20130729 |
|
A131 | Notification of reasons for refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A131 Effective date: 20130731 |
|
RD02 | Notification of acceptance of power of attorney |
Free format text: JAPANESE INTERMEDIATE CODE: A7422 Effective date: 20130801 |
|
A521 | Written amendment |
Free format text: JAPANESE INTERMEDIATE CODE: A821 Effective date: 20130826 |
|
RD04 | Notification of resignation of power of attorney |
Free format text: JAPANESE INTERMEDIATE CODE: A7424 Effective date: 20130826 |
|
A977 | Report on retrieval |
Free format text: JAPANESE INTERMEDIATE CODE: A971007 Effective date: 20130924 |
|
A521 | Written amendment |
Free format text: JAPANESE INTERMEDIATE CODE: A523 Effective date: 20130925 |
|
TRDD | Decision of grant or rejection written | ||
A01 | Written decision to grant a patent or to grant a registration (utility model) |
Free format text: JAPANESE INTERMEDIATE CODE: A01 Effective date: 20131105 |
|
A61 | First payment of annual fees (during grant procedure) |
Free format text: JAPANESE INTERMEDIATE CODE: A61 Effective date: 20131118 |
|
R151 | Written notification of patent or utility model registration |
Ref document number: 5428629 Country of ref document: JP Free format text: JAPANESE INTERMEDIATE CODE: R151 |
|
LAPS | Cancellation because of no payment of annual fees |