I want to embed the video to image then extract the video from that image.I have properly embeded the video to an image.But I am not able to extract.Can provide extractioncode

5 次查看(过去 30 天)
%THIS IS MY EMBEDVIDEO TO IMAGE CODE
% Read the image and video
image = imread('glioma.jpg');
video = VideoReader('medicine_health_surgery_hospital_729.mp4');
% Read the video frames and resize them to match the image size
numFrames = get(video, 'NumberOfFrames');
videoFrames = cell(numFrames, 1);
for i = 1:numFrames
frame = read(video, i);
videoFrames{i} = imresize(frame, [size(image, 1), size(image, 2)]);
end
% Embed the video frames into the image
embeddedImage = image;
bitplane = 1; % Choose the least significant bit (LSB) plane for embedding
tic; % Start the timer
for i = 1:numFrames
% Extract the bitplane from the video frame
videoFrame = videoFrames{i};
videoBitplane = bitget(videoFrame, bitplane);
% Embed the video bitplane into the image
embeddedImage = bitset(embeddedImage, bitplane, videoBitplane);
end
embeddedTime = toc; % Calculate the embedded time in seconds
% Calculate SNR and PSNR
originalImage = double(image);
embeddedImage = double(embeddedImage);
mse = mean((originalImage(:) - embeddedImage(:)).^2);
snr = 10 * log10(mean(originalImage(:).^2) / mse);
psnr = 10 * log10(max(originalImage(:))^2 / mse);
% Display original and embedded images side by side
figure;
subplot(1, 2, 1);
imshow(image);
title('Original Image');
subplot(1, 2, 2);
imshow(uint8(embeddedImage));
title('Embedded Image');
% Print embedded time, SNR, and PSNR
fprintf('Embedded Time: %.2f seconds\n', embeddedTime);
fprintf('SNR: %.2f dB\n', snr);
fprintf('PSNR: %.2f dB\n', psnr);
% Save the embedded image
imwrite(uint8(embeddedImage), 'embedded_image.jpg');

采纳的回答

Image Analyst
Image Analyst 2023-8-4
See attached demo that extracts individual frames from a video and saves them to disk, and then builds a new video from the individual disk images. Adapt as needed.

更多回答(1 个)

Sai Kiran
Sai Kiran 2023-8-4
Hi,
As per my understanding you want to convert a set of images into a video.
You can use the function 'writeVideo' to do the same.
Please refer to the following documentation for more information.
Thanks!

Community Treasure Hunt

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

Start Hunting!

Translated by