[英]Matlab displaying binary images as video
I'm using this code as a starting point to detect the skin color of a hand in a video. 我将此代码用作检测视频中手的肤色的起点。 as the first step I've manged to do that and display the result by using the imshow(segment); 作为第一步,我努力做到了,并使用imshow(segment)显示结果; function in Matlab. Matlab中的功能。
here's the code (found online) i don't fully understand: 这是我不完全了解的代码(可在网上找到):
function SkinDetection()
obj = VideoReader('CloseupHandVid.mp4');
nframes = read(obj, inf);
nframes = get(obj, 'NumberOfFrames');
I = read(obj, 1);
for k = 1 : nframes
singleFrame = read(obj, k);
Skin(:,:,:,k) = singleFrame;
whos v
I=double(singleFrame);
[hue,s,v]=rgb2hsv(I);
cb = 0.148* I(:,:,1) - 0.291* I(:,:,2) + 0.439 * I(:,:,3) + 128;
cr = 0.439 * I(:,:,1) - 0.368 * I(:,:,2) -0.071 * I(:,:,3) + 128;
[w h]=size(I(:,:,1));
for i=1:w
for j=1:h
if 140<=cr(i,j) && cr(i,j)<=165 && 140<=cb(i,j) && cb(i,j)<=195 && 0.01<=hue(i,j) && hue(i,j)<=0.1
segment(i,j)=1;
else
segment(i,j)=0;
end
end
end
imshow(segment);
end
end
and here is the result: segmented skin 结果如下: 皮肤分割
the problem i'm having is that i can't figure out how to display the binary images as a video by using either vision.VideoPlayer or vision.VideoDeployer so i can display the result of the skin detected video next to original like in this example: 我遇到的问题是我无法弄清楚如何使用vision.VideoPlayer或vision.VideoDeployer将二进制图像显示为视频,因此我可以像这样在原始图像旁边显示皮肤检测到的视频的结果例:
http://uk.mathworks.com/help/vision/examples/motion-based-multiple-object-tracking.html?searchHighlight=multiple%20motion%20detection http://uk.mathworks.com/help/vision/examples/motion-based-multiple-object-tracking.html?searchHighlight=multiple%20motion%20detection
In the example you cited, there are two vision.VideoPlayer
objects: one for displaying the original video, and one for displaying the binary images. 在您引用的示例中,有两个vision.VideoPlayer
对象:一个用于显示原始视频,另一个用于显示二进制图像。 You simply feed the binary images into the step
method of the vision.VideoPlayer
object. 您只需将二进制图像输入到vision.VideoPlayer
对象的step
方法中vision.VideoPlayer
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.