1
我正在嘗試調整javacv中的IplImage圖像的大小。我找到了cvResize函數來做這樣的事情。我的工作流程是:打開圖像將其轉換爲gray_scale,將其調整到所需的大小,最後重新塑造它。我已經讀過它將其轉換爲gray_scale並調整它的大小。重塑我的最後一步是什麼?我有我想要的cvReshape。我有一個IplImage,我必須將其轉換爲cvMat。下一步是重塑,其中需要4個參數,cvArr a cvMat和所需的尺寸。在javacv中重新整形IplImage
// read an image
final IplImage image = cvLoadImage("ef.jpg");
//create image window named "My Image"
final CanvasFrame canvas = new CanvasFrame("My Image");
// request closing of the application when the image window is closed
canvas.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
// show image on window
canvas.showImage(image);
IplImage GrayImage = cvCreateImage(cvGetSize(image), IPL_DEPTH_8U, 1);
cvCvtColor(image, GrayImage, CV_BGR2GRAY);
IplImage img = IplImage.create(60, 60, IPL_DEPTH_8U, 1);
//resize the image
cvResize(GrayImage, img, CV_INTER_LINEAR);
cvSaveImage("4-rjb" + ".jpg", img);
//cvReleaseImage(result1);
System.out.println("The size of the image: "+img);
CvMat mtx = CvMat.createHeader(img.height(), img.width());
cvGetMat(img, mtx, null, 0);
System.out.println(mtx);
cvReshape(img, mtx, 3600, 1);
我收到的錯誤:
OpenCV Error: Bad number of channels() in unknown function, file .\src\array.cpp,
line 2721
我剛纔已經想重塑2D圖像,爲什麼渠道錯誤的壞數發生?
是的,所以我的解決方案是創建ny自己的重塑:)! –