Skip to content

Instantly share code, notes, and snippets.

@larrykite
Created November 4, 2011 18:30
Show Gist options
  • Save larrykite/1340099 to your computer and use it in GitHub Desktop.
Save larrykite/1340099 to your computer and use it in GitHub Desktop.
Convert 32F to 8U for display
Mat img = imread("image.jpg");
Mat grey;
cvtColor(img, grey, CV_BGR2GREY);
Mat sobelx;
Sobel(grey, sobelx, CV_32F, 1, 0);
double minVal, maxVal;
minMaxLoc(sobelx, &minVal, &maxVal); //find minimum and maximum intensities
Mat draw;
sobelx.convertTo(draw, CV_8U, 255.0/(maxVal - minVal), -minVal);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment