フィルターのクリア

How can i Blur the background of an image?

2 ビュー (過去 30 日間)
rifat
rifat 2024 年 4 月 30 日
編集済み: DGM 2024 年 4 月 30 日
Hello, I have to be able to blur only object of a .jpg not subject. I have tried many times but the whole picture both subject and object is getting blurry.,any help would be greatly appreciated.

回答 (1 件)

DGM
DGM 2024 年 4 月 30 日
編集済み: DGM 2024 年 4 月 30 日
Create a mask which selects the foreground (or background). Compose the output using the mask, the original image, and a blurred copy.
% an image (RGB, uint8)
inpict = imread('peppers.png');
% an antialiased mask selecting the foreground (I, uint8)
mask = imread('chilipepmask.png');
% a blurred copy of the entire image
blurred = imgaussfilt(inpict,5);
% compose the output using MIMT tools
%outpict = replacepixels(inpict,blurred,mask);
% compose the output using base tools
mask = im2double(mask);
outpict = mask.*im2double(inpict) + (1-mask).*im2double(blurred);
outpict = im2uint8(outpict); % presuming the output should always be uint8
imshow(outpict,'border','tight')
See also:

カテゴリ

Help Center および File ExchangeImage Processing Toolbox についてさらに検索

製品


リリース

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by