Create a new matrix that contains indices for values that are larger than X

조회 수: 3 (최근 30일)
Jhangir
Jhangir 2013년 10월 7일
댓글: Image Analyst 2013년 10월 7일
Lets say I have a matrix D and I ask the user to input a number into X. Now I need a new matrix which contains indices for values that are larger than X, what do I do to do this?

답변 (1개)

Image Analyst
Image Analyst 2013년 10월 7일
편집: Image Analyst 2013년 10월 7일
[rows, columns] = find(D > X);
  댓글 수: 4
Jhangir
Jhangir 2013년 10월 7일
“number of pixels” x “number of pixels”.
Image Analyst
Image Analyst 2013년 10월 7일
편집: Image Analyst 2013년 10월 7일
rows and columns are your new matrices. So row(1) and column(1) are the row and column of the first element that is more than x.
If you want a binary "map" of where it's greater than just threshold:
binaryImage = D > X;
That will be a matrix of true and false (1 & 0) the same size as D. If you want just a long 1D list of values, you can do
bigValues = D(binaryImage);
But you said "new matrix which contains indices" so I gave you that. rows and columns contain the indices. To say that you want a matrix “number of pixels” x “number of pixels” shows that you don't really understand what you're asking for because that makes no sense whatsoever. If your matrix is 100 by 100 = 10000 pixels, you're not going to want a matrix that's 10000 by 10000 pixels = 100 million elements. A hundred million elements for a 100 by 100 tiny image just makes no sense.

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

카테고리

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

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by