How to extract specific edges from an image?

Hello eveyone, I have an image of a car door from which I have to find generate a trajectory from specific edges of the car door. Let me expain the detail about my project.
Project: Finding the edges of a door and used those edges as a trajectory for a sensor that checks edges for Gap/Flush.
Principle: I used Savitzky Golay, Edge Linking and Line Segment Fitting (https://www.peterkovesi.com/matlabfns/#step2line).
Method I used: Image Analyst's Savitzky filter smoothening at three diffrent thresholds, obtain three images and blend them. The output is again processed to Edge linking and line segmenting program.
After all this I am not able to get good edges, its either not smooth or has a lot of unnecessary edges. But the main problem is I am getting a lot of unnecessary edges in the image. To get a Trajectory I need only Three specific edges which I have marked by hand below in red.
Questions:
  1. How to remove unnecessary edges out of the image. Please suggest me a way to get only those three edges? (without manual intervention)
  2. How to smoothening those edges and join them so that i can use it as trajectory for another program?
I have attached the images of input and output. Sorry for the long question.

 Accepted Answer

If you have an edge image with a bunch of edges but want edges from only certain locations, you maybe best off using a mask/template to erase everything outside the areas you want to look in.

10 Comments

Hello Sir, thanks for your support. Your answers and programs have been very useful for me as a beginner.
I used a template/mask to erase everything else and obtained the edges I needed.
Now how do I extract edges and curve fit to get a function so that I get the Trajectory of the above curve. This is my code..
im = imread('blend2_21_OPPFS.png');
im = rgb2gray(im);
props = regionprops(im, 'Area');
%im = imread('pout.tif'); % data
% smooth the image
clc;
clear;
close all;
% Read Input Image
InputImage=imread('blend2_22_OPPFS.png');
%Resize the Image
%InputImage=imresize(InputImage,[256 256]);
% Display the Image
imshow(InputImage);
% Get Inputs from Mouse,Select 4 Seed Points in Image
[Col Row]=ginput(6);
c =Col;
r =Row;
%c = [352.313364055300;100.645161290323;119.571428571429;132.870967741936;353.847926267281;353.847926267281];
%r = [111.244239631336;82.5990783410139;140.912442396313;181.322580645161;188.483870967742;187.460829493088];
% Select polygonal region of interest
BinaryMask = roipoly(InputImage,c,r);
figure, imshow(BinaryMask);title('Selected Region of Interest');
%Create Buffer for ROI
ROI=zeros(333,476);
%Create Buffer for NONROI
NONROI=zeros(33,467);
for i=1:333
for j=1:476
if BinaryMask(i,j)==1
ROI(i,j)=InputImage(i,j);
else
NONROI(i,j)=InputImage(i,j);
end
end
end
%Display ROI and Non ROI
figure;
subplot(1,2,1);imshow(ROI,[]);title('ROI');
subplot(1,2,2);imshow(NONROI,[]);title('NON ROI');
Had to replace door with another component called Cup holder of car. I have worked and got all thw edges sir. Now all I need is two edges, How do I filter all the other edges and get only the two edges I wanted?
There are lots of edges in that image. How do you want to indicate the two that you want?
Hi, sorry for being vague Sir, had to do a free hand sketch.
The First edge is as I marked, the all round edge
The second edge is as I marked, it can also be all around like the first edge.
Once again Thank you for taking time!
With Gratitude,
Harshan D
I don't know. I'd probably suggest you try segnet deep learning on the original grayscale or RGB image.
Oh okay Thanks anyway. I started searching in Matlab Forum and google sir. It seems very complex and scary sir. Can u suggest any examples or references that I can use as a Novice.
No, this might be too tough a problem for a novice. If you can, you might want to start learning with easier challenges.
Is there any other way sir, I just want the 2 curves and rest all dissapeared.
For the earlier door image I thresholded 3 times with different values to get 3 specific curves. But same Threshold alongside Savitzky Golay filter is not doable for new image as the Binary image is just full black after threshold = 220.
Try a threshold that gets all the edges then use bwselect() to manually pick out the one you want.
The enitre process has to have no manual interverntion. Thanks for the Idea anyways!

Sign in to comment.

More Answers (0)

Categories

Find more on Image Processing and Computer Vision in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!