Question

Concatenating multiple Images

Asked by: JustScreenShot

Dear experts

I want to concatenate two images that have are overlapped with each other. Sample of two such images are attched. Images 1.png, 2.png, 3.png, 4.png and 5.png are overlapped and I want to create a concatenated version of these images. Overlapped sections of the images should not copied. The overlapped sections didn't have fixed height.

I need a very very fast (As fast as possible) and accurate function for concatenation.

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2008-06-24 at 08:06:37ID23511289
Tags

Delphi

Topic

Delphi Programming

Participating Experts
5
Points
0
Comments
16

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. CONCATENATING
    i am createing a view and want to CONCATENATE two fields, how do I do this?
  2. Concatenation using + or  &￿￿￿￿
    The concatenation going on here: Me.ProductIDTable. Columns.Add( "FullProduct" , GetType(String) , "ProductName + '-' + Category + '-' + Measure + '-' + OzLtr + '-' + SupplierName" ) Please explain why I can't use the & symbol to concatenate but ...
  3. concatenate
    Hello, I would like to concatenate two cells that result in: March 1 thru March 8, but on the March 8 the format is not returning March 8. My formula is:CONCATENATE(H5," ","thru"," ",G3). I have attached the file for reference. Nick

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: rfwoolfPosted on 2008-06-24 at 08:40:30ID: 21856933

Attached is a procedure that you can play around with to get the results you need... What the procedure below does is it places a bitmap in the centre of another bitmap on a Timage- you will use the same idea.

Also, In this attached demo you use 2 Opendialogs to point to the images you want to use - you can instead just replace these parts with the path to the images you need - or if you somehow have them in memory.

Basically what you'll need to do is have a TImage and 2 TBitmaps.
You will need to size the Timage big enough to fit the two concatenated images - in other words Timage will be your canvas for laying out of the images.
Then you simply draw the bitmaps onto the canvas:
image1.Picture.Bitmap.Canvas.draw(X,Y,bitmap);//place the bitmap onto the image //where X and Y is the top and left of the image
image1.Picture.Bitmap.Canvas.draw(X,Y,bitmap2);//place the bitmap2 onto the image

For this you will need a TImage component on your form,
as well as a button
as well as an OpenDialogue.
It is recommended (but not essential) that you set your TImage component's Autosize to True;
 
Here is the sourcecode for the button...
 
procedure TForm1.Button1Click(Sender: TObject);
var
  bitmap1   : TBitMap;      //declare bitmap container 1
  bitmap2   : TBitMap;      //declare  bitmap container 2
  daLeft, daTop : Integer;  //declare two integer units for positioning of the second bitmap
begin
  if opendialog1.Execute then //opens a dialogue asking for the first image
  begin
    bitmap1 := TBitmap.Create;  //create the bitmap container 1
    try
      bitmap1.LoadFromFile(opendialog1.FileName);  //load the file the user chose into the bitmap 1
      image1.Picture.Bitmap.Assign(bitmap1);  //load bitmap1 into your form's image component
      //MOVING ON TO NEXT BITMAP
      if opendialog1.Execute then //opens a dialogue asking for the first image
      begin
        bitmap2 := TBitMap.Create; //create the bitmap container 2
        bitmap2.LoadFromFile(opendialog1.FileName);  //load the file the user chose into the bitmap 2
         try
          daLeft := round((bitmap1.width - bitmap2.width) / 2); //calculate left position of 2nd bitmap
          daTop := round((bitmap1.Height - bitmap2.Height) / 2); //calculate top position of 2nd bitmap
          image1.Picture.Bitmap.Canvas.draw(daLeft,daTop,bitmap2);//place the bitmap 2 onto the bitmap 1 on the image
        finally
          bitmap2.Free;  //free the 2nd bitmap container in memory
        end;
      end;
    finally
      bitmap1.Free;   //free the 2nd bitmap container in memory
    end;
  end;
end;

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:

Select allOpen in new window

 

by: rfwoolfPosted on 2008-06-24 at 08:42:07ID: 21856952

I then forgot a very important part - the output!
You will then say
  Image1.picture.SaveToFile('MyImage.BMP'); -- if you want to save it to a file
or else you can copy it to the clipboard or do what you want.

