how can i blur an image background only
10 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
suppose i want to blur an dog image backgroung..just background only not the dog..what code should i use for this?help please
0 commentaires
Réponses (1)
DGM
le 11 Déc 2023
Using basic tools:
% an image (RGB, uint8)
inpict = imread('peppers.png');
imshow(inpict,'border','tight')
% a mask which selects the BG (I, uint8)
% this happens to be antialiased, but it's not necessary
mask = imread('redpepmask.png');
mask = imcomplement(mask);
imshow(mask,'border','tight')
% blur a copy
blurred = imgaussfilt(inpict,5);
% compose the output
mask = im2double(mask);
outpict = im2double(blurred).*mask + im2double(inpict).*(1-mask);
outpict = im2uint8(outpict);
% show it
imshow(outpict,'border','tight')
See also:
Local blurring meta-answer:
An example of using roifilt2() on an RGB image can be found here:
An example of doing blurring (hard and soft masks) using basic composition methods and basic MATLAB/IPT tools can be found here:
An example of doing soft-masked blurring using purpose-built composition tools can be found here (see the last face-blurring example):
0 commentaires
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!