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 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