필터 지우기
필터 지우기

Count lines in an Image

조회 수: 7 (최근 30일)
Oreoluwa ADESINA
Oreoluwa ADESINA 2018년 4월 30일
댓글: Walter Roberson 2018년 5월 13일
Hi, I would really appreciate some urgent help with this question, Im trying to count lines in a binary image using "bwboundries" but I only want to count particular lines which fall in between a size/length range so as to avoid counting blobs that are not lines. I have attached an image for more clarity. From the image I have horizontal and vertical ones I want to count, but some are just blobs and my current code includes the blobs in the total count, i would like to eliminate that. Thanks for the help

채택된 답변

sloppydisk
sloppydisk 2018년 4월 30일
I adapted some code from the example OverlayRegionBoundariesOnImageExample.mlx to do what you probably want
% Overlay Region Boundaries on Image
% Read grayscale image into the workspace.
I = imread('myImg.png');
% Convert grayscale image to binary image using local adaptive thresholding.
BW = imbinarize(I);
% Calculate boundaries of regions in image and overlay the boundaries on the image.
[B,L] = bwboundaries(BW,'noholes');
% Create function handle for diagonal length
hypotFun = @(x) hypot(max(x(:, 1)) - min(x(:, 1)), max(x(:, 2)) - min(x(:, 2)));
% Set minimum length
minimumLength = 10;
% Logical indexing for allowable length
check = cellfun(hypotFun, B) > minimumLength;
Bnew = B(check);
hold on
% Plot
for k = 1:length(Bnew)
boundary = Bnew{k};
plot(boundary(:,2), boundary(:,1), 'b', 'LineWidth', 2)
end

추가 답변 (1개)

sloppydisk
sloppydisk 2018년 4월 30일
Is it just me or did you not attach any image?
  댓글 수: 1
Oreoluwa ADESINA
Oreoluwa ADESINA 2018년 4월 30일
Oh I really thought i did, sorry!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by