How to highlight linear/curve character in a set of points?

3 visualizaciones (últimos 30 días)
Luke Ooi
Luke Ooi el 23 de Oct. de 2022
Respondida: Maneet Kaur Bagga el 4 de Oct. de 2023
Hello, I have consulted this community very often and it has helped me a lot. This is my first direct question as I have a rather unique problem. Without going into too much detail, I am trying to develop a tracking-like program to trace linear lines in input photos of fingerprints. In this specific case, the visual shape of a curve is still apparent through the distribution of telltale droplets of residue, which I have segmented as individual boundaries using the bwboundary feature.
In low quality regions (below), the ridges are not distinct and there is much more noise, but these droplet points still can be seen to exhibit linear character.
I am trying to put together a segmentation workflow to cut the noise of these disparate points and to automatically 'join the dots'. I'm imagining some sort of fitting function that best fits a straight line or curve to intercept as many points as possible in a best-fit fashion. In a more basic sense, when you have points that have a linear arrangment among other noise points, is there a way to highlight the ones that follow that linear/curve character?
Code section for the segmentation above
%A manual binarization threshold value
highestValueToPlot = 200
%Percentile value to determine the minimum permeter threshold of boundaries to include, i.e. filter out boundaries below a certain percentile of perimeter values
dotpercentile = 85
% Threshold image - manual threshold
BW = cropim > highestValueToPlot;
imshow(BW);
pointbin = BW;
% Adjust data to span data range.
cropim = imadjust(cropim);
% Create masked image.
maskedImage = cropim;
maskedImage(~BW) = 0;
bwbound = bwboundaries(maskedImage);
%Filter small boundaries
dotthreshold = prctile(cellfun(@length,bwbound),dotpercentile);
bwfilter = cellfun(@length,bwbound) >= dotthreshold;
filteredbound = bwbound(bwfilter);
I apologize for the messiness or clumsiness of the code, I don't have a formal coding background and this is a cross-disciplinary project; I am learning the basic of MATLAB and Image segmentation on the go for this project. Also not intending for anyone to do my work for me, just looking for promising directions to study and implement. Any comments or criticism of this existing workflow also welcomed.

Respuestas (1)

Maneet Kaur Bagga
Maneet Kaur Bagga el 4 de Oct. de 2023
Hi Luke,
As per my understanding to automatically "join the dots" and highlight the points that follow a linear or curve character,a curve fitting algorithm can be used. One common approach is to use the least squares method to fit a straight line or curve to the given data points.
Please refer to the following points to incorporate curve fitting into the segmentation workflow:
Preprocess the Image:
  • Apply a manual binarization threshold to obtain a binary image, as shown in the code snippet (BW = cropim > highestValueToPlot).
  • Adjust the data range using techniques like contrast stretching (cropim = imadjust(cropim)).
Create a masked image:
  • Set the non-boundary pixels of the masked image to zero (maskedImage(~BW) = 0).
Extract boundaries:
  • Use the bwboundaries function to extract the boundaries from the masked image (bwbound = bwboundaries(maskedImage)).
Filter small boundaries:
  • Determine a threshold for the minimum perimeter value of boundaries to include, based on a percentile value (dotthreshold = prctile(cellfun(@length,bwbound),dotpercentile)).
  • Filter out boundaries below the threshold (bwfilter = cellfun(@length,bwbound) >= dotthreshold).
  • Keep the filtered boundaries (filteredbound = bwbound(bwfilter)).
Curve Fitting
  • For each filtered boundary, apply a curve fitting algorithm to fit a straight line or curve to the boundary points.
  • Calculate the goodness of fit (e.g., using the sum of squared residuals) to assess how well the fitted curve represents the data points.
By incorporating curve fitting into the segmentation workflow, it becomes possible to automatically identify and highlight the boundaries that follow a linear or curve character, effectively reducing noise and connecting the relevant data points.
Please refer to the following MATLAB Documentation for better understanding of the above algorithm:
bwboundaries
Curve Fitting
Hope this helps!
Regards,
Maneet Bagga

Community Treasure Hunt

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

Start Hunting!

Translated by