"blockproc" with more than one output image

6 次查看(过去 30 天)
Hello!
I'm using blockproc from the image processing toolbox for processing some large images.
Is it possible to output more than one image? My prossing function returns two versions of the processed image, and I would like to save both.
Is there any way to do so?
BTW: Why does blockproc work single-threaded? It could easily create a new thread for each single block, as long as there are enough system resources (CPU cores and memory).

回答(3 个)

Walter Roberson
Walter Roberson 2011-6-1
Creating a new thread has a lot of overhead. It does not become worthwhile until you are working with somewhere over 5000 array elements.
It appears to me that you could concatenate the two processed images together and return that, and then afterwards pull out the appropriate stripes.
The version of MATLAB that I use is not new enough to have blockproc() so I cannot test; it appears to me that possibly your "fun" could return a cell array.
  2 个评论
Sean de Wolski
Sean de Wolski 2011-6-1
As long as the concatenation is along the first or second dimension, it can't concatenate along the third. It cannot convert to cell.
R2009b
Walter Roberson
Walter Roberson 2011-6-1
Yes, I was thinking of horzcat() in particular, and afterwards selecting the columns for each of the stripes. Though the de-interleaving would be made easier if the "fun" output the two images interleaved in alternate columns: then image1 could be pulled out as I(:,1:2:end)

请先登录,再进行评论。


Image Analyst
Image Analyst 2011-6-2
I guess I'm not sure what you're asking. What do you mean by "output two images"? So your "prossing function" (which may use blockproc internally, but so what) returns two images as two output arguments, and these are accepted by your calling routine. So go ahead and save them - you can use imwrite(). Again, not sure why you have a question about that. Why should blockproc have anything to do with saving those images? Or are you saying that your function called by blockproc returns two variables (either scalars or arrays) and that you want to take those and stick them into two different images that you're building up? You might need to explain in more detail (at least for me).

Lemar DeSalis
Lemar DeSalis 2011-6-3
"Or are you saying that your function called by blockproc returns two variables (either scalars or arrays) and that you want to take those and stick them into two different images that you're building up?"
Yes, that's exactly what I want to do.
I ended up extending my function, so that it has a "IsBlockProcMode"-Flag. Whenever that flag is set, the two output-images will be concatened in the third dimension (so instead of two N-by-M-by-3 color-images I'll get one N-by-M-by-6 image). Afterwards, this image will be manually split up into two separate images.
Not a very nice solution, but it's OK as a workaround.
  1 个评论
Sean de Wolski
Sean de Wolski 2011-6-3
You might also think about using the fourth dimension to stack RGB images. This is the way it's typically done in MATLAB.

请先登录,再进行评论。

Community Treasure Hunt

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

Start Hunting!

Translated by