Display images side by side

How I can in Matlab using figure and imshow commands to display images side by side ?
ty-exexch-koAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

aaverCommented:
Have you tried using subplot?
KendorCommented:
I would do something like:

figure,
subplot(121), imshow(img1,[]);
subplot(122), imshow(img2,[]);
ty-exexch-koAuthor Commented:
Hi Kendor

small question
the number 121 inside subplot function refer for what ?

I try using numbers 1, 2 , 3 and etc. I get an error message
Your Guide to Achieving IT Business Success

The IT Service Excellence Tool Kit has best practices to keep your clients happy and business booming. Inside, you’ll find everything you need to increase client satisfaction and retention, become more competitive, and increase your overall success.

ty-exexch-koAuthor Commented:
If I want to use subplot with 3 or 4 images to display side by side ?

I get an error message

I think available diferent way to use with figure and imshow
KendorCommented:
ok subplot functions as follows:

the first number tells you how many rows you have, the second number says how many columns and the third defines the overall position.

say you have 2 rows and 3 columns you would write:
subplot(2,3,x) and x would be the position like:
1 2 3
4 5 6

otherwise refer to: http://www.mathworks.com/help/techdoc/ref/subplot.html
KendorCommented:
for your problem with 3 or foure images this would mean:
subplot(13x) or subplot(14x) (note: you can put commas in between the number or not... its the same. commas are nice if you want to use subplot in a loop... for example for your problem:

for i=1:4
 subplot(1,4,i); imshow(image(i),[]);
end

or what you asked for:
subplot(141), imshow(img1,[]);
subplot(142), imshow(img2,[]);
subplot(143), imshow(img3,[]);
subplot(144), imshow(img4,[]);

(note, i'm using the [] in imshow which tells matlab to scale the brigthness range to the available scale (i.e. 256 grayvalues))


otherwise you can also use
handle = figure();
and then use the handle to draw your images. however, things then get slightly more complicated.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming Languages-Other

From novice to tech pro — start learning today.