Please Please help with centering and overlaying an image

15 ビュー (過去 30 日間)
MLnoob5340
MLnoob5340 2014 年 10 月 21 日
コメント済み: Image Analyst 2014 年 10 月 21 日
I know this should be simple but I really cannot figure it out. How do I take two images and then have them display overlap each other at the central point (I have included a figure below)? These pictures are of different sizes. And I would like to do this without "hard-coding"
I have A = imread('A.png'); A = imread('B.png'); imshow (A) hold on; imshow (B)
But after this I have no idea how to center these :(

採用された回答

Image Analyst
Image Analyst 2014 年 10 月 21 日
Probably the easiest way is to copy and past the box at the proper location. You can easily find out the coordinates using the size function
[rows1, columns1, numberOfColorChannels1] = size(image1);
[rows2, columns2, numberOfColorChannels2] = size(image2);
col3 = int32(columns2/2 - columns1/2);
col4 = col3 + columns1 - 1;
row3 = int32(rows2/2 - rows1/2);
row4 = row3 + rows1 - 1;
Then paste in to each color channel. See my attached demo.
  5 件のコメント
MLnoob5340
MLnoob5340 2014 年 10 月 21 日
Thank you very much! I am just confused on the definition of hard-coding--I'll look into it
Image Analyst
Image Analyst 2014 年 10 月 21 日
Well go ahead and mark it "Accepted" then. Thanks. Hard coding woul dbe where you specify the actual numerical coordinates, like
image2(200:300, 500:550) = image1;
It would always put it at those column and row locations and not adapt to the size of image1.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDisplay Image についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by