detect horizontal and vertical lines
15 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Mohammad
el 28 de Sept. de 2014
Comentada: Firdausy angga Permana
el 5 de Jun. de 2017
How to detect horizontal and vertical lines in a given image using imerode function? I have this code but it doesn't detect H and V lines
im=imread('src\ima.tif');
im(:,:,2:4)=[];
im=im2bw(im);
SE = strel('arbitrary',ones(10,1));
im2 = imerode(im,SE);
imwrite(im2,'src\aa.tif');
imshow(im2)

0 comentarios
Respuesta aceptada
Image Analyst
el 28 de Sept. de 2014
Just call bwconncomp(), then regionprops() and check if the bounding box height is less than some number, like 1 or 2 pixels. Untested code:
binaryImage = grayImage < 128;
cc = bwconncomp(binaryImage);
measurements = regionprops(cc, 'BoundingBox');
for k = 1 : length(measurements)
thisBB = measurements(k).BoundingBox;
if thisBB(4) <= 3 % If it's shorter than 4 lines tall.
message = sprintf('Blob #%d is horizontal.', k);
sprintf('%s\n', message);
uiwait(helpdlg(message));
end
end
8 comentarios
Tina
el 22 de Sept. de 2015
Hi, I'm new to Matlab and Matlab Answers. I have a query. While detecting vertical lines, what if I need to detect the lines from the alphabets also? For example quoting the same input image as above, the letter H has two vertical lines, letters R, L, D has one vertical line. How do I detect them? Thanks.
Firdausy angga Permana
el 5 de Jun. de 2017
Hi Image Analyst. I've tried this code and it's really helping me to solve my problem. But, how can we remove that lines? Thanks Before!
Más respuestas (0)
Ver también
Categorías
Más información sobre Image Processing Toolbox en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

