Extract Sobel feature from an image
2014-11-17 12:13
183 查看
#include <iostream> #include <opencv.hpp> using namespace std; using namespace cv; int main() { Mat img = imread("t.jpg"); Mat grey; cvtColor(img, grey, CV_BGR2GRAY); Mat sobelx; Mat sobely; Sobel(grey, sobelx, CV_32F, 1, 0); Sobel(grey, sobely, CV_32F, 0, 1); double minVal_x, minVal_y, maxVal_x, maxVal_y; minMaxLoc(sobelx, &minVal_x, &maxVal_x); //find minimum and maximum intensities minMaxLoc(sobely, &minVal_y, &maxVal_y); //find minimum and maximum intensities Mat draw_x; Mat draw_y; sobelx.convertTo(draw_x, CV_8U, 255.0/(maxVal_x - minVal_x), -minVal_x * 255.0/(maxVal_x - minVal_x)); sobely.convertTo(draw_y, CV_8U, 255.0/(maxVal_y - minVal_y), -minVal_y * 255.0/(maxVal_y - minVal_y)); namedWindow("sobelx", CV_WINDOW_AUTOSIZE); imshow("sobelx", draw_x); //waitKey(); namedWindow("sobely", CV_WINDOW_AUTOSIZE); imshow("sobely", draw_y); waitKey(); return 0; }
相关文章推荐
- Create an ISO Image from a source CD or DVD on ubuntu
- 精彩控件件源码(3)-ImageListPopup, a C# class which pops up a window to select an image from an image list
- 论文阅读:An Automatic Panoramic Image Reconstruction Scheme from Dental Computed Tomography Images
- How to create jigsaw puzzle from an image using javascript(拼图引擎)
- (转载)无法从带有索引像素格式的图像创建graphics对象|A Graphics object cannot be created from an image that has an indexed pixel format
- Direct2D Intro - Retrieve the Frames from an Image
- Load an image from a url into a PictureBox
- Send an image from the iPhone using ASIHTTP and UIImagePicker
- Simple VBScript program to extract data from all worksheets in an Excel spreadsheet
- Simple VBScript program to extract data from all worksheets in an Excel spreadsheet
- Capturing an Image from a window
- ModalPopupExtender Example: Creating an image thumbnail viewer(From Matt Berseth)
- How to extract component from vector image
- Extract the bitmap image data from the bitmap
- How do I get an image from an UIButton? 如何获取uibutton设置的uiimage
- Extract User Defined Region From An Chromosome Fasta File
- 无法从带有索引像素格式的图像创建graphics对象|A Graphics object cannot be created from an image that has an indexed pixel format
- extract a crop from image and remark groundtruth(if left then flip)
- Copying an image from one server to another using PHP