How to use subplot, to plot an image?

Hey, everyone I am new with MatLab, I tried googling this but no success. I wanted to know, how can I use the subplot function, to plot a line graph of an image X, the value of image X is the difference of image A-B. One being an original image the other the same image with a filter applied. I want to show the difference between them through the new image.

댓글 수: 4

Surely
doc subplot
to bring up the Matlab help rather than a google search is sufficient to understand subplot? What aspect of it are you struggling with?
I had a look at it, but I am having difficulties getting it to work. Here is an example. Let's say I want to plot an image that is called A, I can easily get it to show the image histogram. But when i try to subplot that image, using the steps in the documentation, I don't get an error, but the plot does not come up. Image A in this case is a 320 x 426 matrix in uint8
Example of code:
x = linspace(0,5);
y = A;
figure
subplot(2,1,1);
plot(x,y)
Your problem is with your usage of plot rather than subplot.
You are trying to plot a vector vs an image. I'm not quite sure I understand what you are aiming to do.
To get the image you can use e.g.
imagesc( A );
but what do you want your line to represent? Or are you trying to plot 426 lines, each of length 320 to represent your image data? Or something else?
Conor McGregor
Conor McGregor 2016년 10월 12일
What I am trying to achieve is to subtract the original and smoothed images to illustrate the difference between them and then use subplot to show the original smooth and the difference image in the same figure.

댓글을 달려면 로그인하십시오.

답변 (1개)

Adam
Adam 2016년 10월 12일

0 개 추천

A = rand(200);
B = rand(200);
D = A - B;
figure;
subplot( 2, 1, 1 )
imagesc( A );
subplot( 2, 1, 2 )
imagesc( D );
would, for example show an original image and the difference image from some other matrix. Obviously with uint8 data you have to be more careful with the difference, but that wasn't what you were asking about anyway I assume.
That is an example of how subplot can work simply though.

카테고리

도움말 센터File Exchange에서 Images에 대해 자세히 알아보기

태그

질문:

2016년 10월 12일

답변:

2016년 10월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by