user1538798
user1538798

Reputation: 1135

joint histogram between 2 image

Would like to ask if anyone has or can point me to a fast implementation of a function that calculates the joint histogram between two images?

Thanks

Upvotes: 1

Views: 3570

Answers (2)

yanlend
yanlend

Reputation: 480

Calculating the joint histogram between multiple images works directly with cv2.calcHist() as well. The trick is to pass an array of the images you want to have in the joint histogram. Then, you have to select the channels that should end up in the histogram. The channel numbering is described here.

This is a short example code in Python that calculates the joint histogram between im1 and im2:

im1 = cv2.imread(im1_path, cv2.CV_LOAD_IMAGE_GRAYSCALE)
im2 = cv2.imread(im2_path, cv2.CV_LOAD_IMAGE_GRAYSCALE)
h = cv2.calcHist( [im1, im2], [0, 1], None, [256, 256], [0, 256, 0, 256] )

Upvotes: 0

remi
remi

Reputation: 3988

Joint histogram or cumulated histogram? For the latter, calcHist with the accumulate flags set to true will do the job.

For the first case, reading this link might be helpful.

Upvotes: 1

Related Questions