How can I track the boundary
1 次查看(过去 30 天)
显示 更早的评论
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

so how can i just track the white boundary only like

采纳的回答
Image Analyst
2020-6-29
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 个评论
Image Analyst
2020-6-29
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Polynomials 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!