banner



How To Draw A Line In Image Matlab

Draw Line on Prototype in Matlab

  1. Draw Line on an Paradigm Using the plot() Function in MATLAB
  2. Draw Line on an Epitome Using the insertshape() Function in MATLAB

This tutorial will discuss how to draw lines and other shapes on an image using the plot() and insertshape() function in MATLAB.

Draw Line on an Epitome Using the plot() Part in MATLAB

If you want to draw a line or other variables like the sine wave on an paradigm, yous tin use the plot() part to practice that. For example, permit's depict a line on an image. See the code below.

              load clown paradigm(X) concur on plot([180 l], [lx 250],'Color','r','LineWidth',5)                          

Output:

Drawing Line On An Image Using plot in Matlab

In the in a higher place code, we accept used an already stored clown image and plotted a line on the clown paradigm using the hold on command. You can change the colour of the line using the Colour property and the line width using the LineWidth holding. Yous tin besides change the starting and ending point of the line.

Draw Line on an Image Using the insertshape() Function in MATLAB

If you lot want to draw shapes: line, circle, rectangle, and polygon on an image, you can employ the insertshape() office to do that. The basic syntax of the insertshape() function is given below.

              Output = insertShape(Image, shape, shape_position)                          

In the above code, Epitome is the image object on which you want to draw, shape is the shape you lot desire to depict on the image, shape_position is the position on the image at which you lot want to draw the shape. For case, allow's draw a circumvolve on an image. See the code below.

              X = imread('peppers.png'); output = insertShape(X,'circumvolve',[100 100 100],'LineWidth',five); imshow(output)                          

Output:

Drawing Shapes on Image Using insertshape

In the above lawmaking, we take used an already stored peppers image, and a circle is drawn on the epitome using the insertshape() function. In the case of a circle, the position consists of three values; the showtime value is the ten-axis position, the second value is the y-axis position, and the tertiary value is the radius of the circle. In the example of a rectangle, the position consists of four values, the first value is the x-axis position, the 2nd value is the y-axis position, the third value is the width, and the quaternary value is the height of the rectangle. Yous can also change the color of the shape using the Color belongings, the line width using the LineWidth property, and also the opacity in case of filled shapes using the Opacity belongings. Cheque this link for more details about the insertshape() role.

Write for u.s.

DelftStack articles are written past software geeks similar you. If yous too would like to contribute to DelftStack by writing paid articles, you tin check the write for us page.

Related Article - MATLAB Epitome

  • MATLAB Image Dilation
  • MATLAB Paradigm Histogram
  • Image Resize in MATLAB
  • Erosion of an Epitome in MATLAB
  • Ezoic

    Source: https://www.delftstack.com/howto/matlab/matlab-draw-line-on-image/

    Posted by: ferrarogreggelf44.blogspot.com

    0 Response to "How To Draw A Line In Image Matlab"

    Post a Comment

    Iklan Atas Artikel

    Iklan Tengah Artikel 1

    Iklan Tengah Artikel 2

    Iklan Bawah Artikel