Reputation: 12252
Let's say I have a very large bitmap and it should be divided into smaller chunks for parallel processing. But in some cases edge pixels from neighboring area should be taken account. Should I simply add some overlap/padding or is there something else to do?
Upvotes: 4
Views: 573
Reputation: 74475
Extending subblocks on those sides that neighbour other subblocks is a common pattern in parallel processing. It is called ghost cells pattern on halos pattern. Basically you take as much pixels of ghost cells/halo as the processing stencil requres and communicate their value at the beginning of each processing iteration. It is also possible to take twice as large halo area and thus reduce in half the number of communications (improves performance on high latency networks). The process in which each parallel process sends parts of its subblock into the halo areas of its neighbours and vice versa is called halo swapping. Most parallel processing libraries (e.g. MPI) provide routines that aid in performing those halo swaps (e.g. MPI_Cart_shift()
combined with MPI_Sendrecv()
in MPI).
Upvotes: 2
Reputation: 146
Yes, overlapping is the most common solution. Beware that on the physical edges of your image, you will have to do something more clever, because there won't be any pixels to take from neighbooring tiles. Common solution are mirroring or prolongation through continuity the content of your image, unless you don't mind your output image being smaller than your input image.
Upvotes: 1