Please Can Somebody tell me how to add additional coins in the eight.tif image that is being copied from the database?

6 views (last 30 days)
Hey Guys, How you doing? Please after you generate A=imread('eight.tif'); from Matlab database, what should you do to add additional coins in this image? Please give me a complete code that works to add this additional coins in that image.
Thank you in advance,
Jean
  3 Comments
Walter Roberta
Walter Roberta on 18 Nov 2012
Hello Mr. Simon, so far I have been trying so hard and used different avenues and could not get anything at all. Here is an example that I tried and gave errors: H=imread('eight.tif'); G=imread('coins.png'); F=imlincomb(0.5, H, 0.5, G); imshow(F) Error using imlincombc Function imlincomb expected its array input arguments (A1, A2, ...) to be the same size.
Error in imlincomb (line 84) Z = imlincombc(images, scalars, outputClass);
Image Analyst
Image Analyst on 18 Nov 2012
imlincomb() is just a weighted sum of two images, so the images have to be the same size. It will not paste a smaller image into a larger image.

Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 18 Nov 2012
I swear I already answered this today but it's no longer there or in your duplicate posting in the newsgroup http://www.mathworks.com/matlabcentral/newsreader/view_thread/324565#891884. I remember referring someone to my BlobsDemo Image Segmentation Tutorial and I said that to crop out coins and you could paste them back in. Since this might be a homework problem (since I've heard it more than once) I'll just give you a similar demo:
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
imtool close all; % Close all imtool figures.
clear; % Erase all existing variables.
workspace; % Make sure the workspace panel is showing.
format longg;
format compact;
fontSize = 20;
image1 = imread('moon.tif');
[rows1 columns1 numberOfColorChannels1] = size(image1)
subplot(2, 2, 1);
imshow(image1);
axis on;
title('Large Grayscale Image', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
image2 = imread('cameraman.tif');
[rows2 columns2 numberOfColorChannels2] = size(image2)
subplot(2, 2, 2);
imshow(image2);
title('Small Grayscale Image', 'FontSize', fontSize);
axis on;
row1 = 30;
col1 = 51;
row2 = row1 + rows2 - 1;
col2 = col1 + columns2 - 1;
image1(row1:row2, col1:col2) = image2;
subplot(2, 2, 3);
imshow(image1);
axis on;
caption = sprintf('Small Image Pasted\ninto Large Image', 'FontSize', fontSize);
title(caption, 'FontSize', fontSize);

More Answers (0)

Community Treasure Hunt

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

Start Hunting!