Put two different JPEG files into your Current Folder. Read both into matrix variables. To superimpose the images, if the matrices are the same size, the elements can simply be added element-by-element. However, if they are not the same size,
belongs to book: MATLAB: A Practical Introduction to Programming and Problem Solving|Stormy Attaway|Fourth Edition| Chapter number:13| Question number:25.13
All Answers
total answers (1)
Ch13Ex25.m
% Superimpose two images
% Crop one if necessary so they're the same size
im1 = imread('photo1.jpg');
im2 = imread('photo2.jpg');
[r1, c1, d1] = size(im1);
[r2, c2, d2] = size(im2);
%Check number of rows
if r1 > r2
im1 = im1(1:r2,:,:);
elseif r1 < r2
im2 = im2(1:r1,:,:);
end
%Check number of columns
if c1 > c2
im1 = im1(:,1:c2,:);
elseif c1 < c2
im2 = im2(:,1:c1,:);
end
[r1 c1 d1] = size(im1);
[r2 c2 d2] = size(im2);
%Superimpose
im3 = im1 + im2;
image(im3)
In a random walk, every time a “step” is taken, a direction is randomly
chosen. Watching a random walk as it evolves, by viewing it as an
image, can be very entertaining. However, there are actually very
practical applications of random walks; they can be used to simulate
diverse events such as the spread of a forest fire or the growth of a
dendritic crystal.
need an explanation for this answer? contact us directly to get an explanation for this answer