MATLAB MATLAB Matrix Overlay?

  • Thread starter tangodirt
  • Start date
I'm currently having an issue with MATLAB vectorized code (I'm not sure how to best write this).

What I'm trying to do is take an image (stored as a uint8 array) and insert it into a sparse matrix of predefined dimensions at a specific location. Basically, I'm trying to insert an image into another big sparse matrix (replacing all values) at a specific location.

Here's a more detailed description:

Code:
imageOffset = [3 4;]; % Offset in X and in Y
imageCombine = [1 2 3 4 5; 1 2 3 4 5; 1 2 3 4 5;]; % This is the image to be inserted.

imageAssembled{1} = sparse(20, 10); % Empty sparse matrix, many of them stored in one 'imageAssembled' cell.
In theory, the code would take the imageCombine and place it within the imageAssembled cell (sparse matrix) to yield this:

Code:
imageAssembled{1} = 

[  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ]
[  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ]
[  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ]
[  -  ,  -  ,  1  ,  2  ,  3  ,  4  ,  5  ,  -  ,  -  ,  -  ]
[  -  ,  -  ,  1  ,  2  ,  3  ,  4  ,  5  ,  -  ,  -  ,  -  ]
[  -  ,  -  ,  1  ,  2  ,  3  ,  4  ,  5  ,  -  ,  -  ,  -  ]
[  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ]
[  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ]
[  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ]
[  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ]
[  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ]
[  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ]
[  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ]
[  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ]
[  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ]
[  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ]
[  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ]
[  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ]
[  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ]
[  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ,  -  ]
Any ideas how to do this with the code I've presented?
 

Want to reply to this thread?

"MATLAB Matrix Overlay?" You must log in or register to reply here.

Physics Forums Values

We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling
We Value Civility
• Positive and compassionate attitudes
• Patience while debating
We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving
Top