How to join an image to multiple images with a loop?

1 visualización (últimos 30 días)
sara Cachique
sara Cachique el 8 de Ag. de 2019
Editada: Image Analyst el 9 de Ag. de 2019
Hello everyone, I hope someone can help me,
My program is to build a puzzle, regardless of the order in which the piece is read, I am trying to do a test, with the images of each segmented piece, for example I have two images, one is from piece 1 and piece 2 out of a total of 12 pieces, that is 12 positions, I want them to be detected (I am trying to do so with an if but I don't know what arguments to add to read an image) are added to my background (A matrix of zeros ), this is my code.
P1 = imread ([path, '/ Piece1.jpg']);
P2 = imread ([path, '/ Piece2.jpg']);
[r, c, n] = size (P1);
matchs = zeros (r, c, n, 'uint8');
for i = 1: r
     for j = 1: c
        matchs (i, j,:) = P1 (i, j,:) + P2 (i, j, :);
     end
end
figure, imshow (matchs)
 
This works to add images
but I want the program through some cycle to say if it is piece 1, if piece 2 is added, regardless of the order, and the puzzle is built.

Respuesta aceptada

Image Analyst
Image Analyst el 8 de Ag. de 2019
If the number of columns are the same:
tallImage = [topImage; bottomImage];
If the number of rows are the same
wideImage = [leftImage, rightImage];
I'd start by constructing the horizontal bands first, then by stitching those bands together vertically to form the complete image. I imaging you can figure out how to put those lines in a loop where you read in the two images and stitch them together.
  2 comentarios
sara Cachique
sara Cachique el 8 de Ag. de 2019
The number of columns is not the same, I guess because my piece is as follows (see attached image Piece1)
Piece1.JPG
but the images are segmented in position, that is, if the overlays are not going to be on top of another, what I want is that, as soon as one is entered, it is added to the black board (see final attached image)
Join Image.JPG
I don't know if Is there any way to do this with an if loop, for example.
if P1 == 1, is it active or is being read
matchs (i, j,:) = P1 (i, j, :);
end
If P2 == 1
matchs (i, j,:) = matchs (i, j,:) + P2 (i, j, :);
end
or how to do this?
Image Analyst
Image Analyst el 9 de Ag. de 2019
Editada: Image Analyst el 9 de Ag. de 2019
You have to locate the position first. Only then can you drop it in, or mask it in, to the proper location. Do you have an algorithm for that? Do you have coordinates of all the (x,y) locations of the perimeter of the piece? If you had those you could find out which pieces matched close to 1/4 of their points.
If you don't have your own algorithm, you could copy someone else's from here in VisionBibliography: https://www.google.com/search?hl=En&as_sitesearch=www.visionbib.com%2F&bthG=Google%2BSearch&q=jigsaw

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Image Processing and Computer Vision en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by