Video analysis: problem finding the vertical mean of edges

3 Ansichten (letzte 30 Tage)
EJMK
EJMK am 7 Dez. 2013
Kommentiert: Image Analyst am 10 Dez. 2013
I have a video file which shows an object that is fluctuating up and down along its horizontal length. I want to divide each frame into regions of 50 horizontal pixels so that I can find a single point in each region that is horizontally in the centre of the region and vertically in the centre of the upper and lower edges of the object. I have used edge detection to find the top and bottom edges and I am using a loop to find the centres of the object in the regions. The problem: I have used “mean” to find the vertical centroid of the upper and lower object edges in each region, y_m. However y_m for some bizarre reason always outputs a value very close to the bottom edge of the object, usually below the bottom edge. I have no idea why as there are only 1s (1s for the edges, 0s for everything else) along the edges in each region so the mean should at least be between the upper and lower edges. Could anyone help? Thank you in advance.
Source = vision.VideoFileReader('video.mp4',... 'ImageColorSpace', 'Intensity');
Edge = vision.EdgeDetector('Method', 'Canny', ... 'ThresholdSource', 'Auto',... 'NonEdgePixelsPercentage', 98.3);
VideoEdges = vision.VideoPlayer('Name', 'Edges'); VideoEdges.Position = [700 50 600 400];
F=1; while ~isDone(Source)
frame = step(Source);
edges = step(Edge, frame);
w=50; %width of regions, 60 pixels.
N=1920/w; %number of regions of width w.
for n=1:N
for s=1:w
for j=300:800
for Rni=w*(n-1)+s
if edges(j,Rni)==1
y_m(F,n)=mean(j);
end
end
end
x_m(F,n)=Rni+w/2; %centre of each individual region
end
F=F+1; %for every frame individually
end
step(VideoEdges, edges);
end
release(Source);
  1 Kommentar
Image Analyst
Image Analyst am 7 Dez. 2013
It's hard to visualize the problem. Can you attach a screenshot or image or something?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Image Analyst
Image Analyst am 8 Dez. 2013
What are you trying to find and measure? The black snake-like thing? If so, why are you using edge detection???? And if so, what do you want to find out about it? Its centroid, length, area, perimeter, mean intensity, what??? Also why do you have what looks like bad reflections? Why not get rid of those with a better image capture setup (e.g. crossed polarizers or whatever)?
  6 Kommentare
Image Analyst
Image Analyst am 10 Dez. 2013
Upload just one frame as a PNG file then.
Image Analyst
Image Analyst am 10 Dez. 2013
A video is just a series of frames (individual images) so why wouldn't it work for the video?

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by