Divide binary image into overlapping blocks using blockproc
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
sgericeb
am 27 Aug. 2021
Beantwortet: Rishabh Singh
am 31 Aug. 2021
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)
0 Kommentare
Akzeptierte Antwort
Rishabh Singh
am 31 Aug. 2021
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.
Hope this helps.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!