image and its intensity profile on one plot

11 ビュー (過去 30 日間)
Gefen Livne
Gefen Livne 2021 年 5 月 31 日
コメント済み: Gefen Livne 2021 年 7 月 25 日
Hi
I created the intensity profile, but would like to plot it on the original image, at the place were I measured it, with the proper scale.
I need it to be in one figure and not in subplots like I used in the code.
the code and the image are attached below.
appreciate your help.
thanks, Gefen
I=imread('Composite (RGB).tif');
% imshow(I)
%improfile(I)
x = [0 size(I,2)];
y = [size(I,1)/2 size(I,1)/2];
c = improfile(I,x,y);
figure
subplot(2,1,1)
imshow(I)
hold on
plot(x,y,'r')
subplot(2,1,2)
plot(c(:,1,1),'r')
hold on
plot(c(:,1,2),'g')
plot(c(:,1,3),'b')

採用された回答

Hrishikesh Borate
Hrishikesh Borate 2021 年 7 月 23 日
Hi,
The following code demonstrates a few possible approaches to display the intensity profile and it’s image in one plot.
I=imread('peppers.png');
% imshow(I)
%improfile(I)
x = [0 size(I,2)];
y = [size(I,1)/2 size(I,1)/2];
c = improfile(I,x,y);
a = normalize(squeeze(c),'range');
figure;
subplot(1,3,1)
imagesc(flipud(I))
set(gca,'YDir','normal')
axis on;
hold on;
plot(x,y,'r')
plot(c(:,1,1),'r')
plot(c(:,1,2),'g')
plot(c(:,1,3),'b')
title('Original')
hold off;
subplot(1,3,2)
imagesc(flipud(I))
set(gca,'YDir','normal')
axis on;
hold on;
plot(x,y,'r')
plot(c(:,1,1)+y(1),'r')
plot(c(:,1,2)+y(1),'g')
plot(c(:,1,3)+y(1),'b')
title('Shifted, Not Scaled')
ylim([0 max(c(:))+y(1)])
hold off;
subplot(1,3,3)
imagesc(flipud(I))
set(gca,'YDir','normal')
axis on;
hold on;
plot(x,y,'r')
plot((a(:,1)+1)*y(1),'r')
plot((a(:,2)+1)*y(1),'g')
plot((a(:,3)+1)*y(1),'b')
title('Shifted and Scaled')
hold off;
  1 件のコメント
Gefen Livne
Gefen Livne 2021 年 7 月 25 日
Thank you very much for your help!

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by