- #1
tangodirt
- 54
- 1
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:
In theory, the code would take the imageCombine and place it within the imageAssembled cell (sparse matrix) to yield this:
Any ideas how to do this with the code I've presented?
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?