MATLAB: Finding block with minimum mean in cell array

image processingMATLAB

Hi, I have a problem with finding blocks with minimum mean in cell array. I have a cell array like
salientMask_B128x128=mat2cell(salientMask,128 * ones(1, size(salientMask,1) / 128), 128 * ones(1, size(salientMask,2) / 128));
that divide a 512×512 image to blocks with size 128×128. now I want to find 4 first blocks which have minimum mean. how can I do it?

Best Answer

Get the mean for each block using cellfun, and apply a sort to get the indices in order.
M = cellfun (@(x) mean(x(:)), salientMask_B128x12) ;
[Msorted, idx] = sort(M(:)) ;
RequiredIndices = idx(1:4)
Related Question