Help me with this calculation that uses blockproc()

2 ビュー (過去 30 日間)
TUSHAR MURATKAR
TUSHAR MURATKAR 2017 年 8 月 4 日
編集済み: Image Analyst 2017 年 8 月 24 日
I have an input image of size 384x512 double. I applied blockproc() on this input image, with a blocksize of 20x20, and as a result I got new output image of size 58x77 double.
My question is "why is the output image size 58x77?"

回答 (1 件)

Walter Roberson
Walter Roberson 2017 年 8 月 4 日
With a 384 x 512 you do not have full blocks of 20 x 20 in either direction, so you will be operating on partial blocks on the edges.
Whatever operation you are doing is returning a 3 x 3 response for 20 x 20 blocks, but for the partial blocks it is returning 2 x 3 for the 4 x 20 partial blocks vertically, and 3 x 2 for the 20 x 12 the partial blocks horizontally, and 2 x 2 for the 4 x 12 partial corner block.
  2 件のコメント
TUSHAR MURATKAR
TUSHAR MURATKAR 2017 年 8 月 5 日
@walter, can u pls explain this with a pictorial or numerical example
Walter Roberson
Walter Roberson 2017 年 8 月 5 日
%I was slightly off on the above output description.
image_rows = 384;
image_columns = 512;
row_blocksize = 20;
column_blocksize = 20;
blockproc_output_rows = 58;
blockproc_output_columns = 77;
row_full_blocks = floor(image_rows/row_blocksize);
input_rows_used_for_full_blocks = row_blocksize * row_full_blocks;
row_partial_block_size = image_rows - input_rows_used_for_full_blocks;
outputs_per_full_row_block = floor(blockproc_output_rows ./ row_full_blocks);
output_rows_used_for_full_blocks = outputs_per_full_row_block * row_full_blocks;
leftover_blockproc_output_rows = blockproc_output_rows - output_rows_used_for_full_blocks;
column_full_blocks = floor(image_columns/column_blocksize);
input_columns_used_for_full_blocks = column_blocksize * column_full_blocks;
column_partial_block_size = image_columns - input_columns_used_for_full_blocks;
outputs_per_full_column_block = floor(blockproc_output_columns ./ column_full_blocks);
leftover_blockproc_output_columns = blockproc_output_columns - outputs_per_full_column_block * column_full_blocks;
output_columns_used_for_full_blocks = outputs_per_full_column_block * column_full_blocks;
leftover_blockproc_output_columns = blockproc_output_columns - output_columns_used_for_full_blocks;
fprintf('Image size is %d by %d\n', image_rows, image_columns);
fprintf('full input blocks are %d by %d\n', row_blocksize, column_blocksize);
fprintf('number of left-over input rows is %d; number of left-over input columns is %d\n', row_partial_block_size, column_partial_block_size);
fprintf('Output size is %d by %d\n', blockproc_output_rows, blockproc_output_columns);
fprintf('full output blocks are %d by %d\n', outputs_per_full_row_block, outputs_per_full_column_block);
fprintf('which uses up %d by %d of the output matrix\n', output_rows_used_for_full_blocks, output_columns_used_for_full_blocks);
fprintf('number of left-over output rows is %d; number of left-over output columns is %d\n', leftover_blockproc_output_rows, leftover_blockproc_output_columns);
fprintf('There are %d rows of output for each of the %d full input blocks with %d rows each\n', outputs_per_full_row_block, row_full_blocks, row_blocksize);
fprintf('There are %d rows of output for the one partial input block that was %d rows high\n', leftover_blockproc_output_rows, row_partial_block_size);
fprintf('There are %d columns of output for each of the %d full input blocks with %d columns each\n', outputs_per_full_column_block, column_full_blocks, column_blocksize);
fprintf('There are %d columns of output for the one partial input block that was %d columns wide\n', leftover_blockproc_output_columns, column_partial_block_size);
temp1 = sprintf('%2dx%2d ', row_blocksize, column_blocksize);
temp2 = [repmat(temp1, 1, column_full_blocks), sprintf('%2dx%2d\n', row_blocksize, column_partial_block_size)];
temp3 = repmat(temp2, 1, row_full_blocks);
temp4 = sprintf('%2dx%2d ', row_partial_block_size, column_blocksize);
temp5 = [repmat(temp4, 1, column_full_blocks), sprintf('%2dx%2d\n', row_partial_block_size, column_partial_block_size)];
fprintf('\nInput diagram:\n\n%s%s\n', temp3, temp5);
temp1 = sprintf('%2dx%2d ', outputs_per_full_row_block, outputs_per_full_column_block);
temp2 = [repmat(temp1, 1, column_full_blocks), sprintf('%2dx%2d\n', outputs_per_full_row_block, leftover_blockproc_output_columns)];
temp3 = repmat(temp2, 1, row_full_blocks);
temp4 = sprintf('%2dx%2d ', leftover_blockproc_output_rows, outputs_per_full_column_block);
temp5 = [repmat(temp4, 1, column_full_blocks), sprintf('%2dx%2d\n', leftover_blockproc_output_rows, leftover_blockproc_output_columns)];
fprintf('\nOutput diagram:\n\n%s%s\n', temp3, temp5);

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeImage Processing Toolbox についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by