## N-dimensional find

버전 1.2.0.0 (1.99 KB) 작성자:
FIND_NDIM Finds the first or last nonzero element indices along a given matrix dimension.
다운로드 수: 832
업데이트 날짜: 2012/8/20

라이선스 보기

This function finds the 'first' pixel in an N-dimensional image, along any dimension. This is somewhat like measuring from the top row of an image towards the bottom row of the image, and recording the first collision with an "on" pixel.

FIND_NDIM Finds first/last nonzero element indices along a dimension.
I = FIND_NDIM(BW,DIM) returns the subscripts of the first nonzero
elements of BW along the dimension DIM. Output I will contain zeros in
element locations where no nonzero elements were found

I = FIND_NDIM(BW,DIM,'first) is the same as I = FIND_NDIM(BW,DIM).

I = FIND_NDIM(BW,DIM,'last') returns the subscripts of the last nonzero
elements of BW along the dimension DIM.

[I,MASK] = FIND_NDIM(BW,DIM,...) also returns a MASK the same size as
BW with only the first/last pixels in dimension DIM on.

Example 1:
If X = [0 1 0
1 1 0]
then find_ndim(X,1) returns [2 1 0], find_ndim(X,1,'last')
returns [2 2 0], and find_ndim(X,2) returns [2 1]';

Example 2:
I = imread('rice.png');
greyIm = imadjust(I - imopen(I,strel('disk',15)));
BW = imclearborder(bwareaopen(im2bw(greyIm, graythresh(greyIm)), 50));
topMostOnInds = find_ndim(BW, 1, 'first');
rightMostOnInds = find_ndim(BW, 2, 'last');
figure, imshow(BW), hold on
plot(1:size(BW,2), topMostOnInds, 'r.')
plot(rightMostOnInds, 1:size(BW,1), '.b')

A discussion of how this came about is at:
http://www.mathworks.com/matlabcentral/newsreader/view_thread/244823

### 인용 양식

Sven (2024). N-dimensional find (https://www.mathworks.com/matlabcentral/fileexchange/27755-n-dimensional-find), MATLAB Central File Exchange. 검색됨 .

개발 환경: R2010a
모든 릴리스와 호환
##### 플랫폼 호환성
Windows macOS Linux
##### 카테고리
Help CenterMATLAB Answers에서 Feature Detection and Extraction에 대해 자세히 알아보기

### Community Treasure Hunt

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

Start Hunting!
버전 게시됨 릴리스 정보
1.2.0.0

Added mask second output argument

1.1.0.0

Updated icon and help

1.0.0.0