Just spitballing here, but I know notifications are stored in a sqlite3 database. You might be able to query the count based on application type and use that?
However, that is the one that feeds the Notification Center itself. If ones dismisses a notification from Messages via the Notification Center, but does not open the message itself, then the count would be off between what remains in the Notification Center database and the actual number of the Messages' alert badge.
For example, one could have 3 notifications in the Notification Center belonging to Messages, but one could still have 20 unchecked text messaged. Thus, my suggestion wouldn't actually solve the problem.
Though, there may be another database one could check that I am unaware of.