include 4 images as different panels in matlab - matlab

I am trying to include 4 already present images into one new image, done and created in matlab, like a collage, with 4 images present adjacent to each other, bordering, in the new image. I really do not know where to start. Could you please help me here? In matlab?

Another options if you don't want white space between images is to combine the images into a single matrix.
ie:
image([I1 I2; I3 I4])
of course the images have to be the same size for this to work...

Actually, apart from What Hassan suggested, I was able to achieve my purpose easily using subplot and subimages.
Eg.
subplot(2,2,1)
imshow(I1)
subplot(2,2,2)
imshow(I2)
Thanks for your help :).

Related

Matlab border around figure

In attached image the output looks boring to me. Is it possible to have the subplots enclosed in a border?
Note: This question is not specific to publishing only but in general, say for exported images also.
Thanks
Postscript: I actually need this:
You can add a box like in here
making your code:
close all
figure()
padd=0.04
axes('Position',[padd padd 1-padd*2 1-padd*2],'xtick',[],'ytick',[],'box','on','handlevisibility','off')
subplot(1,2,1)
imagesc(magic(2))
subplot(1,2,2)
imagesc(magic(3))
This yields
And you can change the padd to be bigger or smaller
I obtained this just by plotting lines of different thickness 1.
The text was added with Inkscape though.
If I understand correctly what you want to do, you can obtain borders inside a figure using uipanels http://www.mathworks.com/help/matlab/ref/uipanel.html like this:
Code is:
u=uipanel('Title','MainPanel')
u1=uipanel('Parent',u,'BorderType','line','HighlightColor','k','Title','Subpanel 1','Position',[0,0,0.5,1])
u2=uipanel('Parent',u,'BorderType','line','HighlightColor','k','Title','Subpanel 2','Position',[0.5,0,0.5,1])
axes1=axes('Parent',u1)
imagesc(magic(2))
axes2=axes('Parent',u2)
imagesc(magic(3))
Of course you can change border widths, colors, titles and such

imshowpair function

Is it possible to use imshowpair function in MATLAB to display images next to each other instead of over one another?
So far I have:
figure;
imshowpair(imgA, imgB, 'diff');
I have about 100 images I would like to display. Is it possible?
Indeed it is possible.
imshowpair(im1, im2, 'montage')
It only displays 2 images, though. If you need to display many images of the same size use the montage function.
you also can use
newImg = cat(2,img1,img2);

Matlab figure visualization

In Matlab, I would like to visualize the test results in a figure with several charts and text. The figure is divided into rows and colums: 3 rows and 5 colums. For better understanding, here a screenshot of the figure with a orange grid which shows the subplot division:
Now I have several questions:
A) How can I include text into a specific section within the figure? i.e. test settings into subplot(6 and 11) and test results into subplot (7, 8, 9, 10).
B) Is it possible to "draw" separator lines between the subplots? i.e. to separate the test settings from the test result subplots for a better visualization.
C) Is it possible to set a title over several subplots such as "input data" and "output data"?
Thanks for your help!
Cheers,
Kevin
I have come this problem many times and haven't yet figured out a decent way to solve it. However what you can do is:
A) Include a Label (help label) in the subplot you want. Alternatively use a "edit locked" edit text field.
B) Yes in a way. Check out panels. Create a subplot, then inside a panel that fills the plot area. with the panel as parent create a figure (or label as in A) )
C) Thats a tricky one and I would use panels again, but I am not sure if that works.
These things are always a pain to do in Matlab itself. I usually ended up exporting my figures, writing a small HTML generator that places the images in divs and a decent CSS to make it look nice. It is way easier to do so if it is only for representing data. If you want it to be interactive you have to do it inside the UI.
Hope that helps
Benjamin

to draw ROIs and to calculate mean difference

I have two CT image . How can I draw multiple ROIs on both image and calculate mean difference between each the corresponding ROIs with matlab ? I've used the 'imrect' or 'imellipse' but this commands creates the Mask which makes the image as binary image then I would have problem with to calculate mean difference .
How to show the images with the ROIs draw on them?
Not very sure about what you want to do with imrect. This is an idea; the way I would do it. You have to get your hands dirty with actual programming instead of GUI, but it's VERY basic stuff, and easy as soon as you understand indexing, which is very nice in MatLab and the thing you should take with you from this answer:
First of you define the size of your ROIs, which can be easily made with a variable
width=20; %or whatever you wish
height=10;
then define the multiple ROIs using their upper left corner for the position
ROI11=Image1(corner1:corner1+width,corner1:corner1+height); %(width and height eventually the other way around, whatever)
ROI12=Image1(corner2:corner2+width,corner2:corner2+height);
%...
ROI21=Image2(corner1:corner1+width,corner1:corner1+height);
ROI22=Image2(corner2:corner2+width,corner2:corner2+height);
%...
and then calculate the mean however you please, like for example:
Mean1=sum(ROI11-ROI21)/length(ROI11(:));
Mean2=sum(ROI11-ROI21)/length(ROI11(:));
%...
or something along those lines.
Give it a try and play a bit with it.

I am trying to rearrange sections of a picture in matlab

here is the assignment:
Open humpty_mixed.gif (2D image) and do what all of the king’s horses and men could not do – put humpty back together again. The image is 600x412 and split evenly along the row and columns. (Note: We may use the imread(), imshow(), and imwrite() commands here.)
the picture is sectioned off in 4 rows and 4 columns, could someone help me get started, i'm stuck
b=imread('humpty_mixed.gif');
imshow('humpty_mixed.gif')
%that should get you started.oh by the way this is cheating you will recieve a zero!
a=b:
imshow(a)