How can I track the boundary

1 visualización (últimos 30 días)
HUANG YU-CHE
HUANG YU-CHE el 29 de Jun. de 2020
Comentada: HUANG YU-CHE el 2 de Jul. de 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
so how can i just track the white boundary only like
  1 comentario
KSSV
KSSV el 29 de Jun. de 2020
Read about convhull, boundary.

Iniciar sesión para comentar.

Respuesta aceptada

Image Analyst
Image Analyst el 29 de Jun. de 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 comentarios
Image Analyst
Image Analyst el 29 de Jun. de 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.
HUANG YU-CHE
HUANG YU-CHE el 2 de Jul. de 2020
thank you very much

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Polynomials en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by