image and its intensity profile on one plot
10 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Gefen Livne
am 31 Mai 2021
Kommentiert: Gefen Livne
am 25 Jul. 2021
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/637650/image.png)
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 Kommentare
Akzeptierte Antwort
Hrishikesh Borate
am 23 Jul. 2021
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;
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Subplots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!