フィルターのクリア

How do i count the horizontal lines in an image

4 ビュー (過去 30 日間)
N/A
N/A 2018 年 2 月 26 日
回答済み: Akira Agata 2018 年 2 月 27 日
I am new to MATLAB. How do i write a code which detects and counts horizontal lines in an image. Example is below. Any method of image analysis would be helpful. Thank you
  2 件のコメント
Akira Agata
Akira Agata 2018 年 2 月 27 日
Is it possible to erase the red line mesh? Or do we have to use this image as an input?
N/A
N/A 2018 年 2 月 27 日
Sorry i'll upload the original picture. I put the mesh on that one myself.

サインインしてコメントする。

採用された回答

Akira Agata
Akira Agata 2018 年 2 月 27 日
Thank you for uploading the clean image!
In my view, one simple and straight-forward solution will be regionprops function. The following is one example to extract horizontal lines in the image.
% Read your image and binarize
I = imread('5159-15B front_imgJ-macro.jpg');
I = rgb2gray(I);
BW = imbinarize(I);
% Apply regionprops function
s = regionprops(~BW,{'MajorAxisLength','MinorAxisLength','BoundingBox','Orientation'});
s = struct2table(s);
% Extract the regions which satisfies both the following conditions:
% (1) (Minor axis length)/(Major axis length) <= 10%
% (2) Angle with horizontal line <= +- 5 degree
idx =...
(s.MinorAxisLength ./ s.MajorAxisLength <= 0.1) &...
(abs(s.Orientation) <= 5);
s = s(idx,:);
% Show the result
figure
imshow(I)
hold on
for kk = 1:height(s)
rectangle(...
'Position', s.BoundingBox(kk,:),...
'EdgeColor','r')
end

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by