Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Copy histogram of an image to another

Hi all! Here's my problem: I have two images of the same thing acquired with different illumination condition. I found that is possible to copy the histogram of a reference image to a destination image, and it's called histogram specification or histogram matching. As shown here https://studentathome.wordpress.com/2013/03/27/histogram-specification-matching/, in matlab it's pretty simple. There is a way to do the same thing on OpenCV?

Copy histogram of an image to another

Hi all! Here's my problem: I have two images of the same thing acquired with different illumination condition. I found that is possible to copy the histogram of a reference image to a destination image, and it's called histogram specification or histogram matching. As shown here https://studentathome.wordpress.com/2013/03/27/histogram-specification-matching/, in matlab it's pretty simple. There is a way to do the same thing on OpenCV?

EDIT I've used the code posted on a comment in the website link text and it doesn't work. i have these problem:

  • error on vector declaration. I think I resolved by declaring the vector with the int type.
  • error on double* _src_cdf = src_cdf.ptr();. I have underline on src_cdf, which I haven't resolved
  • error on do1ChnHist(chns[i], src_mask, _src_hist, _src_cdf);, with underline on first parameter.
  • error on every -tm.at. I think I resolved by using _tm.at<uchar>.
  • Underline on the slash in h[c][/ c], unresolved.

How can I make it work with Opencv 3.1?

Copy histogram of an image to another

Hi all! Here's my problem: I have two images of the same thing acquired with different illumination condition. I found that is possible to copy the histogram of a reference image to a destination image, and it's called histogram specification or histogram matching. As shown here https://studentathome.wordpress.com/2013/03/27/histogram-specification-matching/, in matlab it's pretty simple. There is a way to do the same thing on OpenCV?

EDIT I've used The code linked on the code posted on a comment in the website page link text and it doesn't work. i have these problem:gives me error on the lines:

  • error on vector declaration. I think I resolved by declaring the vector with the int type.
  • error on double* _src_cdf = src_cdf.ptr();. I have underline on src_cdf, which I haven't resolved
  • error on
    do1ChnHist(chns[i], src_mask, _src_hist, _src_cdf);src_hist, src_cdf);
    do1ChnHist(chns1[i], dst_mask, dst_hist, dst_cdf);
    , with underline on first parameter.
  • error on every -tm.at. I think I resolved by using _tm.at<uchar>.
  • Underline on the slash in h[c][/ c], unresolved.

it says that I can't pass a matrix (src_hist etc) because the function accepts double*. How can I make it work with Opencv 3.1?

Copy histogram of an image to another

Hi all! Here's my problem: I have two images of the same thing acquired with different illumination condition. I found that is possible to copy the histogram of a reference image to a destination image, and it's called histogram specification or histogram matching. As shown here https://studentathome.wordpress.com/2013/03/27/histogram-specification-matching/, in matlab it's pretty simple. There is a way to do the same thing on OpenCV?

EDIT The code linked on the page link text gives me error on the lines:

do1ChnHist(chns[i], src_mask, src_hist, src_cdf);
do1ChnHist(chns1[i], dst_mask, dst_hist, dst_cdf);

it says that I can't pass a matrix (src_hist etc) because the function accepts double*. How can I make it work with Opencv 3.1?

EDIT 2 Now it compiles and run, but i obtain as a matched image a black image. Since I need to match the histogram of the whole image, I created as mask a Mat on ones. Am I doing right? Any suggestion?

Copy histogram of an image to another

Hi all! Here's my problem: I have two images of the same thing acquired with different illumination condition. I found that is possible to copy the histogram of a reference image to a destination image, and it's called histogram specification or histogram matching. As shown here https://studentathome.wordpress.com/2013/03/27/histogram-specification-matching/, in matlab it's pretty simple. There is a way to do the same thing on OpenCV?

EDIT The code linked on the page link text gives me error on the lines:

do1ChnHist(chns[i], src_mask, src_hist, src_cdf);
do1ChnHist(chns1[i], dst_mask, dst_hist, dst_cdf);

it says that I can't pass a matrix (src_hist etc) because the function accepts double*. How can I make it work with Opencv 3.1?

EDIT 2 Now it compiles and run, but i obtain as a matched image a black image. Since I need to match the histogram of the whole image, I created as mask a Mat on ones. Am I doing right? Any suggestion?