필터 지우기
필터 지우기

How to store the co-ordinates of a pixel in an array?

조회 수: 2 (최근 30일)
Rachel
Rachel 2014년 1월 21일
답변: AJ von Alt 2014년 1월 21일
Dear All,
I have a certain number of pixels selected based on a condition (if the pixel value is zero), and I want to take the first 10 of these pixels and get their co-ordinates and store it into an array.
Can anyone help? Thanks in advance!

답변 (1개)

AJ von Alt
AJ von Alt 2014년 1월 21일
Assuming that by the first 10 pixels, you mean the first 10 in column major order, find will do this for you.
% Generate a random logical matrix
binMat = binornd(1,0.5,[20 20]);
numToFind = 10; % number of indices to find
% find the subscript indcies for the first numToFind values set to 1 in
% column major order
[r , c] = find( binMat , numToFind );

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by