slow imwarp with large arrays
댓글 수: 0
채택된 답변
댓글 수: 4
추가 답변 (3개)
Hi @Nic Bac ,
As mentioned in the documentation,
https://www.mathworks.com/help/images/ref/imwarp.html
specifying the OutputView parameter can enhance performance by defining the output size and location. For large images, defining an appropriate output view can minimize unnecessary computations and speed up processing:
outputView = affineOutputView(size(refimg), tform); [Imagenew, Rnew] = imwarp(refimg, Rimage, tform, "OutputView", outputView, "cubic", FillValues=0);
If performance is still an issue, consider using other functions or techniques that may better utilize multi-core capabilities. For example, if you have access to a compatible GPU, leveraging GPU computing could significantly speed up your image transformations:
refimgGPU = gpuArray(refimg); [ImagenewGPU, Rnew] = imwarp(refimgGPU, RimageGPU, tform, "cubic", FillValues=0); Imagenew = gather(ImagenewGPU); % Transfer back to CPU
For extremely large images or when dealing with multiple images, consider breaking down the image into smaller tiles or batches and processing them individually in parallel:
% Example of tiling approach (pseudo-code) parfor i = 1:numTiles [Imagenew{i}, Rnew{i}] = imwarp(tiles{i}, RimageTile{i}, tform); end
Please bear in mind that large images require significant memory resources. Ensure your system has enough RAM to handle the image sizes you are working with and using a recent version of MATLAB that supports advanced features in parallel computing and GPU acceleration. Versions beyond R2021a have improved support for these capabilities. Also, utilize MATLAB's built-in profiler (profile on; ...; profile viewer;) to identify bottlenecks in your code execution and determine whether imwarp is indeed the limiting factor.
Hope this helps.
댓글 수: 2
- Parallel pools, which rely on the Parallel Computing Toolbox, need to be explicitly specified using syntax such as parfor. Each parallel thread calculates independently and cannot share data.
- Automatic parallelization, does not depend on the toolbox, and does not need to be explicitly specified. During the vectorization of large arrays, the main process of MATLAB automatically invokes parallel computation. However, automatic parallelization is disabled when parallel pool (1) is enabled.
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!