Skip to content

Instantly share code, notes, and snippets.

@larrykite
larrykite / OCV_Cookbook_strategy_pattern.cpp
Created November 14, 2011 18:16
set up opencv iterators for 3 channel input and 1 channel output
Mat image;
Mat result;
cv::Mat_<cv::Vec3b>::const_iterator it = image.begin<cv::Vec3b>();
cv::Mat_<cv::Vec3b>::const_iterator itend = image.end<cv::Vec3b>();
cv::Mat_<uchar>::iterator itout=result.begin<uchar>();
for ( ; it!=itend; ++it, ++itout){
if (getDistance(*it) < minDist){
*itout = 255;
@larrykite
larrykite / *Scratch*
Created November 4, 2011 18:30
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);