add small image to large image in center without losing image quality
You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Show older comments
0 votes
i have a image containing some data. I want to add it into bigger image which contains zero. KINDLY HELP
Accepted Answer
Ameer Hamza
on 12 May 2018
You can use indexing to place a smaller image inside a large image. For example if imageBig is 200x200x3 and imageSmall is 50x50x3 then use
imageBig(70:70+size(imageSmall,1)-1, 80:80+size(imageSmall,2)-1, :) = imageSmall;
this will place imageSmall over imageBig starting from (70, 80) pixels from topl ledt corner.
8 Comments
varinder kaur
on 12 May 2018
Great help. Thanks Ameera Hamza. Can you please tell me how can i place my small image not touching any of the sides. as when i use code provided by you it touches the axis in top right corner
varinder kaur
on 12 May 2018
more clearing my comment. please provide information that i don't want to place my image on any axis.
Ameer Hamza
on 12 May 2018
Can you tell about the dimensions of your both images?
varinder kaur
on 12 May 2018
large image size 260*260 and small image size is 256*256
varinder kaur
on 12 May 2018
large image size 260*260*3 and small image size is 256*256*3
Ameer Hamza
on 12 May 2018
Edited: Ameer Hamza
on 12 May 2018
You need to change the location of the top left pixel. In my answer it was (70, 80). But since your Big Image already have similar resolution to small Image, the corner needs to be close
imageBig(3:3+size(imageSmall,1)-1, 3:3+size(imageSmall,2)-1, :) = imageSmall;
Remember, it will only leave space of 2 pixels at edges.
varinder kaur
on 12 May 2018
Thank you very much Ameer Hamza for quick reply. It works perfectly...
Ameer Hamza
on 12 May 2018
You are welcome.
More Answers (0)
Categories
Find more on Image Arithmetic in Help Center and File Exchange
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)