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

2 ビュー (過去 30 日間)
cui,xingxing
cui,xingxing 2022 年 12 月 13 日
編集済み: cui,xingxing 2023 年 3 月 14 日
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 Center および File ExchangeImage Processing Toolbox についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by