Concatenation of overlapping blocks with weighted average

3 次查看(过去 30 天)
I'm looking for a quick way to combine overlapping blocks into one image. Assume the size of the full image and the coordinates of each block within the full image are known. Also assume the blocks are regularly spaced both horizontally and vertically.
The catch - in the overlapping region, a pixel in the output image should get a value according to a weighted average of the corresponding pixels in the overlapping blocks. The weights should be proportional to the distance from the block center.
So, for example, take a pixel location p (relative to the full image coordinates) in the overlapping region between block B1 and B2. Assume the overlap region is due to a horizontal shift only of size h. If B1(p) and B2(p) are the values at that location as they appear in blocks B1,B2, and d1,d2 are the respective distances of p from the center of blocks B1 and B2 then in the output image O the location p will get O(p) = (h-d1)/h*B1(p) + (h-d2)/h*B2(p).
Note that generally, there can be up to 4 overlapping blocks in any region.
I'm looking for the best way to do this in Matlab. Hopefully, for any choice of distance function.
blockproc and alike can help splitting an image into blocks but allow for very basic combination of results. imfuse comes close to what I need, but offers simple non-weighted alpha blending only. bwdist seems to be useful, but I haven't figured what the most efficient method to put it to use is.
  5 个评论
Stav
Stav 2014-6-16
The coordinates of the 2 blocks from my example are related by horizontal shift (so I guess like a sliding window). The overlap region of the 2 blocks is a column as tall as the blocks themselves and with width h.
B1(p) and B2(p) have different values because of the specific processing I do on the blocks (which you can ignore for the sake of the question).
This processing I do, has decreasing confidence as pixels are further away from the block center. This is why fusion of the blocks with a weighted average makes sense.
Matt J
Matt J 2014-6-16
B1(p) and B2(p) have different values because of the specific processing I do on the blocks (which you can ignore for the sake of the question).
That must mean that you've already extracted and manipulated the blocks. How are they stored now? As elements of a cell array?

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Computer Vision with Simulink 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by