필터 지우기
필터 지우기

Generalize centervalue to return the center value and a 2-element vector representing the row-column coordinate of the center. Call it centervalue2. >> centervalue2(magic(5)) ans = 13 >> [c loc] = centervalue2(magic(5)) c = 13 loc = 3 3

조회 수: 2 (최근 30일)
plz help

답변 (1개)

Prem Kumar Tiwari
Prem Kumar Tiwari 2018년 9월 26일
Hello Song,
Following function will find out the center location of the given matrix mat. You can refer to the [row, col] values returned by it to find out the value at that location.
CAUTION : When one of the dimension of matrix is even, it will still find out the center which ideally do no exists. For the even dimension it will report the center point value to be the last value from the first half of the length in that dimension.
function [mid_row, mid_col] = findCenter(mat)
mid_row = floor((size(mat, 1) + 1) / 2);
mid_col = floor((size(mat, 2) + 1) / 2);
end

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by