mapping a matrix to array to new matrix (mapping image to tone image )

1 次查看(过去 30 天)
i have a matrix A n*m for example A,3*3 = A[0,3,10;255,6,8;7,9,9] the values between 0 to 255 and i have array B 1*256 that includes all the numbers from 0 to 255 not sorted , (ex. [5,0,4,255,...]) i need to map the matrix A to B - for every value i in A i want to map it to B(i+1) i am required to do it in one line code !!!
in this example the first element in A 0 will convert to 5 index 1 in B and second element 3 will be 255 index 4 in B in the new matrix .

采纳的回答

Image Analyst
Image Analyst 2018-11-5
How about intlut()?
A = uint8([0,3,10;255,6,8;7,9,9])
B = uint8(randperm(256)-1)
output = intlut(A, B) % A and B must be integers

更多回答(1 个)

Akira Agata
Akira Agata 2018-11-5
Like the following ?
reshape(B(A(:)+1),size(A))

类别

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