Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
pmi432 / LR07 / 2read / image processing toolbox guide.pdf
Скачиваний:
166
Добавлен:
18.03.2015
Размер:
18.08 Mб
Скачать

Performing Distinct Block Operations

tic, im = blockproc('concordorthophoto.tif',[500 500],@(s) s.data); toc

Elapsed time is 17.806605 seconds.

Case 2: Worst Case — Column-Shaped Block. The file layout on the disk is in rows. (Stripped TIFF images are always organized in rows, never in columns.) Try choosing blocks shaped like columns of size [2215 111]. Now the block is shaped exactly opposite the actual file layout on disk.

The image is over 26 blocks wide (2956/111 = 26.631). Every strip must be read for every block. The blockproc function reads the entire image from disk 26 times. The amount of time it takes to process the image with the column-shaped blocks is proportional to the number of disk reads. With about four times as many disk reads in Case 2, as compared to Case 1, the elapsed time is about four times as long.

tic, im = blockproc('concordorthophoto.tif',[2215 111],@(s) s.data); toc

Elapsed time is 60.766139 seconds.

Case 3: Best Case — Row-Shaped Block. Finally, choose a block that aligns with the TIFF strips, a block of size [84 2956]. Each block spans the width of the image. Each strip is read exactly one time, and all data for a particular block is stored contiguously on disk.

tic, im = blockproc('concordorthophoto.tif',[84 2956],@(s) s.data); toc

Elapsed time is 4.610911 seconds.

Using Parallel Block Processing on large Image Files

If you have a Parallel Computing Toolbox™ license, you can take advantage of multiple processor cores on your machine by specifying the blockproc setting 'UseParallel' as true. Doing so divides the block processing among all available MATLAB sessions to potentially improve the performance of

blockproc.

15-15

15 Neighborhood and Block Operations

What is Parallel Block Processing?

Parallel block processing allows you to process many blocks simultaneously by distributing task computations to a collection of MATLAB sessions, called workers. The MATLAB session with which you interact is called the client.

The client reserves a collection of workers, called a MATLAB pool. Then the client MATLAB session divides the input image and sends sections to the worker MATLAB sessions. Each worker processes a subset of blocks and sends the results back to the client. The client MATLAB collects the results into an output variable.

When you set 'UseParallel' to true, blockproc uses all available workers in the MATLAB pool to process the input image in parallel.

To read more about parallel computing, see Key Problems Addressed by Parallel Computing and Introduction to Parallel Solutions in the Parallel Computing Toolbox User’s Guide.

When to Use Parallel Block Processing

When processing small images, serial mode is expected to be faster than parallel mode. For larger images, however, you may see significant performance gains from parallel processing. The performance of parallel block processing depends on three factors:

Function used for processing

Image size

Block size

In general, using larger blocks while block processing an image results in faster performance than completing the same task using smaller blocks. However, sometimes the task or algorithm you are applying to your image requires a certain block size, and you must use smaller blocks. When block processing using smaller blocks, parallel block processing is typically faster than regular (serial) block processing, often by a large margin. If you are using larger blocks, however, you might need to experiment to determine whether parallel block processing saves computing time.

15-16

Соседние файлы в папке 2read