Concatenation of overlapping blocks with weighted average

4 views (last 30 days)
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 Comments
Stav
Stav on 16 Jun 2014
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 on 16 Jun 2014
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?

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!