%  Read a color image, stored as 480x640x3 array.
%
  x = imread ('balloons.tif');
%
%  Create an image Y by adding "salt and pepper" noise to X.
%
  y = imnoise ( x, 'salt & pepper', 0.30 );
%
%  Make YD, a distributed version of Y.
%
  yd = distributed ( y );
%
%  Each worker works on its "local part", YL.
%
  spmd
    yl = getLocalPart ( yd );
    yl = medfilt2 ( yl, [ 3, 3 ] );
  end
%
%  The client retrieves the data from each worker.
%
  z(1:480,1:640,1) = yl{1};
  z(1:480,1:640,2) = yl{2};
  z(1:480,1:640,3) = yl{3};
%
%  Display the original, noisy, and filtered versions.
%
  figure;
  subplot ( 1, 3, 1 );imshow ( x );title ( 'Original image' );
  subplot ( 1, 3, 2 );imshow ( y );title ( 'Noisy Image' );
  subplot ( 1, 3, 3 );imshow ( z );title ( 'Median Filtered Image' );
