Dark image using imshow
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello,
I'm having a problem with imshow. I'm going point per point through my data and want to plot the corresponding video while I do this.
The file works when there is no video in it. And in another file I was able to plot the whole data with the video playing.
BUT: now when I use "animatedline" with "addpoints" the video is black. The video is black and becomes lighter sometimes, but you can't see anything.I have added a screenshot of the figure while its going through the data in the attachment.
UPDATE: when i remove all the animatedlines and addpoints the video plays correctly
Here is my code
%code
daqrate = 40;
VID = VideoReader('Zwemvideo1.mp4','Tag','My reader object');
writerObj = VideoWriter('output_video','MPEG-4');
writerObj.FrameRate = 40;
fps=30;%VID.FrameRate;
totalframes=VID.NumberOfFrames;
rate=daqrate/fps;
frameA=read(VID,1);
x=[329 752];
y=[50 411];%56
ratio =(y(2)-y(1))/(x(2)-x(1));
acc_y = resample(acc_y,3,4);
acc_z = resample(acc_z,3,4);
gyr_y = resample(gyr_y,3,4);
gyr_x = resample(gyr_x,3,4);
figure
subplot(5,1,1)
xlabel('samples')
ylabel('gyr_x filtered')
title('Turn detection')
h = animatedline;
axis([0 length(gyr_x) -230 330])
x = linspace(0,length(gyr_x),length(gyr_x));
subplot(5,1,2)
xlabel('samples')
ylabel('acc_z filtered')
title('Stroke detection')
g = animatedline;
axis([0 length(acc_z) -1 1.5])
y = linspace(0,length(acc_z),length(acc_z));
subplot(5,1,3)
xlabel('samples')
ylabel('gyr_y filtered')
title('Stroke detection')
f = animatedline;
axis([0 length(gyr_y) -100 140])
z = linspace(0,length(gyr_y),length(gyr_y));
subplot(5,1,4)
xlabel('samples')
ylabel('acc_y filtered')
title('Stroke detection')
e = animatedline;
axis([0 length(acc_y) -2 2])
w = linspace(0,length(acc_y),length(acc_y));
for i = 1: length(gyr_x)
%video
drawnow
subplot(5,1,5)
frame= read(VID,1+i-1);
imshow(frame(y(1):y(2),x(1):x(2),:),[]);
%rest
gyr_x_memory= gyr_x(1:i);
gyr_x_lowpass = [gyr_x_lowpass lowpass_filter(32,gyr_x_memory,gyr_x_lowpass)];%32
%gyr_x_lowpass=abs(gyr_x_lowpass);
gyr_y_memory= gyr_y(1:i);
gyr_y_lowpass = [gyr_y_lowpass lowpass_filter(20,gyr_y_memory,gyr_y_lowpass)];
%gyr_y_lowpass=abs(gyr_y_lowpass);
acc_z_memory= acc_z(1:i);
acc_z_lowpass = [acc_z_lowpass lowpass_filter(20,acc_z_memory,acc_z_lowpass)];
%acc_z_lowpass=abs(acc_z_lowpass);
acc_y_memory= acc_y(1:i);
acc_y_lowpass = [acc_y_lowpass lowpass_filter(64,acc_y_memory,acc_y_lowpass)];%20->30 meer gesmooth
addpoints(h,x(i),gyr_x_lowpass(i));
drawnow limitrate
addpoints(g,y(i),acc_z_lowpass(i));
drawnow limitrate
addpoints(f,z(i),gyr_y_lowpass(i));
drawnow limitrate
addpoints(e,w(i),acc_y_lowpass(i));
drawnow limitrate
end
0 Kommentare
Antworten (1)
Image Analyst
am 16 Apr. 2016
Your "frame" appears to be 3D. Using [] in imshow() doesn't work for RGB images. So you're going to have to figure out why your "frame" values are not integers in the range 0 - 255.
16 Kommentare
Image Analyst
am 17 Apr. 2016
Are the addpoints supposed to go to other axes, or onto the image axes?
If onto the image axes, then perhaps use hold on.
If onto one of the top 4 axes, then use subplot() to switch the current axes back to the one it's supposed to plot into.
Siehe auch
Kategorien
Mehr zu Audio and Video Data finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!