필터 지우기
필터 지우기

finding specific value stored in cell

조회 수: 1 (최근 30일)
sabeeh
sabeeh 2011년 4월 1일
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
David Young
David Young 2011년 4월 1일
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 2011년 4월 2일
@David: ",3]}" is the part, which confuses me. Most likely "I have an image[200x200]" means "[200 x 200 x 3]".

댓글을 달려면 로그인하십시오.

답변 (2개)

Jan
Jan 2011년 4월 5일
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 2011년 4월 1일
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.

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by