Edge tracing - left side only
Mostrar comentarios más antiguos
Hi, I'm trying to trace the left edge of this image, I don't want the top portion, only the left side. I Have 2 methods listed below but neither are working quite the way I need it to. Any help would be greatly appreciated! Thank you. 

clc;
clear;
close all;
I = imread('Frame4.jpg');
figure %figure 1
imshow(I)
hold on;
threshold = 69;
Igray = im2gray(I);
title('Original Image')
IBW = Igray>threshold;
figure %figure 1 BW
imshow(IBW) %threshold
title('Binarized Image 1')
%%Method 1
[rows, columns, numberOfColorChannels] = size(IBW);
lowThreshold = 1;
highThreshold = 500;
% [lowThreshold, highThreshold, lastThresholdedBand] = threshold(lowThreshold, highThreshold, grayImage)
mask = IBW >= lowThreshold & IBW <= highThreshold;
leftedge = nan(rows,1);
% topRows = nan(1, columns);
for row = 1 : rows
thisRow = mask(row,:);
% Find top row
t = find(thisRow,1);
if ~isempty(t)
leftedge(row) = t;
end
end
imshow(IBW)
hold on;
plot(leftedge,'r-', 'LineWidth', 2);
axis on
grid on
% METHOD 2
mask = false(size(IBW));
mask(300+200:650,130-50:200) = true;
b = visboundaries(mask,'color','r') ;
hold on ;
g = visboundaries(IBW(500-400:650,130-129:200),'color','b');
g.Children(1);
g.Children(2).Visible='off';
g.Children(1).LineWidth = 2;
grid on
axis on
hold on;
h = visboundaries(BB(200-199:450,90-89:130),'color','r'); %226-225:300
% h = visboundaries(BB(:,590:551-550),'color','r');
hold off
h.Children(1);
h.Children(2).Visible='off';
h.Children(1).LineWidth = 2;
grid on
axis on

Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Image Segmentation en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
