# convert the image sketch in to x,y boundary coordinate

8 vues (au cours des 30 derniers jours)
Ali le 27 Fév 2024
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 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Réponses (2)

Mathieu NOE le 29 Fév 2024
hello
try this
hope it helps
filename = 'image.png';
[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 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

Image Analyst le 29 Fév 2024
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)
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 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Catégories

En savoir plus sur ROI-Based Processing dans Help Center et File Exchange

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by