diff --git a/V2rgb.m b/V2rgb.m index a450cca..0cbbd8e 100644 --- a/V2rgb.m +++ b/V2rgb.m @@ -13,6 +13,12 @@ % Loop through the images selected + +% Initialize a matrix to store RGB values +all_rgb = zeros(900, 3, 61, 101); + +% Initialize iteration +a=0; for i = 100:1000 % Set the image path image_path = imread(sprintf('frame2_%d.jpg', i)); @@ -23,12 +29,6 @@ for i = 100:1000 imwrite(roi, (sprintf('frames/my_imagev2%d.jpg',i))); end -% Initialize a matrix to store RGB values -all_rgb = zeros(900, 3, 61, 101); - -% Initialize iteration -a=0; - % Loop through 900 images for i = 100:1000 % Read image @@ -51,6 +51,7 @@ for i = 100:1000 % Display iteration disp(a); end + % Compute mean RGB values for each image mean_rgb = squeeze(mean(mean(all_rgb, 4), 3)); save('mean_rgb.m', 'mean_rgb'); @@ -115,7 +116,7 @@ hold off; xlabel('Frequency (Hz)'); ylabel('Magnitude'); -legend('Red', 'Green', 'Blue'); +legend({'Red', 'Green', 'Blue'}); % Find indices in f that correspond to the frequency range of interest idx_range = find(f >= 0.75 & f <= 4); diff --git a/video to image.py b/video to image.py index 8bd0d02..bb23823 100644 --- a/video to image.py +++ b/video to image.py @@ -13,10 +13,7 @@ total_frames = int(video.get(cv2.CAP_PROP_FRAME_COUNT)) frame_number = 0 while True: success, frame = video.read() - if not success: - break - if frame_number % int(frame_rate / 24) == 0: - cv2.imwrite("frame2_{}.jpg".format(frame_number), frame) + cv2.imwrite("frame2_{}.jpg".format(frame_number), frame) frame_number += 1 # Release the video file