필터 지우기
필터 지우기

How to get indexed pixels from set of images?

조회 수: 1 (최근 30일)
John
John 2017년 5월 4일
편집: John 2017년 5월 5일
A set of images a(x,y,n); n images, each image has a size of (x * y); A known index map: imind(x,y), size of the image with each element value from 1 to n;
How to obtain the image that each pixel is from different image? For example: imind(1,1)=2, then take final_im(1,1)=a(1,1,2); imind(21,33)=6, then take final_im(21,33)=a(21,33,6); etc.
It can be done with a loop:
for nx=1:x
for ny=1:y
final_im(nx,ny)=a(nx,ny,imind(nx,ny));
end
end
But, is there an elegant way?
Thanks.

답변 (2개)

KSSV
KSSV 2017년 5월 5일
You can reduce one loop shown below:
for nx=1:x
final_im(nx,1:ny)=a(nx,1:ny,imind(nx,1:ny));
end
  댓글 수: 1
Image Analyst
Image Analyst 2017년 5월 5일
I wouldn't encourage John's bad habits of calling vertical row "x" and the horizontal column "y" - this is the opposite the way the rest of the world does it. Images take indexes y,x not x,y.

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


John
John 2017년 5월 5일
편집: John 2017년 5월 5일
Will this single loop way work? And a loop-less way would be more "elegant".

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by