How can I track the boundary
2 ビュー (過去 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 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!