How to superimpose an matrix image into the center of a zero matrix (MATLAB CODE)?
Show older comments
The given image is 211 x 350 and there is a zeros matrix of size 512 x 512. The goal is to superimpose the image in the middle of the zero matrix. Then plot the squared image.
I don't know how to do this part, looking for some help.
Thank you.
Accepted Answer
More Answers (1)
Image Analyst
on 23 Nov 2018
Just figure out the starting and ending rows and columns through simple algebra, and do
z(row1:row2, col1:col2) = givenMatrix;
For a start,
row1 = round(256 - 211/2)
I imagine you can figure out the rest, i.e. row2=row1+211-1, etc.
2 Comments
Juan Rodriguez
on 23 Nov 2018
Edited: Juan Rodriguez
on 23 Nov 2018
Hi, I'm having a similar issue, however, I don't follow what you're saying exactly. Can you provide more code and reasoning rather than "etc."?
Image Analyst
on 23 Nov 2018
If Andrei's code is too cryptic for you to follow, then let me know. Otherwise it's basically the same thing I said.
Categories
Find more on Resizing and Reshaping Matrices 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!