How can I track the boundary
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
HUANG YU-CHE
il 29 Giu 2020
Commentato: HUANG YU-CHE
il 2 Lug 2020
I'm going to track the boundary line ,but my photo was not very clearly about some of the point(missing point),how can i set the missing point to NaN and replace
to Proximity value,to make the line complete ,thanks
fclose all; close all; clear all; clf; clc;
cd 'C:\Users\User\Documents\MATLAB\test1\carmer1\photo1'
a=imread('img350.png');
i2=im2double(a);
ihd=rgb2gray(i2);
cd 'C:\Users\User\Documents\MATLAB\test1\carmer1\mavg1'
b=imread('imavg1.png');
b=im2double(b);
c=ihd-b;
msim_crop = imadjust(c,[0 0.1],[0 1],1.);
msim_crop = uint8(msim_crop);
bw0 = im2bw( msim_crop,graythresh(msim_crop).*0.01 );%0.12
windsz = 7; %4
H2 = fspecial('average',windsz); )
averaged_bw1 = imfilter(bw0,H2,'replicate');
the photo will look like this
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/323551/image.jpeg)
so how can i just track the white boundary only like
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/323554/image.jpeg)
Risposta accettata
Image Analyst
il 29 Giu 2020
If you want to find the light blue boundary on the left, I'd scan row by row using find() to find the leftmost white pixel. Then I'd fit a sliding quadratic to it with sgolayfilt(). Then I'd subtract the fit from the actual to find the distance. Distances that are greater than some amount, I'd discard. You might be able to use rmoutliers() for that. Give it a try. Here's a start
[rows, columns] = size(binaryImage);
leftColumns = columns * ones(rows, 1);
for row = 1 : rows
thisRow = binaryImage(row, :);
col = find(thisRow, 1, 'first')
if ~isempty(col)
leftColumns(row) = col;
end
end
smoothedColumns = sgolayfilt(leftColumns, 21, 2);
diffs = abs(smoothedColumns - leftColumns);
plot(diffs, 'b-', 'LineWidth', 2);
etc.
3 Commenti
Image Analyst
il 29 Giu 2020
Sorry - I reversed the polynomial order and window width. It should be sgolayfilt(leftColumns, 2, 21) or some other number than 21. A bigger number gives more smoothing.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Polynomials in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!