How to Change image intensity range [closed]

asked 2016-03-24 11:34:43 -0600

asa gravatar image

updated 2016-03-24 11:54:37 -0600


I am working with image registration. I have gray-scale images (CV_8UC1). I have done the registration part. Now I want to check the alignment accuracy. I want to convert the intensity range to [-127 to 128] from [0 to 255]. How can I do that? What I am doing is:

  • subtract the aligned image from template
  • divide the result by 2
  • add 128 to result

Is this correct? Do I need to convert the images from 8U ?


edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by sturkmen
close date 2020-10-06 05:16:12.865128



"Do I need to convert the images from 8U" -- definitely !

berak gravatar imageberak ( 2016-03-24 11:46:51 -0600 )edit

Hi berak,

In the code example shown here in the showDifference function images are being converted to 32F. Should that be the approach?I want to check two things: missing object and extra object in the aligned image.

asa gravatar imageasa ( 2016-03-24 11:54:24 -0600 )edit

yes, that example looks perfect to me.

(well, you only need to convert to CV_32FC1 only for your grayscale images, and skip the grayscale conversion there)

berak gravatar imageberak ( 2016-03-24 11:57:26 -0600 )edit

"I want to check two things: missing object and extra object in the aligned image" -- you might want to explain this a bit deeper (if you need further help on that)

berak gravatar imageberak ( 2016-03-24 11:59:59 -0600 )edit


Ok so I am working with printed images. I have a set of images and I am checking the cover side of each image. The first image is the template image. the rest are checked against the template. For each subsequent image there is some distortion / motion present. So I am doing the registration. I am experimenting with estimateRigidTransform() and fidTransformECC to see alignment performance. I need to check if there is missing print and/or extra print comparing the aligned image against the template.

asa gravatar imageasa ( 2016-03-24 12:09:17 -0600 )edit