How to resize a matrix repeating the original values N times...
20 views (last 30 days)
Show older comments
Hi all. Im trying to do some sort of UpSample on a matrix, what I need to do is repeat each value of my original matrix N times. Example with N=3
A =
1 2
3 4
A_up =
1 1 1 2 2 2
1 1 1 2 2 2
1 1 1 2 2 2
3 3 3 4 4 4
3 3 3 4 4 4
3 3 3 4 4 4
This is going to be used on images of 2Mpx and right now im using matrix concatenation to do it, but it takes more then 10min for each image, and I have to be able to do this in more then 800 images... If someone have a hint of how to do it faster I would be very gratefull.
2 Comments
Accepted Answer
More Answers (1)
Azzi Abdelmalek
on 4 Jun 2013
Edited: Azzi Abdelmalek
on 4 Jun 2013
N=3
out=cell2mat(arrayfun(@(x) ones(N)*x,A,'un',false))
Or
A=[1 2 3;4 5 6;7 8 9]
n=3
m=size(A,1)*n
out=reshape(repmat(reshape(repmat(A(:)',n,1),m,[]),n,1),m,[])
0 Comments
See Also
Categories
Find more on Data Type Identification in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!