フィルターのクリア

auto detection of an image bacjground and blur it

2 ビュー (過去 30 日間)
sanjit
sanjit 2023 年 12 月 20 日
回答済み: Sulaymon Eshkabilov 2023 年 12 月 20 日
give a matlab code for this image that can focous the human then automitically detec this image background and then blur the background..this should work like potrait mode.

回答 (1 件)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2023 年 12 月 20 日
Here is one code that requires yolov2ObjectDetector() from YOLO model and does the job partially.
% Read your image:
O_Image = imread('H_image.jpeg');
% Load pre-trained YOLO model for object detection
yolonet = yolov2ObjectDetector();
% Detect objects in the image using YOLO
[bbox, score, label] = detect(yolonet, O_Image);
% Create a binary mask for humans
binaryMask = false(size(O_Image, 1), size(O_Image, 2));
for jj = 1:size(bbox, 1)
binaryMask(bbox(jj,2):bbox(i,2)+bbox(jj,4)-1, bbox(jj,1):bbox(jj,1)+bbox(jj,3)-1) = true;
end
% Convert binary mask to double
b_Mask = double(binaryMask);
% Blur the background using a Gaussian filter
blur_Background = imgaussfilt(O_Image, 10);
% Combine blurred background with original foreground (humans)
finalImage = double(originalImage) .* repmat(b_Mask, [1, 1, size(O_Image, 3)]) + ...
double(blur_Background) .* repmat(1 - b_Mask, [1, 1, size(O_Image, 3)]);
% The final image in uint8 format
F_Image = uint8(finalImage);
% Display and compare the obtained image
figure
imshow(O_Image);
title('Original Image');
figure
imshow(F_Image);
title('Blurred Background with Detected Humans');

カテゴリ

Help Center および File ExchangeComputer Vision with Simulink についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by