Azzera filtri
Azzera filtri

finding specific value stored in cell

1 visualizzazione (ultimi 30 giorni)
sabeeh
sabeeh il 1 Apr 2011
i have an image[200x200]. i have converted it to cell using mat2cell command which is mat2cell([50 50 50 50],[50 50 50 50],3]}. My original image had a maximum value of pixel on 120,134 i-e 120 row and 130 column. I want to find which cell has got this pixel value in it i-e whether c{5},c{6} etc has got 120,134 value in it..please help me
  3 Commenti
David Young
David Young il 1 Apr 2011
Jan - mat2cell splits up the original array into subarrays, and the partitioning is specified by the arguments. Here, the image is split up into 16 blocks of 50x50 pixels each. I think sabeeh is asking which block a particular pixel finds itself inside - but the documentation has a diagram which is clearer than any answer I can write would be.
Jan
Jan il 2 Apr 2011
@David: ",3]}" is the part, which confuses me. Most likely "I have an image[200x200]" means "[200 x 200 x 3]".

Accedi per commentare.

Risposte (2)

Jan
Jan il 5 Apr 2011
If you have a cell, which contains numeric arrays (or scalars) and want to find the cell- and array-index of the min and max values, FEX: MinMaxElem works efficiently:
C = num2cell(rand(10, 10, 10), [1, 2]);
[minVal, maxVal, minIdx, maxIdx, minArg, maxArg] = MinMaxElem(C{:});
Now minArg is the linear index (see IND2SUB) of the cell, which contains the minimal element, and minInd is the linear index related to C{minArg}.

David Young
David Young il 1 Apr 2011
I assume your image dimensions are actually 200 x 200 x 3, and also that the call to mat2cell had the image as the first argument, followed by the arguments you show.
In this case, the pixel at (120, 134) in the original image will be in the array stored in c{3,3}, where c is the cell matrix (in fact, at row 20, column 34 of this array).
The documentation for mat2cell explains better than I can which pixel from the original image ends up in which cell.

Categorie

Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by