MATLAB: From points to closed contour contourimage processing I have 6 points as shown in the picture above. Can I make a closed contour from the 6 points as shown below? I've tried to use creating ellipse and imfill() but they didn't work. Thank you. Best Answer Try thisim = im2double(imread('image.jpeg'));im_gray = rgb2gray(im);im_gray = imbinarize(im_gray)*1;[r,c] = find(im_gray==1);points = [c r];p = convhull(points);points = points(p, :).';poly_points = points(:).';im_gray = insertShape(im_gray, 'FilledPolygon', poly_points, ... 'Color', [1 1 1], ... 'Opacity', 1, ... 'SmoothEdges', false);imshow(im_gray); Related SolutionsMATLAB: Matlab imshow this gives an error with imsubstract because the images are not of the same size. MATLAB: Locate coordinates of black areas in image. Try this.im = im2double(imread('image.jpeg'));% filter the black circles from colored imageim_gray = rgb2gray(im);mask = im_gray < 0.1;% detect and filter the connected regionsreg = bwconncomp(mask);pxlList = reg.PixelIdxList;idx = cellfun(@(x) numel(x) > 1, pxlList);pxlList(~idx) = [];% calculate the centres of the connected regionscentres = zeros(numel(pxlList), 2);for i=1:numel(pxlList) [r,c] = ind2sub(size(im_gray), pxlList{i}); centres(i,:) = mean([r c]);endimshow(im);hold on;plot(centres(:,2), centres(:,1), 'r+', 'LineWidth', 4, 'MarkerSize', 10) Related QuestionHow to produce edge detected imageHow to get the cooridinate of the lowest point on the circumference of an area in image processing“Index exceeds matrix dimensions” in imwrite()
Best Answer