stitching images

stitching images

Post by da » Fri, 27 Jun 2003 12:00:41


hi

could someone point me in the right direction?
i would like to stitch a number of images (256x256 .bmp 8bit) together
(eg 4x4 or 4x6 image collage) so that i can save the new collage as
one .bmp image for further processing. is there an api function for
this? if not could someone point me in the right direction in
achieving this?

cheers in advance
dan

 
 
 

stitching images

Post by Larry Serflate » Fri, 27 Jun 2003 13:40:58



> could someone point me in the right direction?
> i would like to stitch a number of images (256x256 .bmp 8bit) together
> (eg 4x4 or 4x6 image collage) so that i can save the new collage as
> one .bmp image for further processing. is there an api function for
> this? if not could someone point me in the right direction in
> achieving this?

Have a search through the archive for 'tile picturebox'

LFS

What is the KB?: http://support.microsoft.com/default.aspx?scid=fh;en-us;kbinfo
RTFM?  http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbco...
Where's the archive?: http://groups.google.com/advanced_group_search?q=group:microsoft.publ...

 
 
 

stitching images

Post by Mike D Sutto » Fri, 27 Jun 2003 18:22:58


Quote:> could someone point me in the right direction?
> i would like to stitch a number of images (256x256 .bmp 8bit) together
> (eg 4x4 or 4x6 image collage) so that i can save the new collage as
> one .bmp image for further processing. is there an api function for
> this? if not could someone point me in the right direction in
> achieving this?

The easiest way of doing this is to load each image using LoadPicture(),
then use PaintPicture() to draw it to a canvas (A picture box will do here.)
Here's a quick function that will wrap some of that up for you:

'***
Private Function DrawPicture(ByRef Obj As Object, _
    ByVal inPath As String, ByVal inX As Long, _
    ByVal inY As Long) As StdPicture
    On Error Resume Next ' Try to load the image
    Set DrawPicture = LoadPicture(inPath)
    On Error GoTo 0

    ' Check that it loaded properly
    If (DrawPicture Is Nothing) Then Exit Function

    ' Draw it to the canvas
    Call Obj.PaintPicture(DrawPicture, inX, inY)
End Function
'***

If will load an image, and draw it at the specified coordinates, then return
it to you so you can get the width and height (To offset the next image, in
case they're not all the same size.)
Here's a little bit or air code to demonstrate how you'd use it:

'*** (Air code)
Dim TempImg As StdPicture
Dim CurX As Long, CurY As Long, MaxY As Long, ThisY As Long
Dim LoopImgs As Long
Dim FileNames() As String

---------------------------
Populate FileNames() here
---------------------------

For LoopImgs = 0 To UBound(FileNames()) ' Draw this image
    Set TempImg = DrawPicture(Picture1, FileNames(LoopImgs), CurX, CurY)

    If (Not (TempImg Is Nothing)) Then
        ' Offset horizontally
        CurX = CurX + ScaleX(TempImg.Width, vbHimetric, Picture1.ScaleMode)

        ' Check height
        ThisY =  ScaleX(TempImg.Width, vbHimetric, Picture1.ScaleMode)
        If (ThisY > MaxY) Then MaxY = ThisY

        If (CurX > Picture1.ScaleWidth) Then
            ' Offset vertically once the end of the picture box is reached
            ' You can easily change this to being a number of images though
            CurX = 0
            CurY = CurY + MaxY
            MaxY = 0
        End If
    End If
Next LoopImgs
'***

You can then use the SavePicture() method to save this image (Make sure the
.AutoRedraw property is set to true before you do this though.)  You may
also have to play about with the scale of the canvas you're drawing to
(Before you draw) since otherwise it will be clipped at the scale of the
control - The back buffer is created at the same scale as the control's
area.
While this method is reasonably quick and easy to implement is does however
have a few problems, most noticeably is that it's all device dependant so if
you're running on a low-colour display then it's going to generate a low
colour image.  Also you have little control over the images you load and
save and LoadPicture() will sometimes even *on bad images and take your
application with it.  I've written a wrapper for the function to address the
last issue, which you'll find here:
http://www.veryComputer.com/%40TK2MSFTNGP12
As for the device dependence issue, to circumvent that you'd need to do all
of this in memory using DIB's which depending on how much work you've done
with graphics programming before could be somewhat tricky..  If you want the
explanation of how to go about that then post back here and I'll get
something written up.
Hope this helps,

    Mike

 - Microsoft Visual Basic MVP -

WWW: http://www.veryComputer.com/

 
 
 

1. ** how to tone-match stitched images **

Further to the question about the string of Berlin Wall pix, I am trying
to make a long panorama from several adjacent pix with small overlap. There
are slight tone and brightness differences between adj pix due to changing
sun angle.

In PS, how does one make one image match another using the area of overlap
as control?

I cant find it in any manual.

thanks in advance,

PLEASE REPLY BY E_MAIL

Doug
--
Douglas R. Grant, PhD. (Terracon Geoscience International)
5 Birchview Court, Nepean  ON, K2G 3M7,  CANADA  

Terrain analysis for planning, resources, hazards, & landscape appreciation

2. FAQ?

3. Stitching Images

4. the FollowCurve plugin tool + animator 8.2

5. Combining/Joining/Stitching Images - V5

6. Available: OpenGL programmers

7. Colorbalance blending towards the seam of two stitched images

8. Color matching - stitched images

9. Stitching images

10. Stitching images that should overlap

11. Stitching images clarification