Hello, i want to compute a function handler for blockproc() like
fun = @(block_struct) ...
FD(block_struct.data) * ones(size(block_struct.data));
A = blockproc(I,[16 16],fun)
to process a imagine I and then calculate Box Counting in every blocks. My question is how to compute handler (fun) to do that ? Thanks in advance.

 Réponse acceptée

Walter Roberson
Walter Roberson le 10 Mai 2018

0 votes

Make FD a function that accepts one variable that is an array of data, and have it do the box counting on that array.
Just watch out for incomplete blocks: along the bottom edge and the right edge you will get blocks that are not 16 x 16 unless the size of the image happens to be an exact multiple of 16 in each direction.

4 commentaires

Constantin Alin
Constantin Alin le 11 Mai 2018
Modifié(e) : Walter Roberson le 11 Mai 2018
FD return a VALUE (D=) for entire image. What i want is to divide image to apply in each block FD. Result of blockproc is a Matrix A with these values calculated Per block.
I=512x512 (2^9)
Algorithm Reference :
fun = @(block_struct) BoxCountfracDim(block_struct.data) * ones(size(block_struct.data));
A = blockproc(I, [16 16], fun);
BoxCountfracDim will be invoked a number of times, each time with an image that is 16 x 16 (or smaller at the edges).
Constantin Alin
Constantin Alin le 11 Mai 2018
The code returns a matrix of the same size as the original image (512x512) and returns the same fractal dimension everywhere. A is a matrix 512x512 double.
fun = @(block_struct) BoxCountfracDim(block_struct.data);
out = blockproc(img, [16 16], fun, 'trim', false);
imagesc(out);

Connectez-vous pour commenter.

Plus de réponses (1)

Constantin Alin
Constantin Alin le 11 Mai 2018

0 votes

Thank you so much for your answers. It's work, but in some region of Matrix i have NaN values. Why ?

2 commentaires

Walter Roberson
Walter Roberson le 11 Mai 2018
BoxCountfracDim produces NaN if all of the entries in the input it is passed are zero. It produces NaN+NaN*i if the sum of the entries is negative.
Constantin Alin
Constantin Alin le 11 Mai 2018
Thanks, i understand Now.

Connectez-vous pour commenter.

Produits

Version

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by