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

1 次查看(过去 30 天)
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

采纳的回答

cui,xingxing
cui,xingxing 2023-3-14
编辑:cui,xingxing 2023-3-14
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Image Processing Toolbox 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by