💥💥💞💞欢迎来到本博客❤️❤️💥💥

🏆博主优势:🌞🌞🌞博客内容尽量做到思维缜密,逻辑清晰,为了方便读者。

⛳️座右铭:行百里者,半于九十。

📋📋📋本文目录如下:🎁🎁🎁

目录

💥1 概述

📚2 运行结果

🎉3 参考文献

🌈4 Matlab代码实现


💥1 概述

通过调用图像来重建新影片及计算颜色通道的平均灰度值,并检测帧与前一帧之间的差异

本文展示了一种从视频中提取帧并获取帧的方法,并且可以选择将单个帧保存到单独的图像文件中。接着,我们可以通过从磁盘调用保存的图像来重建新的影片。此外,我们还介绍了如何计算颜色通道的平均灰度值,并检测每一帧与前一帧之间的差异。

为了实现这些功能,我们使用了VideoReader和VideoWriter类。VideoReader类允许我们从视频文件中读取帧,并且可以指定读取的起始和结束时间。通过使用该类,我们可以轻松地获取视频中的每一帧。

接下来,我们可以选择将每一帧保存为单独的图像文件。这可以通过使用imwrite函数来实现。我们可以为每一帧指定一个文件名,并将其保存到指定的目录中。这样,我们就可以将视频拆分成单独的图像文件,方便后续处理或者用于其他用途。

另外,我们还可以计算颜色通道的平均灰度值。通过将每个像素的RGB值转换为灰度值,并计算所有像素的平均值,我们可以得到整个图像的平均灰度值。这个值可以用来描述图像的整体亮度。

最后,我们还可以检测每一帧与前一帧之间的差异。通过对比相邻帧的像素值,我们可以计算出它们之间的差异。这可以用来检测视频中的运动或者其他变化情况。例如,我们可以通过比较两个相邻帧的差异来检测物体的移动或者背景的变化。

综上,本文介绍了如何使用VideoReader和VideoWriter类来提取视频帧,并展示了如何保存单个帧作为图像文件。此外,我们还讨论了如何计算颜色通道的平均灰度值,并检测每一帧与前一帧之间的差异。这些技术可以在图像处理和视频分析领域中发挥重要作用。

📚2 运行结果

运行视频:

部分代码:

% Write the image array to the output file, if requested.
		if writeToDisk
			% Construct an output image file name.
			outputBaseFileName = sprintf('Frame %4.4d.png', frame);
			outputFullFileName = fullfile(outputFolder, outputBaseFileName);
			
			% Stamp the name and frame number onto the image.
			% At this point it's just going into the overlay,
			% not actually getting written into the pixel values.
			text(5, 15, outputBaseFileName, 'FontSize', 20);
			
			% Extract the image with the text "burned into" it.
			frameWithText = getframe(gca);
			% frameWithText.cdata is the image with the text
			% actually written into the pixel values.
			% Write it out to disk.
			imwrite(frameWithText.cdata, outputFullFileName, 'png');
		end
		
		% Calculate the mean gray level.
		grayImage = rgb2gray(thisFrame);
		meanGrayLevels(frame) = mean(grayImage(:));
		
		% Calculate the mean R, G, and B levels.
		meanRedLevels(frame) = mean(mean(thisFrame(:, :, 1)));
		meanGreenLevels(frame) = mean(mean(thisFrame(:, :, 2)));
		meanBlueLevels(frame) = mean(mean(thisFrame(:, :, 3)));
		
		% Plot the mean gray levels.
		hPlot = subplot(2, 2, 2);
		hold off;
		plot(meanGrayLevels, 'k-', 'LineWidth', 2);
		hold on;
		plot(meanRedLevels, 'r-');
		plot(meanGreenLevels, 'g-');
		plot(meanBlueLevels, 'b-');
		grid on;
		

% Write the image array to the output file, if requested.
        if writeToDisk
            % Construct an output image file name.
            outputBaseFileName = sprintf('Frame %4.4d.png', frame);
            outputFullFileName = fullfile(outputFolder, outputBaseFileName);
            
            % Stamp the name and frame number onto the image.
            % At this point it's just going into the overlay,
            % not actually getting written into the pixel values.
            text(5, 15, outputBaseFileName, 'FontSize', 20);
            
            % Extract the image with the text "burned into" it.
            frameWithText = getframe(gca);
            % frameWithText.cdata is the image with the text
            % actually written into the pixel values.
            % Write it out to disk.
            imwrite(frameWithText.cdata, outputFullFileName, 'png');
        end
        
        % Calculate the mean gray level.
        grayImage = rgb2gray(thisFrame);
        meanGrayLevels(frame) = mean(grayImage(:));
        
        % Calculate the mean R, G, and B levels.
        meanRedLevels(frame) = mean(mean(thisFrame(:, :, 1)));
        meanGreenLevels(frame) = mean(mean(thisFrame(:, :, 2)));
        meanBlueLevels(frame) = mean(mean(thisFrame(:, :, 3)));
        
        % Plot the mean gray levels.
        hPlot = subplot(2, 2, 2);
        hold off;
        plot(meanGrayLevels, 'k-', 'LineWidth', 2);
        hold on;
        plot(meanRedLevels, 'r-');
        plot(meanGreenLevels, 'g-');
        plot(meanBlueLevels, 'b-');
        grid on;

🎉3 参考文献

文章中一些内容引自网络,会注明出处或引用为参考文献,难免有未尽之处,如有不妥,请随时联系删除。

[1]金黎明,周晓光,苏志远.一种基于帧间差分背景重建的动目标检测算法[C]//2009年先进光学技术及其应用研讨会.0[2023-09-21].

[2]袁建英.序列图像光流计算关键技术研究及其在三维重建中的应用[D].西南交通大学,2015.DOI:CNKI:CDMD:1.1016.166603.

[3]王静婷,李慧斌.单张图像三维人脸重建方法综述[J].计算机工程与应用, 2023, 59(17):1-21.DOI:10.3778/j.issn.1002-8331.2210-0041.

🌈4 Matlab代码实现

相关文章

网络知识-以太网技术的发展及网络设备

大家都被互联网上各种各样的内容、技术闪亮了眼睛,没有太多人去了解比较底层的一些网络技术。面试的时候,我也问过很多技术人员,对以太网是否了解,了解多少?但是很多人都知之甚少!但是,在我们实际工作碰到问题、分析问题、定位问题、解决问题的时候,又必须要了解这方面的知识。以太网最初到现在的主要设备包括集线器、中继器、网桥、交换机。以太网目前应用在很多行业,在视频监控、安防、视频会议等领域都有很广泛的应用。

在Jetpack Compose中使用ExoPlayer实现直播流和音频均衡器

ExoPlayer与Media3的能力结合,为Android应用程序播放多媒体内容提供了强大的解决方案。在本教程中,我们将介绍如何设置带有Media3的ExoPlayer来支持使用M3U8 URL进行直播流。此外,我们还将探讨如何集成音频均衡器,为用户提供个性化的音频体验。使用ExoPlayer进行直播流涉及到利用ExoPlayer库的强大能力,在互联网上实时播放多媒体内容。在这个探索中,我们将深入了解ExoPlayer如何实现无缝播放直播流URL的复杂性,为用户提供沉浸式体验。
返回
顶部