Not for the faint hearted...
IMHO you will need expert help. The official line is that Symantec will NOT support your environments if you find a way to do this yourself.
The copying of the images database, sure we could do that... but the real sticking point is how to populate the v6.5 EMM database with the "media DB" and the "vol DB" from the v5.1 environment. IMHO I would engage Symantec Professional Services, which is going to cost $$$.
In principal, I see the steps as being:
1) De-activate all policies in both environments. Do NOT run any more backups in either environment!
2) Take two copies of a catalog backup for both environments. Write protect this data. Eject one copy of each, and lock it away somewhere safe. These copies are your last resort recovery points.
3) Upgrade the v5.1 master to v6.5.
4) Take a complete bpimagelist -idonly -d 01/01/1970 00:00:00 from each environment.
5) Run a script to compare both lists against each other to ensure that you do NOT have two images with the same backupid - i.e. that you do not have two images of "client_ctime" in each environment.
6) Shutdown the NetBackup application on both environments.
7) Now you need Symantec PS to copy the imageDB over and export the EMM database from the old env, and to copy all this data over and import the old exported EMM data into the EMM database of your target v6.5 environment, i.e. mediaDB, volDB. One of the real problems is the pool numbers. It is highly likely that both environments have different pool names, but the same pool numbers. The Symantec work should encompass resetting the pool numbers for many/all of the images coming over from the old environment - i.e. resetting the pool numbers inside the imageDB, mediaDB and volDB. And probably a whole host of other actions that are beyond my knowledge.
8) Copy over the "policies" - a straight copy of "/db/class" will do.
9) Copy over the "client attributes" - a straight copy of "/db/client" will do.
10) At this point Symantec PS should help you restart your newer v6.5 env, and perform tests to see if the new environment now knows about all the old images.
11) Uninstall NetBackup master server software completely from your old v5.1 environment.
12) Fresh install of NetBackup v6.5 - but media server only on the old machine - specifying your master server name as the server with the now merged databases.
13) Run device discovery wizard.
14) Inventory your robots.
15) Attempt a test restore of a folder of data for a client that existed only on the old environment.
16) Attempt a test restore of a folder of data for a client that existed only on the new environment.
17) Amend all the old (copied over) policies to specify the new storage unit of the new media server (i.e. what was the old master).
18) Take two copies of catalog backup of your new environment.
19) Create a test policies, with no time schedules, with one client from old env and one client from new env.
20) Update first "Server=" entry in bp.conf on the old client.
21) Run a test backup to a test pool.
22) Which media were used? It should have used scratch media.
23) Now update the "Server=" entry for all clients that were on the old env...
24) Re-activate your policies.
25) Let fly.
Easy as pie.