image and its intensity profile on one plot
6 次查看(过去 30 天)
显示 更早的评论
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')
0 个评论
采纳的回答
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;
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Subplots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!