what should you do to add additional coins in this image?

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,

Respuestas (2)

What are the constraints on the problem? Do you want to detect coins, copy them, and insert them into the image or do you just want to display an image with more coins?
If that is the case, then
B = repmat( A , 20 , 20 );
imshow(B);
should do nicely.

1 comentario

Dear,
I want to insert additional coins to the image to be 5 coins in one image.
Thanks

Iniciar sesión para comentar.

Image Analyst
Image Analyst el 28 de En. de 2014
Manal, see my image segmentation tutorial: http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862. It find the coins. Then see my attached demo for how to copy and paste a chunk of an image. If you're willing to work a little and combine those, you can get it done. I know you can do it.

9 comentarios

I tried many time to do it with this demo but there is errors comes out.
I want to add 1 extra coin to the image A=imread('eight.tif'); to be 5 coins in the image.
What error do you encounter? Which MATLAB version are you using? Do you have the Image Processing Toolbox ?
I didn't get any errors. Are you sure you followed the directions in the message boxes?
MATLAB student version.
Would you please give me a complete code that works to add this additional coins in that image??
What error do you encounter. Which version of MATLAB Student Version -- R2013a ? Have you installed the Image Processing Toolbox? It arrives with Student Version but is not installed by default.
Moon Shadow
Moon Shadow el 29 de En. de 2014
Editada: Moon Shadow el 29 de En. de 2014
yes,MATLAB Student Version-R2013a on MAC
I can crop the coin but I can't paste it again. It gave me this error: Undefined function or variable 'rows2'.
Did you mean: EDU>> r2 = r1 + rows - 1; EDU>>
Image Analyst
Image Analyst el 29 de En. de 2014
Editada: Image Analyst el 29 de En. de 2014
How could you have gotten to that line, when the line 11 lines prior is
[rows2 columns2] = size(croppedImage)
and there is no way to get to the r2= line without going through the [rows2 line???? I think you must have modified my demo. Again, I copied and pasted and it ran fine. Attach your modified m-file so I can find out how you changed it to cause it not to work.
Are you sure you were always clicking in the upper left image, and you waited for the ginput crosshairs before clicking where to paste it?
Moon Shadow
Moon Shadow el 30 de En. de 2014
Editada: Walter Roberson el 30 de En. de 2014
This is my code:
grayImage = imread('eight.tif');
% Get the dimensions of the image.
% numberOfColorBands should be = 1.
[rows columns numberOfColorBands] = size(grayImage);
% Display the original gray scale image.
subplot(2, 2, 1);
imshow(grayImage);
axis on;title('Original Grayscale Image', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
% Give a name to the title bar.
set(gcf,'name','Demo by ImageAnalyst','numbertitle','off')
% Let's compute and display the histogram, just for fun.
[pixelCount grayLevels] = imhist(grayImage);
subplot(2, 2, 2);
bar(pixelCount);
grid on;
title('Histogram of original image', 'FontSize', fontSize);
xlim([0 grayLevels(end)]); % Scale x axis manually.
% Ask user to draw a box.
subplot(2, 2, 1);
promptMessage = sprintf('Drag out a box that you want to copy,\nor click Cancel to quit.');
titleBarCaption = 'Continue?';
button = questdlg(promptMessage, titleBarCaption, 'Continue', 'Cancel', 'Continue');
if strcmpi(button, 'Cancel')
return;
Undefined function or variable 'fontSize'.
EDU>> k = waitforbuttonpress;
point1 = get(gca,'CurrentPoint'); % button down detected
finalRect = rbbox; % return figure units
point2 = get(gca,'CurrentPoint'); % button up detected
point1 = point1(1,1:2); % extract x and y
point2 = point2(1,1:2);
p1 = min(point1,point2); % calculate locations
offset = abs(point1-point2); % and dimensions
% Find the coordinates of the box.
xCoords = [p1(1) p1(1)+offset(1) p1(1)+offset(1) p1(1) p1(1)];
yCoords = [p1(2) p1(2) p1(2)+offset(2) p1(2)+offset(2) p1(2)];
x1 = round(xCoords(1));
x2 = round(xCoords(2));
y1 = round(yCoords(5));
y2 = round(yCoords(3));
hold on
axis manual
plot(xCoords, yCoords, 'b-'); % redraw in dataspace units
% Display the cropped image.
croppedImage = grayImage(y1:y2,x1:x2);
subplot(2, 2, 3);
imshow(croppedImage);
axis on;
title('Region that you defined', 'FontSize', fontSize);
Undefined function or variable 'fontSize'.
EDU>> Paste it onto the original image
[rows2 columns2] = size(croppedImage)
promptMessage = sprintf('Click on the upper left point where you want to paste it,\nor click Cancel to quit.');
titleBarCaption = 'Continue?';
button = questdlg(promptMessage, titleBarCaption, 'Continue', 'Cancel', 'Continue');
if strcmpi(button, 'Cancel')
return;
Undefined function 'Paste' for input arguments of type
'char'.
EDU>> [x, y] = ginput(1)
% Determine the pasting boundaries.
r1 = int32(y);
c1 = int32(x);
r2 = r1 + rows2 - 1;
r2 = min([r2 rows]);
c2 = c1 + columns2 - 1;
c2 = min([c2, columns]);
plot([c1 c2 c2 c1 c1], [r1 r1 r2 r2 r1], 'r-');
% Paste as much of croppedImage as will fit into the original image.
grayImage(r1:r2, c1:c2) = croppedImage(1:(r2-r1+1), 1:(c2-c1+1));
subplot(2, 2, 4);
imshow(grayImage);
axis on;
title('Region that you defined pasted onto original', 'FontSize', fontSize);
x =
82.4542
y =
88.2481
Undefined function or variable 'rows2'.
Did you mean:
EDU>> r2 = r1 + rows - 1;
EDU>> [x, y] = ginput(1)
You deleted the line
fontSize = 20;
that occurs early on in Image Analyst's code.
You deleted the '%' that occurs at the beginning of a comment line
% Paste it onto the original image
Because that % was missed, MATLAB skipped execution of everything between that line and the next command prompt.

Iniciar sesión para comentar.

Categorías

Más información sobre Images en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 28 de En. de 2014

Comentada:

el 30 de En. de 2014

Community Treasure Hunt

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

Start Hunting!

Translated by