Notes
Notes - notes.io |
imageFolder = uigetdir(pwd, 'Select the folder containing the images');
%Check
if imageFolder == 0
error('Folder selection canceled. Please select a valid folder.');
end
%list of all image files in the folder
imageFiles = dir(fullfile(imageFolder, 'image-*.jpg'));
%Check
if isempty(imageFiles)
error('No image files found in the specified folder.');
end
%%%%%%%%%%%% READ %%%%%%%%%%%%%%%%
%Read the first image dimensions
firstImage = imread(fullfile(imageFolder, imageFiles(1).name));
[rows, cols, channels] = size(firstImage);
%Initialize a 4-D array to store all images
numImages = length(imageFiles);
imageArray = zeros(rows, cols, channels, numImages, 'uint8');
%Read each image and store it in the 4-D array
for i = 1:numImages
imageArray(:, :, :, i) = imread(fullfile(imageFolder, imageFiles(i).name));
end
%VideoWriter object to write the 4-D array to an AVI file
videoFile = VideoWriter('E1-video.avi');
open(videoFile);
%%%%%%%%%%%% WRITE %%%%%%%%%%%%%%%%
%Write each frame to the video file
for i = 1:numImages
writeVideo(videoFile, imageArray(:, :, :, i));
end
%Close video file
close(videoFile);
%%%%%%%%% CONVERT AND WRITE %%%%%%%%%%%%
%VideoWriter object for the output video (Red border and grayscale)
outputVideoFile = VideoWriter('E1-output-video.avi');
open(outputVideoFile);
%Convert to grayscale and add a red border
for i = 1:numImages
% Get the current frame
frame = imageArray(:, :, :, i);
% Convert to grayscale
grayFrame = mean(frame, 3);
outputFrame = repmat(uint8(grayFrame), [1, 1, 3]);
% Add a red border
outputFrame(1, :, 1) = 255; % Top row red
outputFrame(1, :, 2:3) = 0; % Top row green and blue
outputFrame(end, :, 1) = 255; % Bottom row red
outputFrame(end, :, 2:3) = 0; % Bottom row green and blue
outputFrame(:, 1, 1) = 255; % Left column red
outputFrame(:, 1, 2:3) = 0; % Left column green and blue
outputFrame(:, end, 1) = 255; % Right column red
outputFrame(:, end, 2:3) = 0; % Right column green and blue
% Write the processed frame to the output video file
writeVideo(outputVideoFile, outputFrame);
end
% Close the output video file
close(outputVideoFile);
disp('Both video files created successfully.');
|
Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 12 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team