Filter löschen
Filter löschen

Dividing an image into blocks of 64*64

1 Ansicht (letzte 30 Tage)
NC
NC am 16 Jun. 2018
Kommentiert: NC am 17 Jun. 2018
I want to divide an image of size into blocks of 64*64 non-overlapping blocks and then apply a user defined function to calculate the ratio between highest pixel value and total pixel values. So how to divide the image into non-overlapping blocks ?

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 16 Jun. 2018
aux_fun = @(block_info) YourFunction(block_info.block);
result = blockproc(aux_fun, [64 64], 'TrimBorder', false);
YourFunction should take in a 64 x 64 block and return the ratio or a vector of information.
Note: more work is needed if the image is not an exact multiple of 64 on each side.
  8 Kommentare
Walter Roberson
Walter Roberson am 17 Jun. 2018
I = imread('cameraman.tif'); %for example
aux_fun = @(block_info) YourFunction(block_info.data);
result = blockproc(I, [64 64], aux_fun, 'TrimBorder', false)
with
function result = YourFunction(block_of_image)
result = double(max(block_of_image(:))) ./ sum(double(block_of_image(:)));
NC
NC am 17 Jun. 2018
Thank you very much. The problem solved.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by