Our objective is to plot a line along 2 points in MATLAB without using inbuilt functions for plotting. A black and white image can be represented as a 2 order matrix. The first order is for the rows and the second order is for the columns, the pixel value will determine the color of the pixel based on the grayscale color format.
- We are given with 2 points. Let the coordinates of the points be (x1, y1) and (x2, y2).
- We find the slope of these 2 points and store it in m.
m = (y2-y1)/(x2-x1);
- Now for every pixel, find the slope between the pixel and one of the point.
m2 = (y2-j)/(x2-i);
- If the slope obtained is equal to the slope of the points, then change the color to black (0).
- Plot a circle using centre point and radius in MATLAB
- MATLAB | RGB image representation
- Image Resizing in Matlab
- Reverse Video in Matlab
- Matlab | Erosion of an Image
- Image Complement in Matlab
- Matlab | Dilation of an Image
- Draw Sudan Flag using MATLAB
- Draw Indian Flag using matlab
- Draw Seychelles Flag using MATLAB
- Draw Sweden Flag using matlab
- LSB based Image steganography using MATLAB
- MATLAB | Complement colors in RGB Image
- Draw Kuwait Flag using MATLAB
- How to draw Japan flag using MATLAB
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.