how to change video gradient to improve edge detection

2 Ansichten (letzte 30 Tage)
Ben Timm
Ben Timm am 7 Apr. 2020
Kommentiert: darova am 14 Apr. 2020
Hi All,
Could you please give me a hand! I am currently writing up some cell analysis code that looks at a cell's radius and see's its change in size over time. At the moment I have gotten the edge detection software working fine but the video seems to be picking up uncessesary noise and I would really like to improve the image quality beofre I move to the next stage.
This is my code for the edge detection:
%% vidobj is input VidioReader Object
vidobj = VideoReader('VID00126.AVI');
numframes = get(vidobj, 'NumberOfFrames');
%% finalvid is output VideoWriter Object
finalvid = VideoWriter('edgedetVID00126.avi');
finalvid.FrameRate = vidobj.FrameRate;
open(finalvid);
c = 1;
for ii = 1 : 17
if rem(numframes,ii) == 0
if c < ii
c = ii;
end
if c == 1
c = 10;
end
end
end
startframe = 1;
stopframe = c;
while (stopframe <= numframes)
frames = read(vidobj, [startframe stopframe]);
for l = 1:size(frames,4)
temp = frames(:,:,:,l);
temp = rgb2gray(temp);
detectedge = edge(temp, 'canny');
detectedge = single(detectedge);
writeVideo(finalvid, detectedge);
end
startframe = startframe + c;
stopframe = stopframe + c;
end
close(finalvid);
I have been trying to use the following link's code to change the gradient but it only seems to be working for images, could anyone tell me what I could do?
Thanks in advance everyone.
Ben
  6 Kommentare
darova
darova am 9 Apr. 2020
  • At the moment I have gotten the edge detection software working fine but the video seems to be picking up uncessesary noise
You think it happens during writing video? You have good quality in MATLAB?
Ben Timm
Ben Timm am 9 Apr. 2020
Best I can do is screenshot! You can see the edge detection working but its got a tonne of uncessesary lines and ideally id like to clean up the image.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

darova
darova am 9 Apr. 2020
Try this
I0 = imread('Screenshot 2020-04-09 at 15.50.08.png');
I1 = im2bw(I0,graythresh(I0)-0.03); % binarize image with treshold
I2 = bwareaopen(I1,50); % remove small regions (50 pixels)
I3 = edge(I2);
II = imfuse(I0,I3);
imshow(II)
Looks like something simple but im not good at this
There is another person who specializes on this. But i don't like him
  2 Kommentare
Ben Timm
Ben Timm am 14 Apr. 2020
Hi Darova,
Sorry for not getting back to you quickly, it was due to medical reasons. This is interesting! I tried applying it to a video though and it wouldnt work (see attached) when I changed it to implay.
Thats perfectly fine and understandable, I doubt many use the code for this application. Would you happen to know their name so I can contact them as well?
Thanks again as usual :)
darova
darova am 14 Apr. 2020
Use this to read video
v = VideoReader('xylophone.mp4');
n = v.NumberOfFrames;
for i = 1:n
I0 = read(v,i);
% I0 = imread('Screenshot 2020-04-09 at 15.50.08.png');
I1 = im2bw(I0,graythresh(I0)-0.03); % binarize image with treshold
I2 = bwareaopen(I1,50); % remove small regions (50 pixels)
I3 = edge(I2);
II = imfuse(I0,I3);
imshow(II,'initialmagnification','fit')
pause(0.1)
end
  • Would you happen to know their name so I can contact them as well?
Sure, here is he: Image Analyst

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Convert Image Type finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by