GPU imadjust pagefun workaround
显示 更早的评论
Hello,
I am trying to run the image processing function "imadjust" on a movie using a GPU. This function is supported on GPUs and I can get it to work on single images. However, it is not supported by pagefun and therefore I have to run a for loop over all 6000 images in the movie, which takes a very long time and defeats the purpose of using a GPU. I can't imagine this is all that rare a thing to do with these tools. Am I missing something? Is there a more efficient way of doing this or am I stuck using for loops? Here is the code I'm using:
GPUpics = gpuArray(pictures);
stretched = zeros(size(GPUpics),'gpuArray'); for k = 1:size(stretched,3) stretched(:,:,k) = imadjust(GPUpics(:,:,k)); end
2 个评论
Corey Silva
2017-10-23
Hi Josh,
I have passed along a request for pagefun to support imadjust to our development team. It will be considered for future releases of MATLAB.
Joss Knight
2017-10-26
编辑:Joss Knight
2017-10-26
I don't really understand - you only have one GPU, correct? And as long as your images are not tiny, the GPU will be fully utilized processing each one. So there's no way to parallelize it more, and all batch processing is going to do is write your loop for you. Also, pagefun is a very specific function for batch algebraic operations in Parallel Computing Toolbox, and not a generic batch processing function. Not that your proposal isn't interesting. But the point of using the GPU is to process the many pixels of your image in a massively parallel way, not to process multiple images in batch.
If your GPU isn't fully utilized you can use a parfor loop to process your images more efficiently. If you are on Linux you should use the Multi-Process Service to get true concurrency between processes.
Failing this, I don't know the details of how imadjust is being used, but I expect there's a way you could simply reshape your data and imadjust whole chunks of the video at once as if it were a single larger image.
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 GPU Computing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!