convert the image sketch in to x,y boundary coordinate
17 次查看(过去 30 天)
显示 更早的评论
Hi every one
excuse me , I have irregular boundary sketch and i need to convert it into x,y coordinate to calculate the area , moment of ineria ,....etc
the photo in attachments
thanks
0 个评论
回答(2 个)
Mathieu NOE
2024-2-29
hello
try this
hope it helps
filename = 'image.png';
inpict = im2double(rgb2gray(imread(filename)));
[m,n] = size(inpict);
mm = min(inpict,[],'all');
% find values below threshold
[y,x] = find(inpict<=mm*1.1);
% flip y direction (on the data)
y = m-y;
% remove x outliers dots using histcounts
[nx,ex] = histcounts(x,25);
ind = find(nx<1);
xmax = ex(ind(1));
ind = (x>xmax);
x(ind) = [];
y(ind) = [];
plot(x,y,'*k');
0 个评论
Image Analyst
2024-2-29
You don't need the (x,y) coordinates. You can work from the binary image directly. Getting the (x,y) coordinates just complicates things.
First get a better photo without those horrendous background illumination problems. For example, use a flatbed scanner. Then threshold and call imfill to get a solid blob. Then you can use regionprops to measure things about the shape. For example area
mask = imfill(mask, 'holes'); % Fill outline to make a solid blob shape
mask = bwareafilt(mask, 1); % Take largest blob only (in case there are small noise blobs)
props = regionprops(mask, 'Area', 'Perimeter')
theArea = props.Area
thePerimeter = props.Perimeter
For a different way to compute area you can use bwarea which gives area depending on the local shape of the boundary of the blob, as opposed to regionprops which gives area as a simple pixel count.
It's a generic, general purpose demo of how to threshold an image to find blobs, and then measure things about the blobs, and extract certain blobs based on their areas or diameters.
To measure moments of inertia, see attached demo.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!