LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Stacking images in array.

Solved!
Go to solution

I have developed a VI to arrange images row wise. I have M rows ans N columns. I have developed VI such that final resultant images in each row as single image with M  rows.So final image is M by 1 array. i.e, M rows and 1 column. I am selecting files from 1 folder. I have programmed in such a way that VI will automatically take images from folder. But one problem I am facing is images in each rows are same. For example, number of rows is 3 and columns 4 , program should take first 4 images stacked as single image to be row1, next 4 images stacked as single image to be row2,etc.But in this VI , images in all rows are the same first column number of images.

How to rectify this issue?

I have attached VI.

0 Kudos
Message 1 of 20
(3,922 Views)

Images are a reference to a memory location.

 

In your first For Loop, you are creating image locations based on the iteration number.  But when the outer loop runs again, you are creating the same names for the image locations in that same For Loop.  Thus you are overwriting the images you got the first time around.

 

Incorporate the outer Forloop iteration along with the inner For Loop iteration in the naming process.

0 Kudos
Message 2 of 20
(3,902 Views)

This is an interesting (and intriguing) problem.  Thank you for attaching some images, which makes clear (to me) what you are trying to do.

 

I've taken a crack at it, and have some comments for you to consider:

  • Looking at the 8 Images, they were of slightly different sizes, but the rows were all the same height (necessary for stitching together) and the columns were all the same width (also necessary).
  • There are IMAQ functions that should enable you to stitch the images together.
  • I found it useful that you named the files with the Row and Column number as part of the name.  This allowed me to parse all of the file names and create a cluster that had, for each file, the Filename, the Row and Column index of the "Image Part", the File Type, the Image Size (from an IMAQ function), and the Image Type.
  • I wrote a sub-VI that programmatically verified what I saw by looking at the Array of Clusters (from the previous step), which meant that if I created a Big Image the width of the Row of Images (summing the X resolutions, verified as identical for all the rows) and the height of the Column of Images (summing the Y resolutions, also verifiied as identical for all the columns), it became just a problem of sticking the "small" images into the "big" one.  That's when I ran out of time (dinner and other family duties intervened).

I haven't (yet) gone back to your code to see where you went astray, nor to see which IMAQ functions you are using.  If I can, I'll take another look tomorrow ...

 

Bob Schor

 

0 Kudos
Message 3 of 20
(3,880 Views)

Ok Thanks

0 Kudos
Message 4 of 20
(3,877 Views)

I have tried and atlast found a way to stack 2 rows of images and N number of columns.

But my aim is M rows and N columns.

 

I have attached VI.

0 Kudos
Message 5 of 20
(3,873 Views)
Solution
Accepted by topic author SSG0484
Message 6 of 20
(3,857 Views)

You need to hard code a number larger than 2 in your Reshape Array!

0 Kudos
Message 7 of 20
(3,846 Views)
Solution
Accepted by topic author SSG0484

My attempt is much more complex than the lovely demonstration posted by @alexderjuengere.  I tried to use IMAQ functions, and included some "sanity checks" (like making sure that all Images in a row had the same height, and all Images in a column had the same width, plus making sure that all of the Images in a rectangle were present).  The other thing I wanted to do (but have not had the time to work on it) was to use the IMAQ function ImagetoImage 2 to create a single 790 x 435 Image with no separation between the 8 sub-Images.  I think this should work ..

 

With this in mind, I went back for another look at the OP's code, which seems to be following what I was thinking about.  Here are some (minor) problems based on "assumptions" that may not always be true:

  • The order of the Images is governed by the order that they are listed by Recursive File List, which does not necessarily list them in "image order".
  • The Images are assumed to be of equal sizes, which (in the present example) is not true, introducing gaps or overlaps.  They are, however, "consistent" in size so they can be packed without spaces.
  • I think the Images named in Row Major order (all of Row 1 before any of Row 2), but your code processes the files in Column-Major order.  I didn't notice this when I wrote the previous "problem" -- once you interchange Rows and Columns, this earlier objection may disappear.
  • To get the X,Y offset for ImagetoImage, use a nested set of Shift Registers.

This Snippet shows what I think is the correct logic for stitching your Images together.  I've changed the order of processing to Row-Major, included some of the IMAQ functions for reference to your code, and redone somewhat the logic for creating the X-Y location of the individual Images into the single Composite Image.

Stitching LogicStitching Logic

Bob Schor

Message 8 of 20
(3,845 Views)

What if I have to do to convert array of images to single joined image?

 

I tried to use array to image function ,but its not working

0 Kudos
Message 9 of 20
(3,828 Views)

I have M rows and N columns of images. My aim is to convert it into final joined images. These images have no overlap. I want my final image as panorama based on M rows and N columns. Images are selected from folder.

I have attached program. But not getting result.

0 Kudos
Message 10 of 20
(3,842 Views)