Speeding up Image Processing Using Parallel Computing Toolbox?

When I write image processing programs, I usually apply morphological operations and regionprops. The function regionprops gets prohibitively slow when there are many objects. The morphological operations are another bottle neck, even though not such big a problem. Is it possible to speed up these operations with Parallel Computing Toolbox?

An example program looks like this:

function MyProgram()

% Image is loaded and segmented.

GrayscaleImage = imread('coins.png');

Threshold = rand(1);

ThresholdedImage = im2bw(GrayscaleImage, Threshold);

ObjectImage NumberOfObjects = bwlabel(ThresholdedImage);

% The number of pixels per object is calculated. Only objects with a minimum
% size are retained.

Statistics = regionprops(ObjectImage, {'PixelIdxList', 'Area'});

MinArea = 100;

ToBeRetained = arrayfun(@(x) x.Area >= MinArea, Statistics);

Statistics(~ToBeRetained) = [];

ObjectImage(:) = 0;

% Objects are transferred from old to new object image. We 
% don't need a for loop here.
arrayfun(@TransferPixels, Statistics, (1 : length(Statistics))');

% Nested function that transfers pixels from old to new object image
function TransferPixels(ObjectInfo, ObjectIndex)

ObjectImage(ObjectInfo.PixelIdxList) = ObjectIndex;



How can this program be sped up?

11/13/2008 10:57:01 AM
comp.soft-sys.matlab 211266 articles. 23 followers. lunamoonmoon (257) is leader. Post Follow

0 Replies

Similar Articles

[PageSpeed] 30