Showing posts with label clipping. Show all posts
Showing posts with label clipping. Show all posts

Thursday, 3 April 2014

                                                 

  • It is more efficient than cohen and sutherland line algorithm liang barsky.
  •  liang barsky has developed the algorithm using the parametric equation are:
x= x1+TX
y= y1+TY
                                                         where X= x1-x2, Y= y1-y
  •  The point clipping condition for liang barsky are:
                         xw min <= x1+TX <= xw max
                         yw min <= y1+TY <=yw max
  • Liang barsky express these four with two parameter p and q as t pi<qi where i=1,2,3.......
             where the parameter p and q are :
              p1 = -X , p2 = X , p3= -Y , p4 = Y and q1 = x1-xw min , q2= xw max- x1 , q3= y1-yw min ,              q4= yw max - y1
  •  If pi= 0 then line is parallel to  i th boundary where i=1,2,3......
  •  If qi= 0 then line is completely outside the boundary so we can discard the line.
  • The non zero value of pi the line cross the clipping boundary and we have to find the parameter 't'. where t= qi/pi
  •  this algorithm find the two value of 't' such as 't1' and 't2'.
  • The value of 't1' is taken as the largest value among various values of intersection with all edges i.e; pi < 0. and The value of 't2' is taken as the smallest value i.e; pi > 0.
  •  if (t1<t2) then some formulas are used to find the ends points .
  1.   xx1= x1+t1X
  2.   xx2= x1+ t2X
  3.  yy1= y1+ t1Y
  4.  yy2 = y2+t2Y (Then draw the line)
  • STOP 


  

ADVANTAGES OF LIANG BARSKY ALGORITHM
  1.  It is more efficient then sutherland and cohen algorithm because intersection calculation are reduce.
  2. It required only one division to update parameter p1 and p2.
  3. Window intersection of the lines are computed only once.






Wednesday, 26 March 2014

LIANG BARSKY ALGORITHM

  • It is more efficient than cohen and sutherland line algorithm liang barsky.
  •  liang barsky has developed the algorithm using the parametric equation are:
x= x1+TX
y= y1+TY
                                                         where X= x1-x2, Y= y1-y
  •  The point clipping condition for liang barsky are:
                         xw min <= x1+TX <= xw max
                         yw min <= y1+TY <=yw max
  • Liang barsky express these four with two parameter p and q as t pi<qi where i=1,2,3.......
             where the parameter p and q are :
              p1 = -X , p2 = X , p3= -Y , p4 = Y and q1 = x1-xw min , q2= xw max- x1 , q3= y1-yw min ,              q4= yw max - y1
  •  If pi= 0 then line is parallel to  i th boundary where i=1,2,3......
  •  If qi= 0 then line is completely outside the boundary so we can discard the line.
  • The non zero value of pi the line cross the clipping boundary and we have to find the parameter 't'. where t= qi/pi
  •  this algorithm find the two value of 't' such as 't1' and 't2'.
  • The value of 't1' is taken as the largest value among various values of intersection with all edges i.e; pi < 0. and The value of 't2' is taken as the smallest value i.e; pi > 0.
  •  if (t1<t2) then some formulas are used to find the ends points .
  1.   xx1= x1+t1X
  2.   xx2= x1+ t2X
  3.  yy1= y1+ t1Y
  4.  yy2 = y2+t2Y (Then draw the line)
  • STOP 


ADVANTAGES OF LIANG BARSKY ALGORITHM
  1.  It is more efficient then sutherland and cohen algorithm because intersection calculation are reduce.
  2. It required only one division to update parameter p1 and p2.
  3. Window intersection of the lines are computed only once.






Tuesday, 18 February 2014

Sutherland and cohen subdivision line clipping algorithm
  • this is one of the most oldest and popular method for line clipping algorithm developed by "Dan cohen" and "Ivan sutherland".
  • This algo uses a 4 digit code to indicate which of the nine region contain the n point of the line, the 4 digit codes are called Region codes or out codes. these codes identifies the location of the point relative to the boundaries of the clipping window.
  • Each bit position in the region code is used to indicate one of the 4 releative co-ordinate position of the point w.r.t the clipping window.(left, right, top and bottom).
  • set bit 1: if the end point is to left of the window.
  • set bit 2: if the end point is to right of the window.
  • set bit 3: if the end point lie below the window.
  • set bit 4: if the end point lie above the window.
  • Once we have establish region codes for all the lines end points we can determine which lines are completely outside the clipping window and any lines that are completely inside the window boundaries have a region code of (0000) for both the ends point and we accept these lines.
  • A method used to test lines for total clipping is equivalent to the logical AND operation with two end points is not equal to (0000).   
  • The line that can't be identified as completely inside or completely outside the clipping window by these test they are checked for intersection with the window boundaries. 

Algorithm:
  1. read two end points of the line p1(x1,y1), p2(x2,y2).
  2. Read two corner(left -top, left-bottom) of the window (Wx1,Wy1) and (Wx2,Wy2).
  3. Assign the region codes for the two end points (p1,p2) using the following steps:
  • Set bit 1:if x<Wx1
  • Set bit 2: if x>Wx2
  • Set bit 3: if y<Wy2
  • set bit 4: if y>wy1 
     4. Check for visibility of line (p1,p2)
         a. if region codes for both the end point are zero then the line is completly visible hence draw    the line and go to step 9
         b. if region code for the end point are not zero and the logical AND operation of them is also  non -zero then the line is comletely unvisible .so, reject the line and go to step 9.
         c. if above points not satisfy the line is partially visible.
     5.Determine the intersection edge of the clipping window by respecting the region code of the two end points.
a. if the region code for both the end points are non-zero .find the respective points (p1'&p2') with the boundary edge of the clipping window w.r.t it .
    6. Divide the line segment considering the (x) point.
    7. Reject the line segment if any one end point of it appeared outside the clipping window.
    8. Draw the remaning line segment.
     9. STOP.

Sunday, 9 February 2014

Clipping

  • The process of selecting and viewing the picture with different views is called windowing , and a process which divides each element of a picture into its visible and non- visible portion allowing the invisible portion to be discarded is called CLIPPING.
  • we can generate different views of a picture by applying the appropriate scaling and translations by during this we have to identify the visible part of the picture for including it in the display device.
  • Selection lines may lie partially inside the visible portion of the picture and partially outside. these lines can't emitted entirely from the display image because image would become in accurate . 
  • The procedure that identifies the portion of the picture that are either inside and outside of the specific region or space is referred to as clipping. The region against which an object is to be clicked is called clip window.   
There are various line clipping algorithms:
  1. Sutherland and cohen sub-division line clipping algorithm .
  2. Liang barsky line clipping algorithm.
  3. Mid-point subdivision line clipping algorithm.