필터 지우기
필터 지우기

returning the indexes of an image displayed with a specific colormap

조회 수: 1 (최근 30일)
hi, does anyone know hot to get the numeric indexes of a displayed image with a specific user defined colormap???
for example imagesc(IMAGE) colormap(user_colormap)
displays an image mapped into the colormap....and I want the numeric representation of the displayed image.
  댓글 수: 5
Sean de Wolski
Sean de Wolski 2012년 8월 14일
That's what IMAGE is.... It's just a 2d matrix of indices into the colormap.
Mario Trevino
Mario Trevino 2012년 8월 14일
@ Matt: m-by-n only. @ Sean: I know! yet the colormap is transforming the matrix, and I want THAT transformation (or mapping), and not the original one. I want to recover the transformed 2d matrix after using imagesc with a specific user defined colormap.

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

채택된 답변

Matt Fig
Matt Fig 2012년 8월 14일
편집: Matt Fig 2012년 8월 14일
If I understand you correctly, you want (for example):
A = rand(4);
C = [0 0 0;.5 .5 .5;1 1 1];
imagesc(A);
colormap(C);
% idx = interp1([0 .5 1],[0 .5 1],A,'nearest')
idx = ceil(A*size(C,1))
  댓글 수: 7
Matt Fig
Matt Fig 2012년 8월 14일
I don't know what you mean by holding with zeros. But the reshape function does pretty much what the name indicates. Take a look:
X = [1 0 2 0 3 0 4 0 5 0 6 0]
reshape(X,4,3)
reshape(X,3,4)
reshape(X,6,2)
reshape(X,2,6)
reshape(X,12,1)
Mario Trevino
Mario Trevino 2012년 8월 14일
you are absolutely right Matt. What I saw is that none of the elements from A (or idx) can be 0 for the reshape function to work.

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by