Divide binary image into overlapping blocks using blockproc

조회 수: 8 (최근 30일)
sgericeb
sgericeb 2021년 8월 27일
답변: Rishabh Singh 2021년 8월 31일
I know variations on this question have been asked but I am still struggling. I have a binary image (matrix) and need to divide it into overlapping blocks of around 310x310 pixels with a 50% overlap between each block. The binary image is 11640x5096 pixels. If possible it would also be good to get smaller overlaps too, for example 25% across each block. I have some code but I am stuggling with the input values. I have working code on other image analysis programs but I need to process larger images now so need the extra speed of matlab. Any help would be greatly appreciated.
fun = @(block_struct) imresize(block_struct.data,0.15);
blockproc(A, [155 155], @(x) mean(x.data(:)), 'BorderSize', [155 3155], 'TrimBorder', false, 'PadPartialBlocks',false)

채택된 답변

Rishabh Singh
Rishabh Singh 2021년 8월 31일
As per my understanding, you wish to divide your image into overlapping blocks and later perform certain post-processing by using a custom function on overlapping block.
fun = @(block_struct) imresize(block_struct.data , 0.25);
processed_image = blockproc(original_image , [155 155],fun, 'BorderSize' , [77,77], 'UseParallel' , true , 'TrimBorder' , false );
figure;
imshow(processe_image);
To ensure appropriate overlapping, you will have to calculate the ‘BorderSize’ and ‘BlockSize’ values. Simply saying ‘BorderSize’ will added to ‘BlockSize’(refer to blockproc BorderSize explanation), meaning the BorderSize will be the common pixel between adjacent blocks.
You can also refer to how to divide the image into overlapping blocks for additional help.
Hope this helps.

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by