Create Segmentation.c

Parallel Algorithm
Given an image I with height=H, width= W & N pixels & P-processes,The parallel algorithm consists
of these steps
Step 1
Transform the image into weighted graph
•
Distribute the indexes of the image to P-blocks where there will be overlap in the sent data
because of the last sent row should know the next row values to calculate correctly the weights
Sent Image Block Size = ( ( H / P) +1 )* W
• Perform the calculations that mentioned in main algorithm
• Each process will has as result block of weights where
Weights Block Size = ( N / P ) * 4
Step 2
Segmentation
• For each process do partially the segmentation steps that mentioned in main algorithm on the
   weights block.
• The indexing of a regions block at process P will start from
Start Index = Sum ( RegionsBlock.Size ( p ) )
p [0,P-1]
•
The result at each process is block of regions & a queue of cross-border edges where
Regions Block Size = (N / P)
Queue Block Size = DelayedEdgesPerPixel * W
DelayedEdgesPerPixel = 3
• Allocate Regions & delay Queue from all processes to the root process
• Replace sequentially at root process the regions' indexes of the delayed edges with the correct
indexes
Step 3
Construct Segmented Images
At root process & for each region which size greater than givens threshold build an image I` with the
same size as the original image I & draw only the pixels in that region.