Count lines in an Image

10 Ansichten (letzte 30 Tage)
Oreoluwa ADESINA
Oreoluwa ADESINA am 30 Apr. 2018
Kommentiert: Walter Roberson am 13 Mai 2018
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

Akzeptierte Antwort

sloppydisk
sloppydisk am 30 Apr. 2018
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

Weitere Antworten (1)

sloppydisk
sloppydisk am 30 Apr. 2018
Is it just me or did you not attach any image?
  1 Kommentar
Oreoluwa ADESINA
Oreoluwa ADESINA am 30 Apr. 2018
Oh I really thought i did, sorry!

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Images finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by