I am trying to rearrange sections of a picture in matlab - 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)

Related

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

Calculating unique transformation for multiple images in folder

I'm currently working on an alignment script which aligns two images very well. Usually, I get a data set which contains over 50 images of cells. I normally calculate a transformation matrix (T) based on fluorescent beads. However, this T-matrix gave rise to polarization in unpolarized cells, indicating that the transformation is not optimal. Therefore I switched to another script, which calculates a T-matrix based on cells and not beads. This new T-matrix aligns almost perfectly for a fraction of the cells, but there is always a portion of the images which aligns not so good.
I would like to continue with the alignment on cells, because this script works much better than the alignment on beads. In order to have optimal T-matrix for each image, I would like to calculate unique T-matrices for each image couple. I'm not very skilled in Matlab so the solution I could think of did not work.
Below you can find the current script. It functions by creating variables of the images I want to align and assign them to im1 and im2 in the script:
function [T] = alim(im1, im2, Tstart)
%ALIM Determines the transformation between the cameras.
im3=im2;
if (nargin>2)
im2=imwarp(im2, Tstart,'OutputView',imref2d(size(im1)));
end
optimizer = registration.optimizer.RegularStepGradientDescent;
optimizer.MaximumIterations=500;
metric = registration.metric.MattesMutualInformation;
T = imregtform(im2, im1, 'affine', optimizer, metric);
if (nargin>2)
T.T=Tstart.T*T.T;
end
figure;
imshowpair(im1,imwarp(im3,T,'OutputView',imref2d(size(im1))));
end
I tried to incorporate a loop which imports all images from the folder sequentially and assign these to im1 and im2. However, the problems that arises is that the type of data changes from uint16 into cell, which can't be used for this type of transformation. One defines in the script the location of the folders 'CAM1' and 'CAM2' and the number of images in these folders ('imnum')
for i:imnum
x{i}=imread(strcat(link,'CAM1\',num2str(i),'.tif'));
y{i}=imread(strcat(link,'CAM2\',num2str(i),'.tif'));
I would like to have your view on this problem and hopefully you can make some suggestions on how I can import the images in a folder in one go and keep the data type uint16. I'm always open for suggestions so if you have other ideas on how to solve my problem, I would love it if you shared them with me. If anything is unclear, please contact me with questions!
With kind regards,
Reinier
x is a cell array, where each element x{i} is a uint16 array. Cell arrays can hold any other datatype, including more cell arrays, and are a great way to wrap collections of objects, especially when their sizes and/or types may differ.
In your case, just call your function like this:
T = alim(x{i}, y{i}, tstart);
Or, even better, put the output matrix into a similar cell:
T{i} = alim(x{i}, y{i}, tstart);

include 4 images as different panels in 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 :).

produce several maps in same figure window in matlab

I would like to generate a figure in matlab which looks like the attached .jpeg:
So, the figure should contain an outline of the world and then 3 other figures looking at the USA, UK, and New Zealand where I can then specify individual locations in each country. How would I achieve this?
Subplots to arrange things, images to create the maps, and lines to connect them to points. To create a complicated subplot structure like that I'd suggest you check out Ben Mitch's panel class. The relevant thing you're looking for is its ability to conveniently divide up and manage subplots. Something like this
p = panel('defer');
p.pack('v', [1/5 3/5 1/5]);
p(1).pack('h',[1/5 2/5 2/5]); % top level, US and New Zealand
p(2).pack('h',[1/5 2/5 2/5]); % mid level
p(3).pack('h',[1/5 3/5 1/5]); % bottom level
p(2,2).select();
image(world_image);
p(1,3).select();
image(new_zealand_image);
p(1,3).select();
image(usa_image);
p(1,1).select();
image(uk_iamge);
Then add a few line commands to show where the submaps link to. Note that I haven't gotten a chance to test the above code yet, but will when I get to work. I can't remember offhand if it likes the 'h' argument within the child panels.

how to make "Farm Flip - Memory Match for Kids" like memory based game

i'm about to developp a memory game for children like,i have 6 different images show in in random order in 12 places. note(each image show twice) and i want to know how to set images randomly and how to mach UIImage with animation? any help..
Have a look at the answer by Kristopher at What's the Best Way to Shuffle an NSMutableArray?. You can create an array of 12 images (each repeated twice) & then shuffle the array. Then display the images in the order obtained after shuffling.
Regarding animations, you first need to at least visualize what animation you want. People can then help you achieve that.
HTH,
Akshay