really really new using matlab so here i go
if true
clear all;
cam=webcam;
img = snapshot(cam);
imwrite(img, 'a.jpg');
faceDetector = vision.CascadeObjectDetector();
videoFileReader = vision.VideoFileReader('a.jpg');
a= step(videoFileReader);
bbox= step(faceDetector, a);
m=img(bbox(2):bbox(2)+bbox(3),bbox(1):bbox(1)+bbox(3));
imshow(m);
end
the idea is to save "m" with the new bounds provided from "bbox"...thats cool i did that and "m" is the new image (only face)..the problem is "m" is a n x m unit 8 matrix image NOT like "img" a n x m x 3 unit 8 matrix image. I know about 2d (nxm) index only, i have no idea how to index a nxmx3 matrix (thats my problem i guess)... short story. Having a black and white "m" instead of the full collor "m" i wanted
any help appreciated
(sorry for my bad english)

 採用された回答

Ced
Ced 2014 年 11 月 3 日
編集済み: Ced 2014 年 11 月 3 日

0 投票

Hi
I'm not familiar with the output from snapshot, but concerning 3D matrices (or even higher dimensions), indexing works the same way it does for 2D matrices, just call e.g. A(1:2,2:4,1:3) instead of A(1:2,2:4). For your example, this may be something like
m = img(bbox(2):(bbox(2)+bbox(3)),bbox(1):(bbox(1)+bbox(3)),:)
since I'm guessing your 3 dimensions are color channels, and you want all three of them. If you don't specify that you want all three (through ":"), you will only get the first plane.
PS: Your english is perfectly fine.

1 件のコメント

cristian
cristian 2014 年 11 月 3 日
Thx man that completely solve my problem and i learn something new today thanks for everything

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeImage Processing and Computer Vision についてさらに検索

質問済み:

2014 年 11 月 3 日

コメント済み:

2014 年 11 月 3 日

Community Treasure Hunt

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

Start Hunting!

Translated by