If you have a problem with the format (BMP) see if you can use PNG instead - I think you can. Alternatively in the JVCL suite there is a TImage type component that works with a variety of formats including GIF, jpeg, BMP etc - so instead of using a TImage you will use TJvImage or something

 

by: JustScreenShotPosted on 2008-06-24 at 10:17:51ID: 21858040

Dear rfwoolf

Thank for the answer. May be I was not clear enough. I actually need an algorithm for finding overlapped sections of the image and delete the overlapped parts and concatenate 3 images or more together.

 

by: rfwoolfPosted on 2008-06-24 at 10:22:31ID: 21858080

Yes I'm afraid you didn't explain yourself very well - I still don't understand because the 5 example images don't make sense - there doesn't seem to be a discernable pattern. The images are 'cut' in unexpected places - you need to explain exactly how you'd want it to do it. If you can't explain it to a human, you might have some trouble explaining it to a PC :)

 

by: developmentguruPosted on 2008-06-24 at 10:51:17ID: 21858358

 I think I can see what you are looking for... if I am right then my explanation should help.  The first 4 images, in the area that is text, appear to be the same.  The fifth image has a little more text.  On the right side however the images are different.  So, from what I can see, you want to reconstruct the image on the right by stripping out all of what is in the image on each one, and correctly overlap them to produce a larger, complete, image.

simplified...

image 1
----
        A
        B
----

image 2
----
        B
        C
        D
----

produces...
----
        A
        B
        C
        D
----


  Let me know if I am correct on this.

 

by: developmentguruPosted on 2008-06-24 at 10:51:55ID: 21858369

or, perhaps you want the whole screen?

 

by: JustScreenShotPosted on 2008-06-25 at 05:26:32ID: 21864717

Dear developmentguru, neither of 5 images ARE NOT the same. Each of them has more text than the previous. Actually I want to create a screenshot from the page wholly.

Assume this page that you are reading my comment. take a capture from the the internal browser window. Now press down key and take a new capture. repeat these steps until you reached to the end of the page. Now I want to concatenate these pictures with each other. At the first step should overlapped sections of images recognized and then the images could stick to each other without overlapped section to make the finall image. this is a feature named "Automatic Scrolling" could be found at screen capture program like SnagIt.

 

by: rfwoolfPosted on 2008-06-25 at 05:32:13ID: 21864764

I think one important technical consideration is whether it's possible to calculate which portions of the images can be 'cut off' - for example if you know that the screen scrolls 50 pixels down then you know to cut off 50 pixels. But if that's not possible becomes much harder and you have to start with image algorithms to get the program to 'visually' compare the images for similar pixels .

So JustScreenShot - *HOW* you are getting these images is important - because you might be able to collect how many pixels the screen has scrolled.

 

by: Geert_GruwezPosted on 2008-06-25 at 06:22:39ID: 21865235

http://www.scootersoftware.com

the program is called BeyondCompare and it has a picture compare tool.
You can compare 2 pictures in several modes.

with this you can find the matching blocks manually

next step would be to add the non matching blocks to a total image

repeat the process for each subsequent image

problem is there is no automatic matching block algorithm

VNC also has a way of only sending the blocks of the screenshot that have changed...

Am i getting anywhere close ?

 

by: rllibbyPosted on 2008-06-25 at 07:26:08ID: 21865940

JustScreenShot,

I would agree with the others that the *how* (regarding image collection) is important, as knowing this may allow for alternative suggestions. For example, if you are only dealing with browser window capturing, I do have code that will allow you to capture the "whole" browser window image, regardless of scroll bars.

Russell

 

