In the given image, i plotted 6 points on its border manually. a random point is selected in the image. My objective is to connect all those 6 points with this random point. how to connect those by lines.
Did you try the line() function? That will plot in the overlay. If you want the line burned into the image use the imline() function's createMask() method.
% Demo to write a line into the overlay of an image, % and then to burn the overlay into the image.
%----- Initializing steps ----- % Clean up clc; clear all; close all; workspace; % Display the workspace panel.
hasIPT = license('test', 'image_toolbox'); if ~hasIPT % User does not have the toolbox installed. message = sprintf('Sorry, but you do not seem to have the Image Processing Toolbox.\nDo you want to try to continue anyway?'); reply = questdlg(message, 'Toolbox missing', 'Yes', 'No', 'Yes'); if strcmpi(reply, 'No') % User said No, so exit. return; end end
% Display images to prepare for the demo. monochromeImage = imread('pout.tif'); subplot(2, 2, 1); imshow(monochromeImage); title('Original Image'); subplot(2, 2, 2); imshow(monochromeImage); title('Original Image with line in overlay'); set(gcf, 'units','normalized','outerposition',[0 0 1 1]); % Maximize figure. set(gcf,'name','Image Analysis Demo','numbertitle','off')
%----- Burn line into image ----- burnedImage = imread('pout.tif'); % Create line mask, h, as an ROI object over the image. hLine = imline(gca,[10 100],[10 100]); % Second argument defines line endpoints. % Create a binary image ("mask") from the ROI object. binaryImage2 = hLine.createMask(); % Display the line mask. subplot(2, 2, 3); imshow(binaryImage2); title('Binary mask of the line'); % Burn line into image by setting it to 255 wherever the mask is true. burnedImage(binaryImage2) = 255; % Display the image with the "burned in" line. subplot(2, 2, 4); imshow(burnedImage); title('New image with line burned into image');
Play games and win prizes!Learn more