Skip to content

Commit

Permalink
add gamma parameter to play_wctestrecord
Browse files Browse the repository at this point in the history
  • Loading branch information
heimel committed Apr 23, 2018
1 parent f8351fa commit 9578dd5
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions Webcam/play_wctestrecord.m
Expand Up @@ -38,18 +38,23 @@ function play_wctestrecord(record)
vid.CurrentTime = starttime;
end

disp('Keys: left = previous frame, right = next frame, down = play until up, q = quit');
disp('Keys: left = previous frame, right = next frame, down = play until up, q = quit, + = increase gamma, - = decrease gamma');

figure('Name',['Play ' recordfilter(record)],'NumberTitle','off','MenuBar','none');
fig = figure('Name',['Play ' recordfilter(record)],'NumberTitle','off','MenuBar','none');
changed = true;

gamma = 1;

while 1
if ~hasFrame(vid)
logmsg('No more frames available');
pause(0.01);
elseif changed
imframe = readFrame(vid);
image(imframe);

gimframe = uint8(double(imframe).^gamma / (255^gamma) * 255);

image(gimframe);
axis image
changed = false;
title([num2str(vid.CurrentTime,'%.2f') ' s - Frame ' num2str(vid.CurrentTime*frameRate) ]);
Expand All @@ -66,6 +71,19 @@ function play_wctestrecord(record)
end

switch keyCode
case '-'
gamma = gamma + 0.1;
gimframe = uint8(double(imframe).^gamma / (255^gamma) * 255);
image(gimframe);
axis image
case '+'
if gamma>0.1
gamma = gamma - 0.1;
end
gimframe = uint8(double(imframe).^gamma / (255^gamma) * 255);

image(gimframe);
axis image
case 31 %arrow down
while hasFrame(vid)
vidFrame = readFrame(vid);
Expand All @@ -89,9 +107,9 @@ function play_wctestrecord(record)
end
case 29 % arrow right
changed = true;
case 81 % q
case 'q'
break
end
end

delete(fig);

0 comments on commit 9578dd5

Please sign in to comment.