by: developmentguruPosted on 2008-06-26 at 05:38:25ID: 21874103

 The problem is more complex than you know.  If you scan image 1 and find an exact matching line of pixels in image 2, is that a match?  I personally have seen the same line of text inserted twice for emphasis.  This means that if you scan the same 12 pixels of the line in image one you can find it in more then one location in image 2.  If you do a line by line search and show all matches for each line then you would be able to find the longest consecutive match and use that as your starting block.  This is oversimplified as it only matches vertically.  I would not consider such an algorythm to be complete without taking into account the possibility of horizontal changes.

  You may be able to take an easier approach to this though.  The approach would likely be limited by Windows.  If you were to resize the window to the needed size for a full capture, then capture it.  I am really just thinking out loud here, so bear with me.  In Delphi you can request a window paint itself to a bitmap.  I would expect that this is a function of Delphi more than of windows. You can use Windows messages to figure out the needed extents by finding and sendig messages to the windows scroll bars.  This will get you the needed scroll values that will let you determine the size.  Once you have the size you could create a Delphi window (invisible or off screen) containing a web browser component) of the correct size and go to the web address (also determined using windows messages if needed).  Of course if you are using a Delphi window you could just resize until the scroll bars are off... Once this is done, just request that the window paint to a bitmap and you are done.  Save it, copy to the clipboard, whatever.  One downside to this approach is that many sites have advertising that changes with each visit.  This would likely be different.

  I hope that this helps to clarify the original approach and, perhaps, helps you think outside the box for other possibilities.

 

by: JustScreenShotPosted on 2008-06-29 at 05:14:40ID: 21893671

Thank for the comments

rfwoolf:
I'm sure this is something possible because programs like SnagIt and CaptureWizPro accomplish that, successfully.

I got images by captureing current window content, pressing down arrow key, capturing window content, pressing down arrow key, captureing window content, .....

Geert_Gruwez:
Thank for the pointing me forward to VNC. I will take a look over it.


rllibby:

I want to use a generic way for all or most of windows and not only Browsers. As I said it's something that SnagIt accomplished it very quick and well.

developmentguru:
Yes. I agree with you that it's almost seems impossible to design an algorithm that could be found overlapped sections of two images. I wrote a very simple function to do this comparision But the result is not good and sometimes the algorithm found inaccurate positions.

Your solution to repaint the content window to a TBitmap is theorically seems to work but practically there are lot's of problem with various windows with this method. I have a very good code samle that accomplish this. I will send the link, in the next hours.

I'm very courious to know how a program likes SnagIt accomplished this task very quickly and accurately.

 

by: JustScreenShotPosted on 2008-06-29 at 05:17:02ID: 21893679

I'm not sure but may be program like SnagIt is not comparing two images. Maybe it use a completely different approach and it is able to get the current position of the scrolled window. I found an interesting similar question without any answer, here:
http://www.experts-exchange.com/Programming/System/Windows__Programming/Q_23496918.html?cid=239

 

by: JustScreenShotPosted on 2008-06-29 at 09:26:38ID: 21894526

Here is a code that I wrote for finding overlapped sections of two images. As I already said it's inaccurate.

procedure FindOverlap(B1, B2: TBitmap; var FoundR1,
  FoundR2: Integer; MatchesRowsMinimum: Integer);
var
  R1, R2, X, RX: Integer;
  MatchesRow: Integer;
  C1, C2: PRGBTripleArr;
begin
  FoundR1 := 0;
  FoundR2 := 0;
 
  for R1 := B1.Height - 1 downto 0 do begin
    C1 := B1.ScanLine[R1];
    for R2 := 0 to B1.Height - 1 do begin
      C2 := B2.ScanLine[R2];
      RX := R2;
      if IsRowEqual(C1, C2, B1.Width) then begin
        MatchesRow := 0;
        for X := R1 to B1.Height - 1 do begin
          C1 := B1.ScanLine[X];
          C2 := B2.ScanLine[RX];
          if IsRowEqual(C1, C2, B1.Width) then
            Inc(MatchesRow)
          else
          begin
            MatchesRow := 0;
            Break;
          end;
 
          if (MatchesRow > MatchesRowsMinimum) then begin
            FoundR1 := R1;
            FoundR2 := R2 + 20;
          end; // if
 
          if RX < B1.Height - 1 then Inc(RX);
          if (FoundR1 <> 0) or (FoundR2 <> 0) then Break;
        end; // for X
      end; // if IsRowEqual
 
      if (FoundR1 <> 0) or (FoundR2 <> 0) then Break;
      Application.ProcessMessages;
    end; // for R2
 
    if (FoundR1 <> 0) or (FoundR2 <> 0) then Break;
    Application.ProcessMessages;
  end; // for R1
end;

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:

Select allOpen in new window

 

by: Computer101Posted on 2008-09-17 at 20:01:38ID: 22506710

PAQed with points refunded (500)

Computer101
EE Admin

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...