How to store a pixel location in an array?

조회 수: 2 (최근 30일)
pooja
pooja 2013년 9월 18일
Suppose i'm scanning my image for pixels that match a criteria,
instead of storing the PIXEL itself, i want to put the X-coordinate and the Y-coordinate of the pixel into an array
if i were doing it in C, it would look something like int a[i][j]=(i,j);
Basically, i just need a way to store the X-and Y-coordinates in a single array so i can access them that way. is this possible? please suggest what i could do otherwise.

답변 (2개)

Azzi Abdelmalek
Azzi Abdelmalek 2013년 9월 18일
편집: Azzi Abdelmalek 2013년 9월 18일
a=[1 2 3;4 5 6;7 8 9] % your array
[ii,jj]=find(a>4) % In this example the criteria is a>4, ii and jj are the coordinate
coordinate=[ii jj]

Image Analyst
Image Analyst 2013년 9월 18일
편집: Image Analyst 2013년 9월 18일
binaryImage = yourImage == criteria;
That will give you a logical "map" of what pixels meet your criteria. That is most likely all you will need. You most probably won't need the actual row and column number, even though you think you do. For example, turn all pixels brighter than 110 to white (255)
binaryImage = yourImage > 110; % Find the pixels.
yourImage(binaryImage) = 255; % Set them to 255
  댓글 수: 1
pooja
pooja 2013년 9월 18일
Sir, i need to know the pixel locations so i can keep some belonging to one intensity level and force the rest to go another intensity level.
to perform histogram equalization using bucket filling method.

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

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by