Separate strokes from a gesture

2 visualizaciones (últimos 30 días)
Shweta Saboo
Shweta Saboo el 7 de En. de 2021
Respondida: Pratyush el 14 de Feb. de 2024
I have to separate individual strokes from a gesture like curved line and straight line from numeral "2". How to do it?

Respuestas (1)

Pratyush
Pratyush el 14 de Feb. de 2024
Hi Shweta,
To separate individual strokes from a gesture like the numeral "2" in MATLAB, follow these steps:
  • Pre-process the image by converting it to grayscale, binarizing it, and removing noise.
  • Use edge detection and skeletonization to find and thin the outlines of the strokes.
  • Trace the contours of the strokes and analyze their curvature to distinguish between straight and curved segments.
  • Label and classify the different strokes based on features such as length and curvature.
  • Visualize the separated strokes for verification.
Here's an example MATLAB code for these steps:
% Load and preprocess the image
img = imread('numeral2.png');
grayImg = rgb2gray(img);
binaryImg = imbinarize(grayImg);
cleanImg = bwareaopen(binaryImg, 30);
% Edge detection and skeletonization
edges = edge(cleanImg, 'canny');
skeleton = bwmorph(edges, 'thin', Inf);
% Find contours and separate strokes
[contours, ~] = bwboundaries(skeleton, 'noholes');
for i = 1:length(contours)
contour = contours{i};
% Analyze contour for curvature and classify (code for analysis not included)
% Visualize the contour
figure; imshow(skeleton); hold on;
plot(contour(:,2), contour(:,1), 'g', 'LineWidth', 2);
end
The actual curvature analysis and classification logic are not included and would need to be implemented based on your specific requirements.

Categorías

Más información sobre Images en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by