performance: vision.AlphaBlender is slower when image is big.

2 vues (au cours des 30 derniers jours)
cui,xingxing
cui,xingxing le 13 Déc 2022
Modifié(e) : cui,xingxing le 14 Mar 2023
vision.AlphaBlender is a very good function that can do a lot of "image matting", but when I encounter a large image size, the speed is very slow, look forward to the official enhancement of the efficiency of this function.
blender = vision.AlphaBlender('Operation','Binary Mask',...
'MaskSource','Input port');
% big image test performance
HH = [8000,500];
WW = [8000,500];
for i = 1:length(HH)
H = HH(i);
W = WW(i);
bottomImg = zeros(H,W,3,'single');
topImg = rand(H,W,3,'single');
maskImg = zeros(H,W,'logical');
maskImg(1:100,1:100)=1;
t1 = tic;
outImg = blender(bottomImg,topImg,maskImg);
t2 = toc(t1);
fprintf('image size:(%d*%d) take time: %.3f seconds\n',H,W,t2)
end
image size:(8000*8000) take time: 2.445 seconds image size:(500*500) take time: 0.148 seconds

Réponse acceptée

cui,xingxing
cui,xingxing le 14 Mar 2023
Modifié(e) : cui,xingxing le 14 Mar 2023
There are many ways to solve this, such as rewriting the implementation of this function yourself in C/C++ and wrapping it as a mex. I now think it's not just about improving the algorithm, it's about external factors adjusting to my own needs, even if I rewrite it in an optimised C/C++ (not taking into account margin effects), such as cv::copyTo, they don't really differ much in performance, see the performance curve below.
note: uint8 type, two dims image array test

Plus de réponses (0)

Catégories

En savoir plus sur Image Processing Toolbox dans Help Center et File Exchange

Produits


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by