Edge detection on Video

30 views (last 30 days)
Junior Zanini
Junior Zanini on 23 Jul 2015
Commented: Ajay V on 20 May 2022
I have a video of a welding procedure, and for every frame I need to take all the contours of the welded area, and detect all the edges. Unfortunately, the images I got aren't the best quality, I tried to put several filters and make image enhacement and it didn't work to take the sharp edges.
Image Below:
I managed to make the following code, but the results were terrible.
clear all
vid = VideoReader('home/simulation/V6_008.avi');
h=ones(3,3)/9;
for i=1 : mov.NumberOfFrames
thisframe = read(vid,i);
g = image(thisframe);
lsave = sprintf('image.jpg');
saveas(g, lsave, 'jpg')
a = imread(lsave);
a1 = imcrop(a,[150 450 650 300]);
a2= imsharpen(a1,'Radius',50,'Amount',500);
b = rgb2gray(a2);
c=imadjust(b,[0.6 0.8],[]);
c1= imfilter(c,h);
c2=adapthisteq(c1,'cliplimit',0.01,'Distribution','exponential');
d = edge(c1,'canny',0.1);
e=bwareaopen(d,50);
imshow(e) end
these Filters and image enhacements helped a little bit, but it is still not enought for my measurements.
So I have 2 questions:
1) Do you know any other tool I can use to make my edge detection cleaner? I just want to outline the specified region as you can see.
2) I need to make the edge detection for every frame, and then save all the frames, and also save the video after edge detection. I don't really know how to do it. Do you?
I made this on paint, This are the edges I would Ideally get after edge detection:
The problem is that I have 60 videos, each with aproximately 1500 frames, and I need to measure the size of these edges.
Thanks very much guys, I apology if it was confusing. I'm afraid if I don't finish this properly I gonna get very troubled.. :(. Thanks again, I apreciate any help!
  2 Comments
mersede maksabi
mersede maksabi on 5 Jun 2020
did you managed to find a solution for this?
Jerry Mahabub
Jerry Mahabub on 7 Sep 2020
IK am in similar situation over 2500 videos each at 4K reso. I found a cool solution online using the hed model for edge detection by pyimage search and he offerws a great python 176 day couirse that takes you from cleuless to knmowing OpenCV, Caffe, Tensorflow, etc. I am now using Simulink to test various methos Then as with Mathematica, you can just instantiate a python shell externally of Mathematica and via the link between python and Matlab, you get the best of both worlds, I am using VS 2019l, Mathematica, Matlab, and code in c++ and Pythion as cuda oiptimizations are better served in c++ for GPU workloads. Sounds like you should take a look, here is the link, and take some time to do his 17 day course, whether novice or expert dev as I have been writing hard core DSP code and unique algos in softwarwe enigneerring for computational physics for > 33 yearts, and the course did me justice, then again i was not ereally much of a pythin dev but i am not Python huru but my kung fu is improving. I think wioth some tweaking as i did you will find using a hed model more rewarding and you can adjust the size way better than using canny, sobel, or oithers as three coordinates. If you pay for his course and buy his books (noit the free 17 day) you get an amaziong guru expert in CV att yoyur fingetrtips to help you in any way possible (provided you are not ojn Windows and uysing Rasp, some disto of Linux, or a Mac - I use WSL whidch opens an ubuntu window inside of Windowes in a venv.
And for the more specific examples that will get you closer into achieving your goals:
Seriously, I hold my PhD in Physics and ECSE and Adrian is probably about the best teacher in existence and if you want to learn OpenCV or just in general how to go from clueless to kung fu DV master quickly, take his 17 day free course and concureently alongside it pay for his top opf the line course which is under $200.00 yuou get hard copies of his books, and amazing support for anything you need anytime on your projects. I can tell you that if you wqere to pay a consultant to come in and write code for you, one with the background and expoerience of Adrian, you would blow easily $5K to %10K per month in 1099 cobtractor expoenses compared to under $200.000. The latter the two would be the most logica and cost effective solution, and Adrian gets bnack to you quickly. No, he did not pay me to write this i only give reviews of this magnitude for those who deseerve it.
Hope this helps you to achieve success with your project.

Sign in to comment.

Answers (1)

Image Analyst
Image Analyst on 7 Sep 2020
I know it's a 5 year old question, but I recently did a demo for another question that took the Canny edge of a video, in case anyone else stumbles across this old thread with the same question. It's attached.
  8 Comments
Image Analyst
Image Analyst on 19 May 2022
The edges are in an image. You can display an image. You can plot a set of (x,y) coordinates. If you want you could get the (x,y) coordinates from the image using find(), then you could plot them with plot(). Of course that would look just like the image.
A "profile" is like a projection of an image along some direction, or the intensity values of the image along some line in the image. I have no idea what profile you'd like to display in a plot.
Of course you also have the movie showing the edges but I guess you don't want that, or it's not enough.
Why don't you start your own question and attach your own movie, and explain MUCH better what you want, trying to use more exact terminology?
Ajay V
Ajay V on 20 May 2022
Yea sure. I will ask my own question with probably a better explanation of what I want 😅. Thanks for your patient replies!

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!