フィルターのクリア

How to save the cropped image as a RGB image?

1 回表示 (過去 30 日間)
sudha
sudha 2013 年 8 月 3 日
This is the pgm for face detection...
% set mex file path for this platform ...
addpath(lower(computer));
% call without arguments to display help text ...
fprintf('\n--- fdlibmex help text ---\n');
fdlibmex
% load an example image
I = imread('foodcourt.jpg');
figure, imshow(I);
Img = rgb2gray(I);
% bw = im2bw(Img);
Image = im2uint8(Img);
figure, imshow(Image);
% run the detector
pos = fdlibmex(Image);
% display the image
figure, imagesc(Image)
colormap gray
axis image
axis off
% draw red boxes around the detected faces
hold on
for i=1:size(pos,1)
r = [pos(i,1)-pos(i,3)/2,pos(i,2)-pos(i,3)/2,pos(i,3),pos(i,3)];
display(r);
r(1) = r(1)- 10;
r(2) = r(2)- 20;
r(3) = r(3)+ 60;
r(4) = r(4)+ 70;
r = [r(1) r(2) r(3) r(4)];
rectangle('Position', r, 'EdgeColor', [1,0,0], 'linewidth', 2);
r = imcrop(Image,[r(1) r(2) r(3) r(4)]);
figure, imshow(r);
imsave;
end
hold off
% show stats
fprintf('\n--- fdlibmex example ---\n');
fprintf('\n\t%d faces detected in \''%s\'' (see figure 1)\n\n', ...
size(pos,1), imgfilename);
Using the values stored in 'r', i have cut out the detected faces individually from some rgb images, and i am getting all faces in grayscale which is obvious because of the rgb2gray function i have used.. But is there any way to get those cut out faces in rgb ?? How to retain its original rgb composition after running the fdlibmex ?? Can anyone plz help me out..

採用された回答

Image Analyst
Image Analyst 2013 年 8 月 5 日
Just use the original (badly-named) I instead of the version of it you converted to gray scale, (the also very badly-named) Image:
r = imcrop(I,[r(1) r(2) r(3) r(4)]);
  1 件のコメント
sudha
sudha 2013 年 8 月 6 日
Thank You so much..

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeColor Space Formatting and Conversions についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by