Overlay a image with plot

13 ビュー (過去 30 日間)
Georg Edelmann
Georg Edelmann 2020 年 2 月 18 日
コメント済み: Kurt 2023 年 12 月 5 日
Hey Guys,
i want to overlay a image with a the plot i made,
The first Subplot is just the Plot an the second shall be the combination.
Here is my Code:
I = imread('Bild_1.jpg');
I=I(:,:,1);
white = sum(I,2);
[Rows,numCols] = size(I);
x0=0;
y0=0;
width=numCols;
height=Rows;
set(gcf,'position',[x0,y0,width,height])
subplot(1,2,1)
plot(white);
view([90 90]);
saveas(gcf,'Plot_01.png',[x0,y0,width,height]);
P1=imread('Plot_01.png');
P2= imrotate(P1,90,'bicubic','crop');
subplot(1,2,2)
imshowpair(P2,I,'blend','Scaling','joint')
My Problem is that the Plot and the image are in a 90° Angle to each other. Moreover the saved Plot doest not have the same (Pixel)Size.
Hope you can help me

採用された回答

Srivardhan Gadila
Srivardhan Gadila 2020 年 2 月 25 日
Below are some suggestions: (only for the above code)
  1. (line 14 - 17) Instead of using subplots use figure and save the plot
  2. (line 20, 21) Rotate the image first and then resize it
Below is the code after making changes:
I = imread('Bild_1.jpg');
I=I(:,:,1);
white = sum(I,2);
[Rows,numCols] = size(I);
x0=0;
y0=0;
width=numCols;
height=Rows;
figure
set(gcf,'position',[x0,y0,width,height])
plot(white);
view([90 90]);
saveas(gcf,'Plot_01.png',[x0,y0,width,height]);
P1=imread('Plot_01.png');
P1 = imrotate(P1,90);
P2 = imresize(P1,[Rows,numCols],'bicubic');
figure
imshowpair(P2,I,'blend','Scaling','joint')
  2 件のコメント
Georg Edelmann
Georg Edelmann 2020 年 2 月 26 日
thank you a lot
Kurt
Kurt 2023 年 12 月 5 日
imshowpair and imrotate require the Image Processing Toolbox.

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

その他の回答 (0 件)

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by